CMakeLists.txt | 31 +++++++-- src/hb-aat-layout-common-private.hh | 84 --------------------------- src/hb-aat-layout-trak-table.hh | 8 +- src/hb-open-type-private.hh | 87 +++++++++++++++++++++++++++ src/hb-ot-color-cbdt-table.hh | 112 +++++++++++++++++------------------- src/hb-ot-color-colr-table.hh | 70 ++++------------------ src/hb-ot-layout-common-private.hh | 10 +-- src/hb-ot-var-fvar-table.hh | 6 - src/hb-private.hh | 13 ---- 9 files changed, 191 insertions(+), 230 deletions(-)
New commits: commit a0dccb6188d7a9174643c7239041cb1a5300b957 Author: Behdad Esfahbod <[email protected]> Date: Wed Mar 14 16:31:53 2018 +0100 Add NameID diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh index 5767b116..ab743733 100644 --- a/src/hb-aat-layout-trak-table.hh +++ b/src/hb-aat-layout-trak-table.hh @@ -56,11 +56,11 @@ struct TrackTableEntry } protected: - Fixed track; /* Track value for this record. */ - HBUINT16 trackNameID; /* The 'name' table index for this track */ + Fixed track; /* Track value for this record. */ + NameID trackNameID; /* The 'name' table index for this track */ OffsetTo<UnsizedArrayOf<FWORD> > - values; /* Offset from start of tracking table to - * per-size tracking values for this track. */ + values; /* Offset from start of tracking table to + * per-size tracking values for this track. */ public: DEFINE_SIZE_STATIC (8); diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index b065711b..5060b3eb 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -729,6 +729,9 @@ DEFINE_NULL_DATA (Tag, " "); /* Glyph index number, same as uint16 (length = 16 bits) */ typedef HBUINT16 GlyphID; +/* Name-table index, same as uint16 (length = 16 bits) */ +typedef HBUINT16 NameID; + /* Script/language-system/feature index */ struct Index : HBUINT16 { static const unsigned int NOT_FOUND_INDEX = 0xFFFFu; diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh index c5e7f521..e9240aaa 100644 --- a/src/hb-ot-layout-common-private.hh +++ b/src/hb-ot-layout-common-private.hh @@ -398,7 +398,7 @@ struct FeatureParamsStylisticSet * added to the end of this Feature Parameters * table in the future. */ - HBUINT16 uiNameID; /* The 'name' table name ID that specifies a + NameID uiNameID; /* The 'name' table name ID that specifies a * string (or strings, for multiple languages) * for a user-interface label for this * feature. The values of uiLabelNameId and @@ -427,24 +427,24 @@ struct FeatureParamsCharacterVariants } HBUINT16 format; /* Format number is set to 0. */ - HBUINT16 featUILableNameID; /* The ‘name’ table name ID that + NameID featUILableNameID; /* The ‘name’ table name ID that * specifies a string (or strings, * for multiple languages) for a * user-interface label for this * feature. (May be nullptr.) */ - HBUINT16 featUITooltipTextNameID;/* The ‘name’ table name ID that + NameID featUITooltipTextNameID;/* The ‘name’ table name ID that * specifies a string (or strings, * for multiple languages) that an * application can use for tooltip * text for this feature. (May be * nullptr.) */ - HBUINT16 sampleTextNameID; /* The ‘name’ table name ID that + NameID sampleTextNameID; /* The ‘name’ table name ID that * specifies sample text that * illustrates the effect of this * feature. (May be nullptr.) */ HBUINT16 numNamedParameters; /* Number of named parameters. (May * be zero.) */ - HBUINT16 firstParamUILabelNameID;/* The first ‘name’ table name ID + NameID firstParamUILabelNameID;/* The first ‘name’ table name ID * used to specify strings for * user-interface labels for the * feature parameters. (Must be zero diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 999b7236..17ff0e51 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -42,11 +42,11 @@ struct InstanceRecord } protected: - HBUINT16 subfamilyNameID;/* The name ID for entries in the 'name' table + NameID subfamilyNameID;/* The name ID for entries in the 'name' table * that provide subfamily names for this instance. */ HBUINT16 reserved; /* Reserved for future use — set to 0. */ Fixed coordinates[VAR];/* The coordinates array for this instance. */ - //HBUINT16 postScriptNameIDX;/*Optional. The name ID for entries in the 'name' + //NameID postScriptNameIDX;/*Optional. The name ID for entries in the 'name' // * table that provide PostScript names for this // * instance. */ @@ -68,7 +68,7 @@ struct AxisRecord Fixed defaultValue; /* The default coordinate value for the axis. */ Fixed maxValue; /* The maximum coordinate value for the axis. */ HBUINT16 reserved; /* Reserved for future use — set to 0. */ - HBUINT16 axisNameID; /* The name ID for entries in the 'name' table that + NameID axisNameID; /* The name ID for entries in the 'name' table that * provide a display name for this axis. */ public: commit 56946d21c0696ed6a098434537979396171c9bfb Author: Behdad Esfahbod <[email protected]> Date: Wed Mar 14 16:26:33 2018 +0100 [color/COLR] Simplify diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index fe93f64b..c1cf6de5 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -79,51 +79,9 @@ struct COLR inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - if (!(c->check_struct (this) && - c->check_array (&(this+layers), sizeof (LayerRecord), numLayers) && - c->check_array (&(this+baseGlyphs), sizeof (BaseGlyphRecord), numBaseGlyphs))) - return_trace (false); - - const BaseGlyphRecord* base_glyph_records = (this+baseGlyphs).arrayZ; - for (unsigned int i = 0; i < numBaseGlyphs; ++i) - if (base_glyph_records[i].firstLayerIdx + - base_glyph_records[i].numLayers > numLayers) - return_trace (false); - - return_trace (true); - } - - inline bool get_base_glyph_record (hb_codepoint_t glyph_id, - unsigned int &first_layer, - unsigned int &num_layers) const - { - const BaseGlyphRecord* base_glyph_records = (this+baseGlyphs).arrayZ; - unsigned int min = 0, max = numBaseGlyphs - 1; - while (min <= max) - { - unsigned int mid = (min + max) / 2; - hb_codepoint_t glyphid = base_glyph_records[mid].glyphid; - if (glyphid > glyph_id) - max = mid - 1; - else if (glyphid < glyph_id) - min = mid + 1; - else - { - first_layer = base_glyph_records[mid].firstLayerIdx; - num_layers = base_glyph_records[mid].numLayers; - return true; - } - } - return false; - } - - inline void get_layer_record (int layer, - hb_codepoint_t &glyph_id, - unsigned int &palette_index) const - { - const LayerRecord* records = (this+layers).arrayZ; - glyph_id = records[layer].glyphid; - palette_index = records[layer].colorIdx; + return_trace (c->check_struct (this) && + (this+baseGlyphs).sanitize (c, numBaseGlyphs) && + (this+layers).sanitize (c, numLayers)); } protected: commit 6418ae4e8a3f4681cb4e7d54c589562930bc0678 Author: Behdad Esfahbod <[email protected]> Date: Wed Mar 14 16:18:42 2018 +0100 [color/COLR] Clean up diff --git a/src/hb-aat-layout-common-private.hh b/src/hb-aat-layout-common-private.hh index 7c0dfa8b..454b141f 100644 --- a/src/hb-aat-layout-common-private.hh +++ b/src/hb-aat-layout-common-private.hh @@ -140,90 +140,6 @@ struct BinSearchArrayOf }; -/* TODO Move this to hb-open-type-private.hh and use it in ArrayOf, HeadlessArrayOf, - * and other places around the code base?? */ -template <typename Type> -struct UnsizedArrayOf -{ - inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; } - inline Type& operator [] (unsigned int i) { return arrayZ[i]; } - - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c, count))) return_trace (false); - - /* Note: for structs that do not reference other structs, - * we do not need to call their sanitize() as we already did - * a bound check on the aggregate array size. We just include - * a small unreachable expression to make sure the structs - * pointed to do have a simple sanitize(), ie. they do not - * reference other structs via offsets. - */ - (void) (false && arrayZ[0].sanitize (c)); - - return_trace (true); - } - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c, count))) return_trace (false); - for (unsigned int i = 0; i < count; i++) - if (unlikely (!arrayZ[i].sanitize (c, base))) - return_trace (false); - return_trace (true); - } - template <typename T> - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base, T user_data) const - { - TRACE_SANITIZE (this); - if (unlikely (!sanitize_shallow (c, count))) return_trace (false); - for (unsigned int i = 0; i < count; i++) - if (unlikely (!arrayZ[i].sanitize (c, base, user_data))) - return_trace (false); - return_trace (true); - } - - private: - inline bool sanitize_shallow (hb_sanitize_context_t *c, unsigned int count) const - { - TRACE_SANITIZE (this); - return_trace (c->check_array (arrayZ, arrayZ[0].static_size, count)); - } - - public: - Type arrayZ[VAR]; - public: - DEFINE_SIZE_ARRAY (0, arrayZ); -}; - -/* Unsized array of offset's */ -template <typename Type, typename OffsetType> -struct UnsizedOffsetArrayOf : UnsizedArrayOf<OffsetTo<Type, OffsetType> > {}; - -/* Unsized array of offsets relative to the beginning of the array itself. */ -template <typename Type, typename OffsetType> -struct UnsizedOffsetListOf : UnsizedOffsetArrayOf<Type, OffsetType> -{ - inline const Type& operator [] (unsigned int i) const - { - return this+this->arrayZ[i]; - } - - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const - { - TRACE_SANITIZE (this); - return_trace ((UnsizedOffsetArrayOf<Type, OffsetType>::sanitize (c, count, this))); - } - template <typename T> - inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, T user_data) const - { - TRACE_SANITIZE (this); - return_trace ((UnsizedOffsetArrayOf<Type, OffsetType>::sanitize (c, count, this, user_data))); - } -}; - - /* * Lookup Table */ diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh index 5d33199e..b065711b 100644 --- a/src/hb-open-type-private.hh +++ b/src/hb-open-type-private.hh @@ -862,6 +862,90 @@ static inline Type& operator + (Base &base, OffsetTo<Type, OffsetType> &offset) * Array Types */ + +/* TODO Use it in ArrayOf, HeadlessArrayOf, and other places around the code base?? */ +template <typename Type> +struct UnsizedArrayOf +{ + inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; } + inline Type& operator [] (unsigned int i) { return arrayZ[i]; } + + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c, count))) return_trace (false); + + /* Note: for structs that do not reference other structs, + * we do not need to call their sanitize() as we already did + * a bound check on the aggregate array size. We just include + * a small unreachable expression to make sure the structs + * pointed to do have a simple sanitize(), ie. they do not + * reference other structs via offsets. + */ + (void) (false && arrayZ[0].sanitize (c)); + + return_trace (true); + } + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c, count))) return_trace (false); + for (unsigned int i = 0; i < count; i++) + if (unlikely (!arrayZ[i].sanitize (c, base))) + return_trace (false); + return_trace (true); + } + template <typename T> + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, const void *base, T user_data) const + { + TRACE_SANITIZE (this); + if (unlikely (!sanitize_shallow (c, count))) return_trace (false); + for (unsigned int i = 0; i < count; i++) + if (unlikely (!arrayZ[i].sanitize (c, base, user_data))) + return_trace (false); + return_trace (true); + } + + private: + inline bool sanitize_shallow (hb_sanitize_context_t *c, unsigned int count) const + { + TRACE_SANITIZE (this); + return_trace (c->check_array (arrayZ, arrayZ[0].static_size, count)); + } + + public: + Type arrayZ[VAR]; + public: + DEFINE_SIZE_ARRAY (0, arrayZ); +}; + +/* Unsized array of offset's */ +template <typename Type, typename OffsetType> +struct UnsizedOffsetArrayOf : UnsizedArrayOf<OffsetTo<Type, OffsetType> > {}; + +/* Unsized array of offsets relative to the beginning of the array itself. */ +template <typename Type, typename OffsetType> +struct UnsizedOffsetListOf : UnsizedOffsetArrayOf<Type, OffsetType> +{ + inline const Type& operator [] (unsigned int i) const + { + return this+this->arrayZ[i]; + } + + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const + { + TRACE_SANITIZE (this); + return_trace ((UnsizedOffsetArrayOf<Type, OffsetType>::sanitize (c, count, this))); + } + template <typename T> + inline bool sanitize (hb_sanitize_context_t *c, unsigned int count, T user_data) const + { + TRACE_SANITIZE (this); + return_trace ((UnsizedOffsetArrayOf<Type, OffsetType>::sanitize (c, count, this, user_data))); + } +}; + + /* An array with a number of elements. */ template <typename Type, typename LenType=HBUINT16> struct ArrayOf diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 9f8b9375..fe93f64b 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -80,14 +80,14 @@ struct COLR { TRACE_SANITIZE (this); if (!(c->check_struct (this) && - c->check_array (&(this+layerRecordsOffsetZ), sizeof (LayerRecord), numLayerRecords) && - c->check_array (&(this+baseGlyphRecordsZ), sizeof (BaseGlyphRecord), numBaseGlyphRecords))) + c->check_array (&(this+layers), sizeof (LayerRecord), numLayers) && + c->check_array (&(this+baseGlyphs), sizeof (BaseGlyphRecord), numBaseGlyphs))) return_trace (false); - const BaseGlyphRecord* base_glyph_records = &baseGlyphRecordsZ (this); - for (unsigned int i = 0; i < numBaseGlyphRecords; ++i) + const BaseGlyphRecord* base_glyph_records = (this+baseGlyphs).arrayZ; + for (unsigned int i = 0; i < numBaseGlyphs; ++i) if (base_glyph_records[i].firstLayerIdx + - base_glyph_records[i].numLayers > numLayerRecords) + base_glyph_records[i].numLayers > numLayers) return_trace (false); return_trace (true); @@ -97,8 +97,8 @@ struct COLR unsigned int &first_layer, unsigned int &num_layers) const { - const BaseGlyphRecord* base_glyph_records = &baseGlyphRecordsZ (this); - unsigned int min = 0, max = numBaseGlyphRecords - 1; + const BaseGlyphRecord* base_glyph_records = (this+baseGlyphs).arrayZ; + unsigned int min = 0, max = numBaseGlyphs - 1; while (min <= max) { unsigned int mid = (min + max) / 2; @@ -121,19 +121,19 @@ struct COLR hb_codepoint_t &glyph_id, unsigned int &palette_index) const { - const LayerRecord* records = &layerRecordsOffsetZ (this); + const LayerRecord* records = (this+layers).arrayZ; glyph_id = records[layer].glyphid; palette_index = records[layer].colorIdx; } protected: - HBUINT16 version; /* Table version number */ - HBUINT16 numBaseGlyphRecords; /* Number of Base Glyph Records */ - LOffsetTo<BaseGlyphRecord> - baseGlyphRecordsZ; /* Offset to Base Glyph records. */ - LOffsetTo<LayerRecord> - layerRecordsOffsetZ; /* Offset to Layer Records */ - HBUINT16 numLayerRecords; /* Number of Layer Records */ + HBUINT16 version; /* Table version number */ + HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records */ + LOffsetTo<UnsizedArrayOf<BaseGlyphRecord> > + baseGlyphs; /* Offset to Base Glyph records. */ + LOffsetTo<UnsizedArrayOf<LayerRecord> > + layers; /* Offset to Layer Records */ + HBUINT16 numLayers; /* Number of Layer Records */ public: DEFINE_SIZE_STATIC (14); }; commit 150c53ee969876c2831b6165cb71655e7ce2dbdb Author: Behdad Esfahbod <[email protected]> Date: Wed Mar 14 16:08:12 2018 +0100 [color/COLR] Fix bad sanitize Bad bad bad bad code. Don't do that. If compiler's not happy, understand why. diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 01d70377..9f8b9375 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -80,8 +80,8 @@ struct COLR { TRACE_SANITIZE (this); if (!(c->check_struct (this) && - c->check_array ((const void*) &layerRecordsOffsetZ, sizeof (LayerRecord), numLayerRecords) && - c->check_array ((const void*) &baseGlyphRecordsZ, sizeof (BaseGlyphRecord), numBaseGlyphRecords))) + c->check_array (&(this+layerRecordsOffsetZ), sizeof (LayerRecord), numLayerRecords) && + c->check_array (&(this+baseGlyphRecordsZ), sizeof (BaseGlyphRecord), numBaseGlyphRecords))) return_trace (false); const BaseGlyphRecord* base_glyph_records = &baseGlyphRecordsZ (this); commit 399c800b93879186da2b7c892c7aa21468f062f2 Author: Behdad Esfahbod <[email protected]> Date: Wed Mar 14 16:03:01 2018 +0100 [color/COLR] Clean up diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index 2c3b1ccc..01d70377 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -48,8 +48,8 @@ struct LayerRecord } protected: - GlyphID gID; /* Glyph ID of layer glyph */ - HBUINT16 paletteIndex; /* Index value to use with a selected color palette */ + GlyphID glyphid; /* Glyph ID of layer glyph */ + HBUINT16 colorIdx; /* Index value to use with a selected color palette */ public: DEFINE_SIZE_STATIC (4); }; @@ -65,9 +65,9 @@ struct BaseGlyphRecord } protected: - GlyphID gID; /* Glyph ID of reference glyph */ - HBUINT16 firstLayerIndex; /* Index to the layer record */ - HBUINT16 numLayers; /* Number of color layers associated with this glyph */ + GlyphID glyphid; /* Glyph ID of reference glyph */ + HBUINT16 firstLayerIdx; /* Index to the layer record */ + HBUINT16 numLayers; /* Number of color layers associated with this glyph */ public: DEFINE_SIZE_STATIC (6); }; @@ -86,29 +86,30 @@ struct COLR const BaseGlyphRecord* base_glyph_records = &baseGlyphRecordsZ (this); for (unsigned int i = 0; i < numBaseGlyphRecords; ++i) - if (base_glyph_records[i].firstLayerIndex + + if (base_glyph_records[i].firstLayerIdx + base_glyph_records[i].numLayers > numLayerRecords) return_trace (false); return_trace (true); } - inline bool get_base_glyph_record ( - hb_codepoint_t glyph_id, unsigned int &first_layer, unsigned int &num_layers) const + inline bool get_base_glyph_record (hb_codepoint_t glyph_id, + unsigned int &first_layer, + unsigned int &num_layers) const { const BaseGlyphRecord* base_glyph_records = &baseGlyphRecordsZ (this); unsigned int min = 0, max = numBaseGlyphRecords - 1; while (min <= max) { unsigned int mid = (min + max) / 2; - hb_codepoint_t gID = base_glyph_records[mid].gID; - if (gID > glyph_id) + hb_codepoint_t glyphid = base_glyph_records[mid].glyphid; + if (glyphid > glyph_id) max = mid - 1; - else if (gID < glyph_id) + else if (glyphid < glyph_id) min = mid + 1; else { - first_layer = base_glyph_records[mid].firstLayerIndex; + first_layer = base_glyph_records[mid].firstLayerIdx; num_layers = base_glyph_records[mid].numLayers; return true; } @@ -117,11 +118,12 @@ struct COLR } inline void get_layer_record (int layer, - hb_codepoint_t &glyph_id, unsigned int &palette_index) const + hb_codepoint_t &glyph_id, + unsigned int &palette_index) const { const LayerRecord* records = &layerRecordsOffsetZ (this); - glyph_id = records[layer].gID; - palette_index = records[layer].paletteIndex; + glyph_id = records[layer].glyphid; + palette_index = records[layer].colorIdx; } protected: commit 9e337341d54c4ee12eec58e025a6831bb976d61f Author: Behdad Esfahbod <[email protected]> Date: Wed Mar 14 15:52:53 2018 +0100 [color/cbdt] Clean up diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh index e7ab917e..b4971bda 100644 --- a/src/hb-ot-color-cbdt-table.hh +++ b/src/hb-ot-color-cbdt-table.hh @@ -47,21 +47,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 +73,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 +102,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 +131,9 @@ struct IndexSubtableFormat1Or3 return true; } - IndexSubtableHeader header; - Offset<OffsetType> offsetArrayZ[VAR]; - + IndexSubtableHeader header; + Offset<OffsetType> offsetArrayZ[VAR]; + public: DEFINE_SIZE_ARRAY(8, offsetArrayZ); }; @@ -214,10 +214,10 @@ struct IndexSubtableRecord offset, length, format); } - HBUINT16 firstGlyphIndex; - HBUINT16 lastGlyphIndex; - LOffsetTo<IndexSubtable> offsetToSubtable; - + GlyphID firstGlyphIndex; + GlyphID lastGlyphIndex; + LOffsetTo<IndexSubtable> offsetToSubtable; + public: DEFINE_SIZE_STATIC(8); }; @@ -249,8 +249,7 @@ struct IndexSubtableArray } protected: - IndexSubtableRecord indexSubtablesZ[VAR]; - + IndexSubtableRecord indexSubtablesZ[VAR]; public: DEFINE_SIZE_ARRAY(0, indexSubtablesZ); }; @@ -275,19 +274,19 @@ struct BitmapSizeTable } protected: - LOffsetTo<IndexSubtableArray> indexSubtableArrayOffset; - HBUINT32 indexTablesSize; - HBUINT32 numberOfIndexSubtables; - HBUINT32 colorRef; - SBitLineMetrics horizontal; - SBitLineMetrics vertical; - HBUINT16 startGlyphIndex; - HBUINT16 endGlyphIndex; - HBUINT8 ppemX; - HBUINT8 ppemY; - HBUINT8 bitDepth; - HBINT8 flags; - + LOffsetTo<IndexSubtableArray> + 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,11 +298,10 @@ struct BitmapSizeTable struct GlyphBitmapDataFormat17 { - SmallGlyphMetrics glyphMetrics; - HBUINT32 dataLen; - HBUINT8 dataZ[VAR]; - - DEFINE_SIZE_ARRAY(9, dataZ); + SmallGlyphMetrics glyphMetrics; + ArrayOf<HBUINT8, HBUINT32> data; + public: + DEFINE_SIZE_ARRAY(9, data); }; @@ -352,7 +350,6 @@ struct CBLC protected: FixedVersion<> version; LArrayOf<BitmapSizeTable> sizeTables; - public: DEFINE_SIZE_ARRAY(8, sizeTables); }; @@ -459,9 +456,8 @@ struct CBDT protected: - FixedVersion<>version; - HBUINT8 dataZ[VAR]; - + FixedVersion<> version; + HBUINT8 dataZ[VAR]; public: DEFINE_SIZE_ARRAY(4, dataZ); }; commit 86a0ac284fc4c2ce96354bfdf32878b6db5c77bd Author: Behdad Esfahbod <[email protected]> Date: Wed Mar 14 15:51:33 2018 +0100 Revert "hb-private.hh: Add fallback implementation for round()" This reverts commit b9dcbb1f8312d8606b230f75594d40b7d4087004. This is gross. Should be only done if a specific macro is defined. Not the other way around. This fails my build as autotools companions where not added anyway. diff --git a/src/hb-private.hh b/src/hb-private.hh index 62a103cf..daa496e9 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -1070,17 +1070,4 @@ struct hb_string_t }; -/* fallback for round() */ -#if !defined (HAVE_ROUND) && !defined (HAVE_DECL_ROUND) -static inline double -round (double x) -{ - if (x >= 0) - return floor (x + 0.5); - else - return ceil (x - 0.5); -} -#endif - - #endif /* HB_PRIVATE_HH */ commit 791d80a1d42ce0bd7c5f0a3d3d10c562a6161a82 Merge: d4907e83 22de9bf5 Author: Ebrahim Byagowi <[email protected]> Date: Thu Mar 15 11:40:52 2018 +0330 Merge pull request #886 from madig/only-export-visible-symbols CMake: hide symbols by default on non-MSVC, define export attribute commit 22de9bf56d80dbf6a13a06beafd21711bdab78af Author: Nikolaus Waxweiler <[email protected]> Date: Wed Mar 14 10:29:24 2018 +0000 Enable implicit symbol hiding for all libraries, static and shared This covers all built libraries now and both static and shared builds. diff --git a/CMakeLists.txt b/CMakeLists.txt index 3de85399..b9796ebf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,7 @@ cmake_minimum_required(VERSION 2.8.0) +# Allow symbol hiding for both static and shared libs. +cmake_policy(SET CMP0063 NEW) + project(harfbuzz) enable_testing() @@ -524,23 +527,19 @@ endif () ## Define harfbuzz library add_library(harfbuzz ${project_sources} ${project_extra_sources} ${project_headers}) +set_target_properties(harfbuzz PROPERTIES + C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN TRUE) target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS}) -if (BUILD_SHARED_LIBS) - if (WIN32 AND NOT MINGW) - add_definitions("-DHB_EXTERN=__declspec(dllexport) extern") - else () - add_definitions("-DHB_EXTERN=__attribute__(( visibility( \"default\" ) )) extern") - set_target_properties(harfbuzz PROPERTIES - C_VISIBILITY_PRESET hidden - CXX_VISIBILITY_PRESET hidden - VISIBILITY_INLINES_HIDDEN TRUE) - endif () -endif () - ## Define harfbuzz-subset library add_library(harfbuzz-subset ${subset_project_sources} ${subset_project_headers}) add_dependencies(harfbuzz-subset harfbuzz) +set_target_properties(harfbuzz-subset PROPERTIES + C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN TRUE) target_link_libraries(harfbuzz-subset harfbuzz ${THIRD_PARTY_LIBS}) if (UNIX OR MINGW) @@ -568,11 +567,23 @@ if (HB_HAVE_GOBJECT) ${hb_gobject_headers} ${hb_gobject_gen_headers} ) + set_target_properties(harfbuzz-gobject PROPERTIES + C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN TRUE) include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}/src) add_dependencies(harfbuzz-gobject harfbuzz) target_link_libraries(harfbuzz-gobject harfbuzz ${GOBJECT_LIBRARIES} ${THIRD_PARTY_LIBS}) endif () +if (BUILD_SHARED_LIBS) + if (WIN32 AND NOT MINGW) + add_definitions("-DHB_EXTERN=__declspec(dllexport) extern") + else () + add_definitions("-DHB_EXTERN=__attribute__(( visibility( \"default\" ) )) extern") + endif () +endif () + # On Windows, g-ir-scanner requires a DLL build in order for it to work if (WIN32) if (NOT BUILD_SHARED_LIBS) commit ce975dce7ae8950b6e7b9a2d0c00ead9d45f73ff Author: Nikolaus Waxweiler <[email protected]> Date: Wed Mar 14 00:50:32 2018 +0000 CMake: hide symbols by default on non-MSVC, define export attribute This change makes sure that non-MSVC builds using CMake properly hide non-exported functions. diff --git a/CMakeLists.txt b/CMakeLists.txt index 53e89740..3de85399 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,14 +131,6 @@ if (MSVC) add_definitions(-wd4244 -wd4267 -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS) endif () -if (BUILD_SHARED_LIBS) - if (WIN32 AND NOT MINGW) - add_definitions("-DHB_EXTERN=__declspec(dllexport) extern") - else () - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden") - endif () -endif () - ## Detect if we are running inside a distribution or regular repository folder # if (EXISTS "${PROJECT_SOURCE_DIR}/ChangeLog") @@ -534,6 +526,18 @@ endif () add_library(harfbuzz ${project_sources} ${project_extra_sources} ${project_headers}) target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS}) +if (BUILD_SHARED_LIBS) + if (WIN32 AND NOT MINGW) + add_definitions("-DHB_EXTERN=__declspec(dllexport) extern") + else () + add_definitions("-DHB_EXTERN=__attribute__(( visibility( \"default\" ) )) extern") + set_target_properties(harfbuzz PROPERTIES + C_VISIBILITY_PRESET hidden + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN TRUE) + endif () +endif () + ## Define harfbuzz-subset library add_library(harfbuzz-subset ${subset_project_sources} ${subset_project_headers}) add_dependencies(harfbuzz-subset harfbuzz) _______________________________________________ HarfBuzz mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/harfbuzz
