diff --git a/AUTHORS b/AUTHORS index 81cdc4cf3..0763761bb 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,9 +1,11 @@ Behdad Esfahbod -Simon Hausmann -Martin Hosken -Jonathan Kew -Lars Knoll -Werner Lemberg -Roozbeh Pournader -Owen Taylor David Turner +Ebrahim Byagowi +Jonathan Kew +Khaled Hosny +Lars Knoll +Martin Hosken +Owen Taylor +Roozbeh Pournader +Simon Hausmann +Werner Lemberg diff --git a/NEWS b/NEWS index c9af0f368..58e21a592 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,71 @@ +Overview of changes leading to 2.0.0 +Wednesday, October 17, 2018 +==================================== +- Added AAT shaping support (morx/kerx/trak). + Automatically used if GSUB/GPOS are not available respectively. + Set HB_OPTIONS=aat env var to have morx/kerx preferred over + GSUB/GPOS. +- Apply TrueType kern table internally, instead of relying on + hb_font_t callbacks. +- Khmer shaper significantly rewritten to better match Uniscribe. +- Indic3 tags ('dev3', etc) are passed to USE shaper. +- .dfont Mac font containers implemented. +- Script- and language-mapping revamped to better use BCP 47. +- Misc USE and Indic fixes. +- Misc everything fixes. +- Too many things to list. Biggest release since 0.9.1, with + over 500 commits in just over 5 weeks! Didn't intend it to + be a big release. Just happened to become. +- hb-ft now locks underlying FT_Face during use. + +API changes: + +- Newly-created hb_font_t's now have our internal "hb-ot-font" + callbacks set on them, so they should work out of the box + without any callbacks set. If callbacks are set, everything + is back to what it was before, the fallback callbacks are + null. If you to get the internal implementation modified, + sub_font it. + +- New hb_font_funcs_set_nominal_glyphs_func() allows speeding + up character to glyph mapping. + +New API: ++HB_FEATURE_GLOBAL_START ++HB_FEATURE_GLOBAL_END ++hb_buffer_set_invisible_glyph() ++hb_buffer_get_invisible_glyph() ++hb_font_funcs_set_nominal_glyphs_func() ++hb_ot_layout_table_select_script() ++hb_ot_layout_script_select_language() ++hb_ot_layout_feature_get_name_ids() ++hb_ot_layout_feature_get_characters() ++hb_name_id_t ++HB_NAME_ID_INVALID ++HB_OT_MAX_TAGS_PER_SCRIPT ++hb_ot_tags_from_script_and_language() ++hb_ot_tags_to_script_and_language() + +Deprecated API: +-hb_font_funcs_set_glyph_func() +-hb_unicode_eastasian_width_func_t +-hb_unicode_funcs_set_eastasian_width_func() +-hb_unicode_eastasian_width() +-hb_unicode_decompose_compatibility_func_t +-HB_UNICODE_MAX_DECOMPOSITION_LEN +-hb_unicode_funcs_set_decompose_compatibility_func() +-hb_unicode_decompose_compatibility() +-hb_font_funcs_set_glyph_h_kerning_func() +-hb_font_funcs_set_glyph_v_kerning_func() +-hb_font_get_glyph_h_kerning() +-hb_font_get_glyph_v_kerning() +-hb_font_get_glyph_kerning_for_direction() +-hb_ot_layout_table_choose_script() +-hb_ot_layout_script_find_language() +-hb_ot_tags_from_script() +-hb_ot_tag_from_language() + + Overview of changes leading to 1.9.0 Monday, September 10, 2018 ==================================== diff --git a/configure.ac b/configure.ac index 1b9ddfe7c..a3ce8c1e8 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.64]) AC_INIT([HarfBuzz], - [1.9.0], + [2.0.0], [https://github.com/harfbuzz/harfbuzz/issues/new], [harfbuzz], [http://harfbuzz.org/]) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 37f6d03cf..89ed91f28 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -291,10 +291,27 @@ struct Lookup LookupFormat8 format8; } u; public: - DEFINE_SIZE_MIN (0); /* 0 min size, makes sure this cannot be used on null pool, - * because Format0 has unbounded size depending on num_glyphs. - * We cannot define custom null bytes for a template :(. */ + DEFINE_SIZE_UNION (2, format); }; +/* Lookup 0 has unbounded size (dependant on num_glyphs). So we need to defined + * special NULL objects for Lookup<> objects, but since it's template our macros + * don't work. So we have to hand-code them here. UGLY. */ +} /* Close namespace. */ +/* Ugly hand-coded null objects for template Lookup<> :(. */ +extern HB_INTERNAL const unsigned char _hb_Null_AAT_Lookup[2]; +template <> +/*static*/ inline const AAT::Lookup& Null > (void) { + return *reinterpret_cast *> (_hb_Null_AAT_Lookup); +} +template <> +/*static*/ inline const AAT::Lookup& Null > (void) { + return *reinterpret_cast *> (_hb_Null_AAT_Lookup); +} +template <> +/*static*/ inline const AAT::Lookup >& Null > > (void) { + return *reinterpret_cast > *> (_hb_Null_AAT_Lookup); +} +namespace AAT { /* @@ -405,6 +422,8 @@ struct StateTable num_states, num_classes * states[0].static_size))) return_trace (false); + if ((c->max_ops -= num_states - state) < 0) + return_trace (false); { /* Sweep new states. */ const HBUINT16 *stop = &states[num_states * num_classes]; for (const HBUINT16 *p = &states[state * num_classes]; p < stop; p++) @@ -414,6 +433,8 @@ struct StateTable if (unlikely (!c->check_array (entries, num_entries))) return_trace (false); + if ((c->max_ops -= num_entries - entry) < 0) + return_trace (false); { /* Sweep new entries. */ const Entry *stop = &entries[num_entries]; for (const Entry *p = &entries[entry]; p < stop; p++) diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh index e02721750..4b4bc2ffe 100644 --- a/src/hb-aat-layout-trak-table.hh +++ b/src/hb-aat-layout-trak-table.hh @@ -93,12 +93,11 @@ struct TrackData float s0 = size_table[idx].to_float (); float s1 = size_table[idx + 1].to_float (); float t = unlikely (s0 == s1) ? 0.f : (target_size - s0) / (s1 - s0); - return (float) t * trackTableEntry.get_value (base, idx + 1, sizes) + - ((float) 1.0 - t) * trackTableEntry.get_value (base, idx, sizes); - return 0; + return t * trackTableEntry.get_value (base, idx + 1, sizes) + + (1.f - t) * trackTableEntry.get_value (base, idx, sizes); } - inline float get_tracking (const void *base, float ptem) const + inline int get_tracking (const void *base, float ptem) const { /* CoreText points are CSS pixels (96 per inch), * NOT typographic points (72 per inch). @@ -121,7 +120,7 @@ struct TrackData if (trackTable[i].get_track_value () == 0.f) { - trackTableEntry = &trackTable[0]; + trackTableEntry = &trackTable[i]; break; } } @@ -141,8 +140,8 @@ struct TrackData if (size_table[size_index].to_float () >= csspx) break; - return interpolate_at (size_index ? size_index - 1 : 0, csspx, - *trackTableEntry, base); + return round (interpolate_at (size_index ? size_index - 1 : 0, csspx, + *trackTableEntry, base)); } inline bool sanitize (hb_sanitize_context_t *c, const void *base) const @@ -193,7 +192,7 @@ struct trak if (HB_DIRECTION_IS_HORIZONTAL (buffer->props.direction)) { const TrackData &trackData = this+horizData; - float tracking = trackData.get_tracking (this, ptem); + int tracking = trackData.get_tracking (this, ptem); hb_position_t offset_to_add = c->font->em_scalef_x (tracking / 2); hb_position_t advance_to_add = c->font->em_scalef_x (tracking); foreach_grapheme (buffer, start, end) @@ -205,7 +204,7 @@ struct trak else { const TrackData &trackData = this+vertData; - float tracking = trackData.get_tracking (this, ptem); + int tracking = trackData.get_tracking (this, ptem); hb_position_t offset_to_add = c->font->em_scalef_y (tracking / 2); hb_position_t advance_to_add = c->font->em_scalef_y (tracking); foreach_grapheme (buffer, start, end) diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc index 00e7e149c..ce9b0530c 100644 --- a/src/hb-buffer.cc +++ b/src/hb-buffer.cc @@ -1190,7 +1190,7 @@ hb_buffer_get_replacement_codepoint (hb_buffer_t *buffer) * U+0020 SPACE character is used. Otherwise, this value is used * verbatim. * - * Since: REPLACEME + * Since: 2.0.0 **/ void hb_buffer_set_invisible_glyph (hb_buffer_t *buffer, @@ -1211,7 +1211,7 @@ hb_buffer_set_invisible_glyph (hb_buffer_t *buffer, * Return value: * The @buffer invisible #hb_codepoint_t. * - * Since: REPLACEME + * Since: 2.0.0 **/ hb_codepoint_t hb_buffer_get_invisible_glyph (hb_buffer_t *buffer) diff --git a/src/hb-common.h b/src/hb-common.h index c601b1f66..2f09f4318 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -401,13 +401,13 @@ typedef void (*hb_destroy_func_t) (void *user_data); /** * HB_FEATURE_GLOBAL_START * - * Since: REPLACEME + * Since: 2.0.0 */ #define HB_FEATURE_GLOBAL_START 0 /** * HB_FEATURE_GLOBAL_END * - * Since: REPLACEME + * Since: 2.0.0 */ #define HB_FEATURE_GLOBAL_END ((unsigned int) -1) diff --git a/src/hb-deprecated.h b/src/hb-deprecated.h index 52ee49e2b..5af9bdbd8 100644 --- a/src/hb-deprecated.h +++ b/src/hb-deprecated.h @@ -61,7 +61,7 @@ hb_set_invert (hb_set_t *set); /** * hb_unicode_eastasian_width_func_t: * - * Deprecated: REPLACEME + * Deprecated: 2.0.0 */ typedef unsigned int (*hb_unicode_eastasian_width_func_t) (hb_unicode_funcs_t *ufuncs, hb_codepoint_t unicode, @@ -77,7 +77,7 @@ typedef unsigned int (*hb_unicode_eastasian_width_func_t) (hb_unicode_funcs_t * * * Since: 0.9.2 - * Deprecated: REPLACEME + * Deprecated: 2.0.0 **/ HB_EXTERN HB_DEPRECATED void hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs, @@ -88,7 +88,7 @@ hb_unicode_funcs_set_eastasian_width_func (hb_unicode_funcs_t *ufuncs, * hb_unicode_eastasian_width: * * Since: 0.9.2 - * Deprecated: REPLACEME + * Deprecated: 2.0.0 **/ HB_EXTERN HB_DEPRECATED unsigned int hb_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs, @@ -113,7 +113,7 @@ hb_unicode_eastasian_width (hb_unicode_funcs_t *ufuncs, * * Return value: number of codepoints in the full compatibility decomposition of @u, or 0 if no decomposition available. * - * Deprecated: REPLACEME + * Deprecated: 2.0.0 */ typedef unsigned int (*hb_unicode_decompose_compatibility_func_t) (hb_unicode_funcs_t *ufuncs, hb_codepoint_t u, @@ -125,7 +125,7 @@ typedef unsigned int (*hb_unicode_decompose_compatibility_func_t) (hb_unicode_ * * See Unicode 6.1 for details on the maximum decomposition length. * - * Deprecated: REPLACEME + * Deprecated: 2.0.0 */ #define HB_UNICODE_MAX_DECOMPOSITION_LEN (18+1) /* codepoints */ @@ -139,7 +139,7 @@ typedef unsigned int (*hb_unicode_decompose_compatibility_func_t) (hb_unicode_ * * * Since: 0.9.2 - * Deprecated: REPLACEME + * Deprecated: 2.0.0 **/ HB_EXTERN HB_DEPRECATED void hb_unicode_funcs_set_decompose_compatibility_func (hb_unicode_funcs_t *ufuncs, @@ -150,7 +150,7 @@ hb_unicode_funcs_set_decompose_compatibility_func (hb_unicode_funcs_t *ufuncs, * hb_unicode_decompose_compatibility: * * - * Deprecated: REPLACEME + * Deprecated: 2.0.0 **/ HB_EXTERN HB_DEPRECATED unsigned int hb_unicode_decompose_compatibility (hb_unicode_funcs_t *ufuncs, @@ -174,7 +174,7 @@ typedef hb_font_get_glyph_kerning_func_t hb_font_get_glyph_v_kerning_func_t; * * * Since: 0.9.2 - * Deprecated: REPLACEME + * Deprecated: 2.0.0 **/ HB_EXTERN void hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs, @@ -191,7 +191,7 @@ hb_font_funcs_set_glyph_h_kerning_func (hb_font_funcs_t *ffuncs, * * * Since: 0.9.2 - * Deprecated: REPLACEME + * Deprecated: 2.0.0 **/ HB_EXTERN void hb_font_funcs_set_glyph_v_kerning_func (hb_font_funcs_t *ffuncs, diff --git a/src/hb-font.cc b/src/hb-font.cc index c9656cee7..7a430237c 100644 --- a/src/hb-font.cc +++ b/src/hb-font.cc @@ -922,7 +922,7 @@ hb_font_get_glyph_v_origin (hb_font_t *font, * Return value: * * Since: 0.9.2 - * Deprecated: REPLACEME + * Deprecated: 2.0.0 **/ hb_position_t hb_font_get_glyph_h_kerning (hb_font_t *font, @@ -942,7 +942,7 @@ hb_font_get_glyph_h_kerning (hb_font_t *font, * Return value: * * Since: 0.9.2 - * Deprecated: REPLACEME + * Deprecated: 2.0.0 **/ hb_position_t hb_font_get_glyph_v_kerning (hb_font_t *font, @@ -1171,7 +1171,7 @@ hb_font_subtract_glyph_origin_for_direction (hb_font_t *font, * * * Since: 0.9.2 - * Deprecated: REPLACEME + * Deprecated: 2.0.0 **/ void hb_font_get_glyph_kerning_for_direction (hb_font_t *font, diff --git a/src/hb-font.h b/src/hb-font.h index dc88f26c3..74c61aba4 100644 --- a/src/hb-font.h +++ b/src/hb-font.h @@ -237,7 +237,7 @@ hb_font_funcs_set_nominal_glyph_func (hb_font_funcs_t *ffuncs, * * * - * Since: REPLACEME + * Since: 2.0.0 **/ HB_EXTERN void hb_font_funcs_set_nominal_glyphs_func (hb_font_funcs_t *ffuncs, diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index a6ff6e7b9..d836a94d6 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -227,7 +227,8 @@ struct hb_sanitize_context_t : inline hb_sanitize_context_t (void) : debug_depth (0), start (nullptr), end (nullptr), - writable (false), edit_count (0), max_ops (0), + max_ops (0), + writable (false), edit_count (0), blob (nullptr), num_glyphs (65536), num_glyphs_set (false) {} @@ -443,10 +444,10 @@ struct hb_sanitize_context_t : mutable unsigned int debug_depth; const char *start, *end; + mutable int max_ops; private: bool writable; unsigned int edit_count; - mutable int max_ops; hb_blob_t *blob; unsigned int num_glyphs; bool num_glyphs_set; diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index af38dcb02..fb1d9b11f 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -376,7 +376,7 @@ hb_ot_layout_table_choose_script (hb_face_t *face, /** * hb_ot_layout_table_select_script: * - * Since: REPLACEME + * Since: 2.0.0 **/ hb_bool_t hb_ot_layout_table_select_script (hb_face_t *face, @@ -489,7 +489,7 @@ hb_ot_layout_script_find_language (hb_face_t *face, /** * hb_ot_layout_script_select_language: * - * Since: REPLACEME + * Since: 2.0.0 **/ hb_bool_t hb_ot_layout_script_select_language (hb_face_t *face, @@ -1134,7 +1134,7 @@ hb_ot_layout_get_size_params (hb_face_t *face, * * Return value: true if data found, false otherwise * - * Since: REPLACEME + * Since: 2.0.0 **/ hb_bool_t hb_ot_layout_feature_get_name_ids (hb_face_t *face, @@ -1207,7 +1207,7 @@ hb_ot_layout_feature_get_name_ids (hb_face_t *face, * * Return value: Number of total sample characters in the cvXX feature. * - * Since: REPLACEME + * Since: 2.0.0 **/ unsigned int hb_ot_layout_feature_get_characters (hb_face_t *face, diff --git a/src/hb-ot-name.h b/src/hb-ot-name.h index 0fdd63bbd..49423e87c 100644 --- a/src/hb-ot-name.h +++ b/src/hb-ot-name.h @@ -37,14 +37,14 @@ HB_BEGIN_DECLS /** * hb_name_id_t: * - * Since: REPLACEME + * Since: 2.0.0 */ typedef unsigned int hb_name_id_t; /** * HB_NAME_ID_INVALID * - * Since: REPLACEME + * Since: 2.0.0 **/ #define HB_NAME_ID_INVALID 0xFFFF diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc index 0fbc05d8d..b56443910 100644 --- a/src/hb-ot-shape-complex-arabic.cc +++ b/src/hb-ot-shape-complex-arabic.cc @@ -458,9 +458,9 @@ apply_stch (const hb_ot_shape_plan_t *plan, int sign = font->x_scale < 0 ? -1 : +1; unsigned int extra_glyphs_needed = 0; // Set during MEASURE, used during CUT - typedef enum { MEASURE, CUT } step_t; + enum { MEASURE, CUT } /* step_t */; - for (step_t step = MEASURE; step <= CUT; step = (step_t) (step + 1)) + for (unsigned int step = MEASURE; step <= CUT; step = step + 1) { unsigned int count = buffer->len; hb_glyph_info_t *info = buffer->info; diff --git a/src/hb-ot-shape-complex-myanmar.hh b/src/hb-ot-shape-complex-myanmar.hh index 7b6fd4837..3e9537a64 100644 --- a/src/hb-ot-shape-complex-myanmar.hh +++ b/src/hb-ot-shape-complex-myanmar.hh @@ -64,42 +64,42 @@ set_myanmar_properties (hb_glyph_info_t &info) { hb_codepoint_t u = info.codepoint; unsigned int type = hb_indic_get_categories (u); - indic_category_t cat = (indic_category_t) (type & 0x7Fu); + unsigned int cat = type & 0x7Fu; indic_position_t pos = (indic_position_t) (type >> 8); /* Myanmar * https://docs.microsoft.com/en-us/typography/script-development/myanmar#analyze */ if (unlikely (hb_in_range (u, 0xFE00u, 0xFE0Fu))) - cat = (indic_category_t) OT_VS; + cat = OT_VS; switch (u) { case 0x104Eu: - cat = (indic_category_t) OT_C; /* The spec says C, IndicSyllableCategory doesn't have. */ + cat = OT_C; /* The spec says C, IndicSyllableCategory doesn't have. */ break; case 0x002Du: case 0x00A0u: case 0x00D7u: case 0x2012u: case 0x2013u: case 0x2014u: case 0x2015u: case 0x2022u: case 0x25CCu: case 0x25FBu: case 0x25FCu: case 0x25FDu: case 0x25FEu: - cat = (indic_category_t) OT_GB; + cat = OT_GB; break; case 0x1004u: case 0x101Bu: case 0x105Au: - cat = (indic_category_t) OT_Ra; + cat = OT_Ra; break; case 0x1032u: case 0x1036u: - cat = (indic_category_t) OT_A; + cat = OT_A; break; case 0x1039u: - cat = (indic_category_t) OT_H; + cat = OT_H; break; case 0x103Au: - cat = (indic_category_t) OT_As; + cat = OT_As; break; case 0x1041u: case 0x1042u: case 0x1043u: case 0x1044u: @@ -107,47 +107,47 @@ set_myanmar_properties (hb_glyph_info_t &info) case 0x1049u: case 0x1090u: case 0x1091u: case 0x1092u: case 0x1093u: case 0x1094u: case 0x1095u: case 0x1096u: case 0x1097u: case 0x1098u: case 0x1099u: - cat = (indic_category_t) OT_D; + cat = OT_D; break; case 0x1040u: - cat = (indic_category_t) OT_D; /* XXX The spec says D0, but Uniscribe doesn't seem to do. */ + cat = OT_D; /* XXX The spec says D0, but Uniscribe doesn't seem to do. */ break; case 0x103Eu: case 0x1060u: - cat = (indic_category_t) OT_MH; + cat = OT_MH; break; case 0x103Cu: - cat = (indic_category_t) OT_MR; + cat = OT_MR; break; case 0x103Du: case 0x1082u: - cat = (indic_category_t) OT_MW; + cat = OT_MW; break; case 0x103Bu: case 0x105Eu: case 0x105Fu: - cat = (indic_category_t) OT_MY; + cat = OT_MY; break; case 0x1063u: case 0x1064u: case 0x1069u: case 0x106Au: case 0x106Bu: case 0x106Cu: case 0x106Du: case 0xAA7Bu: - cat = (indic_category_t) OT_PT; + cat = OT_PT; break; case 0x1038u: case 0x1087u: case 0x1088u: case 0x1089u: case 0x108Au: case 0x108Bu: case 0x108Cu: case 0x108Du: case 0x108Fu: case 0x109Au: case 0x109Bu: case 0x109Cu: - cat = (indic_category_t) OT_SM; + cat = OT_SM; break; case 0x104Au: case 0x104Bu: - cat = (indic_category_t) OT_P; + cat = OT_P; break; case 0xAA74u: case 0xAA75u: case 0xAA76u: /* https://github.com/roozbehp/unicode-data/issues/3 */ - cat = (indic_category_t) OT_C; + cat = OT_C; break; } @@ -155,15 +155,15 @@ set_myanmar_properties (hb_glyph_info_t &info) { switch ((int) pos) { - case POS_PRE_C: cat = (indic_category_t) OT_VPre; - pos = POS_PRE_M; break; - case POS_ABOVE_C: cat = (indic_category_t) OT_VAbv; break; - case POS_BELOW_C: cat = (indic_category_t) OT_VBlw; break; - case POS_POST_C: cat = (indic_category_t) OT_VPst; break; + case POS_PRE_C: cat = OT_VPre; + pos = POS_PRE_M; break; + case POS_ABOVE_C: cat = OT_VAbv; break; + case POS_BELOW_C: cat = OT_VBlw; break; + case POS_POST_C: cat = OT_VPst; break; } } - info.myanmar_category() = (myanmar_category_t) cat; + info.myanmar_category() = cat; info.myanmar_position() = pos; } diff --git a/src/hb-ot-tag.cc b/src/hb-ot-tag.cc index 7bcc63abc..3d4e8b066 100644 --- a/src/hb-ot-tag.cc +++ b/src/hb-ot-tag.cc @@ -336,7 +336,7 @@ parse_private_use_subtag (const char *private_use_subtag, * * Converts an #hb_script_t and an #hb_language_t to script and language tags. * - * Since: REPLACEME + * Since: 2.0.0 **/ void hb_ot_tags_from_script_and_language (hb_script_t script, @@ -448,7 +448,7 @@ hb_ot_tag_to_language (hb_tag_t tag) * Converts a script tag and a language tag to an #hb_script_t and an * #hb_language_t. * - * Since: REPLACEME + * Since: 2.0.0 **/ void hb_ot_tags_to_script_and_language (hb_tag_t script_tag, diff --git a/src/hb-ot-tag.h b/src/hb-ot-tag.h index f7a061c70..33a4dbdbc 100644 --- a/src/hb-ot-tag.h +++ b/src/hb-ot-tag.h @@ -42,13 +42,13 @@ HB_BEGIN_DECLS /** * HB_OT_MAX_TAGS_PER_SCRIPT: * - * Since: REPLACEME + * Since: 2.0.0 **/ #define HB_OT_MAX_TAGS_PER_SCRIPT 3u /** * HB_OT_MAX_TAGS_PER_LANGUAGE: * - * Since: REPLACEME + * Since: 2.0.0 **/ #define HB_OT_MAX_TAGS_PER_LANGUAGE 3u diff --git a/src/hb-static.cc b/src/hb-static.cc index 5112d77be..e5507960d 100644 --- a/src/hb-static.cc +++ b/src/hb-static.cc @@ -28,6 +28,8 @@ #include "hb-open-type.hh" #include "hb-ot-layout-common.hh" +#include "hb-aat-layout-ankr-table.hh" /* I don't even want to know why... */ +#include "hb-aat-layout-common.hh" #include "hb-face.hh" #include "hb-ot-head-table.hh" @@ -41,6 +43,8 @@ hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_ DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF}; DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00}; DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00}; +/* Hand-coded because Lookup is a template. Sad. */ +const unsigned char _hb_Null_AAT_Lookup[2] = {0xFF, 0xFF}; void diff --git a/src/hb-version.h b/src/hb-version.h index 346495104..d10a168a6 100644 --- a/src/hb-version.h +++ b/src/hb-version.h @@ -36,11 +36,11 @@ HB_BEGIN_DECLS -#define HB_VERSION_MAJOR 1 -#define HB_VERSION_MINOR 9 +#define HB_VERSION_MAJOR 2 +#define HB_VERSION_MINOR 0 #define HB_VERSION_MICRO 0 -#define HB_VERSION_STRING "1.9.0" +#define HB_VERSION_STRING "2.0.0" #define HB_VERSION_ATLEAST(major,minor,micro) \ ((major)*10000+(minor)*100+(micro) <= \ diff --git a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5521982557782016 b/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5521982557782016 deleted file mode 100644 index 55541f749..000000000 Binary files a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5521982557782016 and /dev/null differ diff --git a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5609911946838016 b/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5609911946838016 deleted file mode 100644 index 8c647a8a4..000000000 Binary files a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5609911946838016 and /dev/null differ diff --git a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5670861909524480 b/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5670861909524480 deleted file mode 100644 index 49bcb3098..000000000 Binary files a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5670861909524480 and /dev/null differ diff --git a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5750092395970560 b/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5750092395970560 deleted file mode 100644 index d622c2563..000000000 Binary files a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5750092395970560 and /dev/null differ diff --git a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-6651660668502016 b/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-6651660668502016 deleted file mode 100644 index 6206f0776..000000000 Binary files a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-6651660668502016 and /dev/null differ diff --git a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-get-codepoints-fuzzer-5973295416475648 b/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-get-codepoints-fuzzer-5973295416475648 deleted file mode 100644 index b506d2a5a..000000000 Binary files a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-get-codepoints-fuzzer-5973295416475648 and /dev/null differ diff --git a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-get-codepoints-fuzzer-6136125075750912 b/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-get-codepoints-fuzzer-6136125075750912 deleted file mode 100644 index ffcea6460..000000000 Binary files a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-get-codepoints-fuzzer-6136125075750912 and /dev/null differ diff --git a/test/api/test-ot-tag.c b/test/api/test-ot-tag.c index 993836e2d..f89c25deb 100644 --- a/test/api/test-ot-tag.c +++ b/test/api/test-ot-tag.c @@ -464,8 +464,8 @@ test_tags (hb_script_t script, unsigned int i; hb_tag_t *script_tags = malloc (script_count * sizeof (hb_tag_t)); hb_tag_t *language_tags = malloc (language_count * sizeof (hb_tag_t)); - g_assert_nonnull (script_tags); - g_assert_nonnull (language_tags); + g_assert (script_tags); + g_assert (language_tags); hb_language_t lang = hb_language_from_string (lang_s, -1); va_start (expected_tags, expected_language_count); diff --git a/test/api/test-subset-glyf.c b/test/api/test-subset-glyf.c index af9439c0f..05c7f8cfe 100644 --- a/test/api/test-subset-glyf.c +++ b/test/api/test-subset-glyf.c @@ -228,7 +228,7 @@ test_subset_glyf_strip_hints_composite (void) static void test_subset_glyf_strip_hints_invalid (void) { - hb_face_t *face = hb_subset_test_open_font ("fonts/oom-ccc61c92d589f895174cdef6ff2e3b20e9999a1a"); + hb_face_t *face = hb_subset_test_open_font ("../fuzzing/fonts/oom-ccc61c92d589f895174cdef6ff2e3b20e9999a1a"); hb_set_t *codepoints = hb_set_create(); const hb_codepoint_t text[] = diff --git a/test/api/test-subset-hdmx.c b/test/api/test-subset-hdmx.c index ddcdedce3..8496f9e8f 100644 --- a/test/api/test-subset-hdmx.c +++ b/test/api/test-subset-hdmx.c @@ -72,7 +72,7 @@ test_subset_hdmx_multiple_device_records (void) static void test_subset_hdmx_invalid (void) { - hb_face_t *face = hb_subset_test_open_font("fonts/crash-ccc61c92d589f895174cdef6ff2e3b20e9999a1a"); + hb_face_t *face = hb_subset_test_open_font("../fuzzing/fonts/crash-ccc61c92d589f895174cdef6ff2e3b20e9999a1a"); hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_set_t *codepoints = hb_subset_input_unicode_set (input); @@ -94,7 +94,7 @@ test_subset_hdmx_invalid (void) static void test_subset_hdmx_fails_sanitize (void) { - hb_face_t *face = hb_subset_test_open_font("fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5609911946838016"); + hb_face_t *face = hb_subset_test_open_font("../fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5609911946838016"); hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_set_t *codepoints = hb_subset_input_unicode_set (input); diff --git a/test/api/test-subset-hmtx.c b/test/api/test-subset-hmtx.c index 551e50672..1a5a44dc5 100644 --- a/test/api/test-subset-hmtx.c +++ b/test/api/test-subset-hmtx.c @@ -153,7 +153,7 @@ test_subset_hmtx_noop (void) static void test_subset_invalid_hmtx (void) { - hb_face_t *face = hb_subset_test_open_font("fonts/crash-e4e0bb1458a91b692eba492c907ae1f94e635480"); + hb_face_t *face = hb_subset_test_open_font("../fuzzing/fonts/crash-e4e0bb1458a91b692eba492c907ae1f94e635480"); hb_face_t *subset; hb_subset_input_t *input = hb_subset_input_create_or_fail (); diff --git a/test/api/test-subset.c b/test/api/test-subset.c index 2fc885a6d..aaed03176 100644 --- a/test/api/test-subset.c +++ b/test/api/test-subset.c @@ -32,7 +32,7 @@ static void test_subset_32_tables (void) { - hb_face_t *face = hb_subset_test_open_font("fonts/oom-6ef8c96d3710262511bcc730dce9c00e722cb653"); + hb_face_t *face = hb_subset_test_open_font("../fuzzing/fonts/oom-6ef8c96d3710262511bcc730dce9c00e722cb653"); hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_set_t *codepoints = hb_subset_input_unicode_set (input); @@ -54,7 +54,7 @@ test_subset_32_tables (void) static void test_subset_no_inf_loop (void) { - hb_face_t *face = hb_subset_test_open_font("fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5521982557782016"); + hb_face_t *face = hb_subset_test_open_font("../fuzzing/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5521982557782016"); hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_set_t *codepoints = hb_subset_input_unicode_set (input); @@ -76,7 +76,7 @@ test_subset_no_inf_loop (void) static void test_subset_crash (void) { - hb_face_t *face = hb_subset_test_open_font("fonts/crash-4b60576767ee4d9fe1cc10959d89baf73d4e8249"); + hb_face_t *face = hb_subset_test_open_font("../fuzzing/fonts/crash-4b60576767ee4d9fe1cc10959d89baf73d4e8249"); hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_set_t *codepoints = hb_subset_input_unicode_set (input); diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-hb-shape-fuzzer-5634395566768128 b/test/fuzzing/fonts/clusterfuzz-testcase-hb-shape-fuzzer-5634395566768128 new file mode 100644 index 000000000..cd1a2934f Binary files /dev/null and b/test/fuzzing/fonts/clusterfuzz-testcase-hb-shape-fuzzer-5634395566768128 differ diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5718464350650368 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5718464350650368 new file mode 100644 index 000000000..d511e9d10 Binary files /dev/null and b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5718464350650368 differ diff --git a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5542653037903872 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5738888765636608 similarity index 56% rename from test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5542653037903872 rename to test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5738888765636608 index 6307ddd4b..28e72df7d 100644 Binary files a/test/api/fonts/clusterfuzz-testcase-minimized-hb-subset-fuzzer-5542653037903872 and b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5738888765636608 differ diff --git a/test/api/fonts/crash-4b60576767ee4d9fe1cc10959d89baf73d4e8249 b/test/fuzzing/fonts/crash-4b60576767ee4d9fe1cc10959d89baf73d4e8249 similarity index 100% rename from test/api/fonts/crash-4b60576767ee4d9fe1cc10959d89baf73d4e8249 rename to test/fuzzing/fonts/crash-4b60576767ee4d9fe1cc10959d89baf73d4e8249 diff --git a/test/api/fonts/crash-b577db318b30f2851828a4c9ef97cb30678b1b54 b/test/fuzzing/fonts/crash-b577db318b30f2851828a4c9ef97cb30678b1b54 similarity index 100% rename from test/api/fonts/crash-b577db318b30f2851828a4c9ef97cb30678b1b54 rename to test/fuzzing/fonts/crash-b577db318b30f2851828a4c9ef97cb30678b1b54 diff --git a/test/api/fonts/crash-ccc61c92d589f895174cdef6ff2e3b20e9999a1a b/test/fuzzing/fonts/crash-ccc61c92d589f895174cdef6ff2e3b20e9999a1a similarity index 100% rename from test/api/fonts/crash-ccc61c92d589f895174cdef6ff2e3b20e9999a1a rename to test/fuzzing/fonts/crash-ccc61c92d589f895174cdef6ff2e3b20e9999a1a diff --git a/test/api/fonts/crash-e4e0bb1458a91b692eba492c907ae1f94e635480 b/test/fuzzing/fonts/crash-e4e0bb1458a91b692eba492c907ae1f94e635480 similarity index 100% rename from test/api/fonts/crash-e4e0bb1458a91b692eba492c907ae1f94e635480 rename to test/fuzzing/fonts/crash-e4e0bb1458a91b692eba492c907ae1f94e635480 diff --git a/test/api/fonts/oom-6ef8c96d3710262511bcc730dce9c00e722cb653 b/test/fuzzing/fonts/oom-6ef8c96d3710262511bcc730dce9c00e722cb653 similarity index 100% rename from test/api/fonts/oom-6ef8c96d3710262511bcc730dce9c00e722cb653 rename to test/fuzzing/fonts/oom-6ef8c96d3710262511bcc730dce9c00e722cb653 diff --git a/test/api/fonts/oom-ccc61c92d589f895174cdef6ff2e3b20e9999a1a b/test/fuzzing/fonts/oom-ccc61c92d589f895174cdef6ff2e3b20e9999a1a similarity index 100% rename from test/api/fonts/oom-ccc61c92d589f895174cdef6ff2e3b20e9999a1a rename to test/fuzzing/fonts/oom-ccc61c92d589f895174cdef6ff2e3b20e9999a1a diff --git a/test/fuzzing/run-shape-fuzzer-tests.py b/test/fuzzing/run-shape-fuzzer-tests.py index 074ecc8ea..8fadd167f 100755 --- a/test/fuzzing/run-shape-fuzzer-tests.py +++ b/test/fuzzing/run-shape-fuzzer-tests.py @@ -2,7 +2,36 @@ from __future__ import print_function, division, absolute_import -import sys, os, subprocess +import sys, os, subprocess, tempfile, threading + + +def cmd(command): + # https://stackoverflow.com/a/4408409 + # https://stackoverflow.com/a/10012262 + with tempfile.TemporaryFile() as tempf: + p = subprocess.Popen (command, stderr=tempf) + is_killed = {'value': False} + + def timeout(p, is_killed): + is_killed['value'] = True + p.kill() + timer = threading.Timer (2, timeout, [p, is_killed]) + + try: + timer.start() + p.wait () + tempf.seek (0) + text = tempf.read().decode ("utf-8").strip () + returncode = p.returncode + finally: + timer.cancel() + + if is_killed['value']: + text = 'error: timeout, ' + text + returncode = 1 + + return text, returncode + srcdir = os.environ.get ("srcdir", ".") EXEEXT = os.environ.get ("EXEEXT", "") @@ -24,10 +53,11 @@ parent_path = os.path.join (srcdir, "fonts") for file in os.listdir (parent_path): path = os.path.join(parent_path, file) - p = subprocess.Popen ([hb_shape_fuzzer, path]) + text, returncode = cmd ([hb_shape_fuzzer, path]) + print (text) - if p.wait () != 0: - print ('failure on %s', font) + if returncode != 0 or 'error' in text: + print ('failure on %s' % file) fails = fails + 1 if fails: diff --git a/util/options.cc b/util/options.cc index 26b0bd0a8..5661cd059 100644 --- a/util/options.cc +++ b/util/options.cc @@ -660,7 +660,7 @@ font_options_t::get_font (void) const blob = hb_blob_create_from_file (font_path); if (blob == hb_blob_get_empty ()) - fail (false, "No such file or directory"); + fail (false, "Couldn't read or find %s, or it was empty.", font_path); /* Create the face */ hb_face_t *face = hb_face_create (blob, face_index);