diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2019-09-20 07:40:59 +0000 |
|---|---|---|
| committer | Tavmjong Bah <tavmjong@free.fr> | 2019-09-20 07:40:59 +0000 |
| commit | 800614382942330bedbbcd4cd694639dca094303 (patch) | |
| tree | c96e7de65d5701a5664d6727b2147c1bcc1b061f /src | |
| parent | Crashfix: switch from active LPE tool (gitlab/420) (diff) | |
| download | inkscape-800614382942330bedbbcd4cd694639dca094303.tar.gz inkscape-800614382942330bedbbcd4cd694639dca094303.zip | |
Handle SVG in OpenType fonts with compressed glyphs.
Diffstat (limited to 'src')
| -rw-r--r-- | src/libnrtype/OpenTypeUtil.cpp | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/src/libnrtype/OpenTypeUtil.cpp b/src/libnrtype/OpenTypeUtil.cpp index b5a0760ee..2b60cca9e 100644 --- a/src/libnrtype/OpenTypeUtil.cpp +++ b/src/libnrtype/OpenTypeUtil.cpp @@ -24,6 +24,9 @@ #include <harfbuzz/hb-ft.h> #include <harfbuzz/hb-ot.h> +// SVG in OpenType +#include "util/ziptool.h" + // Utilities used in this file @@ -378,8 +381,29 @@ void readOpenTypeSVGTable(const FT_Face ft_face, // << " Offset: " << offsetGlyph << " Length: " << lengthGlyph << std::endl; std::string svg; - for (unsigned int c = offsetGlyph; c < offsetGlyph + lengthGlyph; ++c) { - svg += (char) data[offset + c]; + + if (lengthGlyph > 1 && data[offset] & 0x1f && data[offset + 1] & 0x8b) { + // Glyph is gzipped + + std::vector<unsigned char> buffer; + for (unsigned int c = offsetGlyph; c < offsetGlyph + lengthGlyph; ++c) { + buffer.push_back(data[offset + c]); + } + + GzipFile zipped; + zipped.readBuffer(buffer); + + std::vector<unsigned char> unzipped_data = zipped.getData(); + for (auto i : unzipped_data) { + svg += (char)i; + } + + } else { + // Glyph is not compressed + + for (unsigned int c = offsetGlyph; c < offsetGlyph + lengthGlyph; ++c) { + svg += (unsigned char) data[offset + c]; + } } for (unsigned int i = startGlyphID; i < endGlyphID+1; ++i) { |
