From b00780a7898db7f92c00d485fa1524805cd3e070 Mon Sep 17 00:00:00 2001 From: Akira Kakuto Date: Wed, 6 Jun 2018 07:23:34 +0000 Subject: harfbuzz 1.8.0 git-svn-id: svn://tug.org/texlive/trunk@47939 c570f23f-e606-0410-a88d-b1316a301751 --- .../harfbuzz-src/src/hb-ot-color-cbdt-table.hh | 211 ++++++++++++++------- 1 file changed, 139 insertions(+), 72 deletions(-) (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh') diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh index e7ab917e06e..d1dd9de4771 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-color-cbdt-table.hh @@ -29,6 +29,18 @@ #include "hb-open-type-private.hh" +/* + * CBLC -- Color Bitmap Location + * https://docs.microsoft.com/en-us/typography/opentype/spec/cblc + * https://docs.microsoft.com/en-us/typography/opentype/spec/eblc + * CBDT -- Color Bitmap Data + * https://docs.microsoft.com/en-us/typography/opentype/spec/cbdt + * https://docs.microsoft.com/en-us/typography/opentype/spec/ebdt + */ +#define HB_OT_TAG_CBLC HB_TAG('C','B','L','C') +#define HB_OT_TAG_CBDT HB_TAG('C','B','D','T') + + namespace OT { struct SmallGlyphMetrics @@ -47,21 +59,21 @@ struct SmallGlyphMetrics extents->height = -height; } - HBUINT8 height; - HBUINT8 width; - HBINT8 bearingX; - HBINT8 bearingY; - HBUINT8 advance; - + HBUINT8 height; + HBUINT8 width; + HBINT8 bearingX; + HBINT8 bearingY; + HBUINT8 advance; + public: DEFINE_SIZE_STATIC(5); }; struct BigGlyphMetrics : SmallGlyphMetrics { - HBINT8 vertBearingX; - HBINT8 vertBearingY; - HBUINT8 vertAdvance; - + HBINT8 vertBearingX; + HBINT8 vertBearingY; + HBUINT8 vertAdvance; + public: DEFINE_SIZE_STATIC(8); }; @@ -73,19 +85,19 @@ struct SBitLineMetrics return_trace (c->check_struct (this)); } - HBINT8 ascender; - HBINT8 decender; - HBUINT8 widthMax; - HBINT8 caretSlopeNumerator; - HBINT8 caretSlopeDenominator; - HBINT8 caretOffset; - HBINT8 minOriginSB; - HBINT8 minAdvanceSB; - HBINT8 maxBeforeBL; - HBINT8 minAfterBL; - HBINT8 padding1; - HBINT8 padding2; - + HBINT8 ascender; + HBINT8 decender; + HBUINT8 widthMax; + HBINT8 caretSlopeNumerator; + HBINT8 caretSlopeDenominator; + HBINT8 caretOffset; + HBINT8 minOriginSB; + HBINT8 minAdvanceSB; + HBINT8 maxBeforeBL; + HBINT8 minAfterBL; + HBINT8 padding1; + HBINT8 padding2; + public: DEFINE_SIZE_STATIC(12); }; @@ -102,10 +114,10 @@ struct IndexSubtableHeader return_trace (c->check_struct (this)); } - HBUINT16 indexFormat; - HBUINT16 imageFormat; - HBUINT32 imageDataOffset; - + HBUINT16 indexFormat; + HBUINT16 imageFormat; + HBUINT32 imageDataOffset; + public: DEFINE_SIZE_STATIC(8); }; @@ -131,9 +143,9 @@ struct IndexSubtableFormat1Or3 return true; } - IndexSubtableHeader header; - Offset offsetArrayZ[VAR]; - + IndexSubtableHeader header; + Offset offsetArrayZ[VAR]; + public: DEFINE_SIZE_ARRAY(8, offsetArrayZ); }; @@ -214,15 +226,17 @@ struct IndexSubtableRecord offset, length, format); } - HBUINT16 firstGlyphIndex; - HBUINT16 lastGlyphIndex; - LOffsetTo offsetToSubtable; - + GlyphID firstGlyphIndex; + GlyphID lastGlyphIndex; + LOffsetTo offsetToSubtable; + public: DEFINE_SIZE_STATIC(8); }; struct IndexSubtableArray { + friend struct CBDT; + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const { TRACE_SANITIZE (this); @@ -249,8 +263,7 @@ struct IndexSubtableArray } protected: - IndexSubtableRecord indexSubtablesZ[VAR]; - + IndexSubtableRecord indexSubtablesZ[VAR]; public: DEFINE_SIZE_ARRAY(0, indexSubtablesZ); }; @@ -258,6 +271,7 @@ struct IndexSubtableArray struct BitmapSizeTable { friend struct CBLC; + friend struct CBDT; inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { @@ -275,19 +289,19 @@ struct BitmapSizeTable } protected: - LOffsetTo indexSubtableArrayOffset; - HBUINT32 indexTablesSize; - HBUINT32 numberOfIndexSubtables; - HBUINT32 colorRef; - SBitLineMetrics horizontal; - SBitLineMetrics vertical; - HBUINT16 startGlyphIndex; - HBUINT16 endGlyphIndex; - HBUINT8 ppemX; - HBUINT8 ppemY; - HBUINT8 bitDepth; - HBINT8 flags; - + LOffsetTo + indexSubtableArrayOffset; + HBUINT32 indexTablesSize; + HBUINT32 numberOfIndexSubtables; + HBUINT32 colorRef; + SBitLineMetrics horizontal; + SBitLineMetrics vertical; + GlyphID startGlyphIndex; + GlyphID endGlyphIndex; + HBUINT8 ppemX; + HBUINT8 ppemY; + HBUINT8 bitDepth; + HBINT8 flags; public: DEFINE_SIZE_STATIC(48); }; @@ -299,19 +313,26 @@ struct BitmapSizeTable struct GlyphBitmapDataFormat17 { - SmallGlyphMetrics glyphMetrics; - HBUINT32 dataLen; - HBUINT8 dataZ[VAR]; - - DEFINE_SIZE_ARRAY(9, dataZ); + SmallGlyphMetrics glyphMetrics; + LArrayOf data; + public: + DEFINE_SIZE_ARRAY(9, data); }; +struct GlyphBitmapDataFormat18 +{ + BigGlyphMetrics glyphMetrics; + LArrayOf data; + public: + DEFINE_SIZE_ARRAY(12, data); +}; -/* - * CBLC -- Color Bitmap Location Table - */ - -#define HB_OT_TAG_CBLC HB_TAG('C','B','L','C') +struct GlyphBitmapDataFormat19 +{ + LArrayOf data; + public: + DEFINE_SIZE_ARRAY(4, data); +}; struct CBLC { @@ -336,8 +357,8 @@ struct CBLC unsigned int count = sizeTables.len; for (uint32_t i = 0; i < count; ++i) { - unsigned int startGlyphIndex = sizeTables.array[i].startGlyphIndex; - unsigned int endGlyphIndex = sizeTables.array[i].endGlyphIndex; + unsigned int startGlyphIndex = sizeTables.arrayZ[i].startGlyphIndex; + unsigned int endGlyphIndex = sizeTables.arrayZ[i].endGlyphIndex; if (startGlyphIndex <= glyph && glyph <= endGlyphIndex) { *x_ppem = sizeTables[i].ppemX; @@ -352,16 +373,10 @@ struct CBLC protected: FixedVersion<> version; LArrayOf sizeTables; - public: DEFINE_SIZE_ARRAY(8, sizeTables); }; -/* - * CBDT -- Color Bitmap Data Table - */ -#define HB_OT_TAG_CBDT HB_TAG('C','B','D','T') - struct CBDT { static const hb_tag_t tableTag = HB_OT_TAG_CBDT; @@ -388,8 +403,8 @@ struct CBDT cbdt = nullptr; return; /* Not a bitmap font. */ } - cblc = Sanitizer::lock_instance (cblc_blob); - cbdt = Sanitizer::lock_instance (cbdt_blob); + cblc = cblc_blob->as (); + cbdt = cbdt_blob->as (); } @@ -447,6 +462,59 @@ struct CBDT return true; } + inline void dump (void (*callback) (const uint8_t* data, unsigned int length, + unsigned int group, unsigned int gid)) const + { + if (!cblc) + return; // Not a color bitmap font. + + for (unsigned int i = 0; i < cblc->sizeTables.len; ++i) + { + const BitmapSizeTable &sizeTable = cblc->sizeTables[i]; + const IndexSubtableArray &subtable_array = cblc+sizeTable.indexSubtableArrayOffset; + for (unsigned int j = 0; j < sizeTable.numberOfIndexSubtables; ++j) + { + const IndexSubtableRecord &subtable_record = subtable_array.indexSubtablesZ[j]; + for (unsigned int gid = subtable_record.firstGlyphIndex; + gid <= subtable_record.lastGlyphIndex; ++gid) + { + unsigned int image_offset = 0, image_length = 0, image_format = 0; + + if (!subtable_record.get_image_data (gid, + &image_offset, &image_length, &image_format)) + continue; + + switch (image_format) + { + case 17: { + const GlyphBitmapDataFormat17& glyphFormat17 = + StructAtOffset (this->cbdt, image_offset); + callback ((const uint8_t *) &glyphFormat17.data.arrayZ, + glyphFormat17.data.len, i, gid); + } + break; + case 18: { + const GlyphBitmapDataFormat18& glyphFormat18 = + StructAtOffset (this->cbdt, image_offset); + callback ((const uint8_t *) &glyphFormat18.data.arrayZ, + glyphFormat18.data.len, i, gid); + } + break; + case 19: { + const GlyphBitmapDataFormat19& glyphFormat19 = + StructAtOffset (this->cbdt, image_offset); + callback ((const uint8_t *) &glyphFormat19.data.arrayZ, + glyphFormat19.data.len, i, gid); + } + break; + default: + continue; + } + } + } + } + } + private: hb_blob_t *cblc_blob; hb_blob_t *cbdt_blob; @@ -459,9 +527,8 @@ struct CBDT protected: - FixedVersion<>version; - HBUINT8 dataZ[VAR]; - + FixedVersion<> version; + HBUINT8 dataZ[VAR]; public: DEFINE_SIZE_ARRAY(4, dataZ); }; -- cgit v1.2.3