diff --git a/src/Makefile.sources b/src/Makefile.sources index 6128fd0f9..b58848e04 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -107,6 +107,7 @@ HB_OT_sources = \ hb-aat-layout-feat-table.hh \ hb-aat-layout-just-table.hh \ hb-aat-layout-kerx-table.hh \ + hb-aat-layout-lcar-table.hh \ hb-aat-layout-morx-table.hh \ hb-aat-layout-trak-table.hh \ hb-aat-layout.hh \ diff --git a/src/hb-aat-layout-feat-table.hh b/src/hb-aat-layout-feat-table.hh index b670caab8..87ab4abd3 100644 --- a/src/hb-aat-layout-feat-table.hh +++ b/src/hb-aat-layout-feat-table.hh @@ -54,13 +54,6 @@ struct SettingName struct FeatureName { - inline bool sanitize (hb_sanitize_context_t *c, const void *base) const - { - TRACE_SANITIZE (this); - return_trace (likely (c->check_struct (this) && - (base+settingTable).sanitize (c, nSettings))); - } - enum { Exclusive = 0x8000, /* If set, the feature settings are mutually exclusive. */ NotDefault = 0x4000, /* If clear, then the setting with an index of 0 in @@ -75,6 +68,13 @@ struct FeatureName * as the default. */ }; + inline bool sanitize (hb_sanitize_context_t *c, const void *base) const + { + TRACE_SANITIZE (this); + return_trace (likely (c->check_struct (this) && + (base+settingTable).sanitize (c, nSettings))); + } + protected: HBUINT16 feature; /* Feature type. */ HBUINT16 nSettings; /* The number of records in the setting name array. */ diff --git a/src/hb-aat-layout-just-table.hh b/src/hb-aat-layout-just-table.hh index 1d6002757..92ca6603e 100644 --- a/src/hb-aat-layout-just-table.hh +++ b/src/hb-aat-layout-just-table.hh @@ -178,6 +178,8 @@ struct RepeatedAddGlyphAction struct ActionSubrecord { + inline unsigned int get_length (void) const { return u.header.actionLength; } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -196,8 +198,6 @@ struct ActionSubrecord } } - inline unsigned int get_length () const { return u.header.actionLength; } - protected: union { ActionSubrecordHeader header; @@ -309,8 +309,8 @@ struct WidthDeltaPair public: DEFINE_SIZE_STATIC (24); }; - -struct WidthDeltaCluster : OT::LArrayOf {}; + +typedef OT::LArrayOf WidthDeltaCluster; struct JustificationCategory { @@ -388,9 +388,10 @@ struct just { TRACE_SANITIZE (this); - return_trace (unlikely (c->check_struct (this) && - horizData.sanitize (c, this, this) && - vertData.sanitize (c, this, this))); + return_trace (likely (c->check_struct (this) && + version.major == 1 && + horizData.sanitize (c, this, this) && + vertData.sanitize (c, this, this))); } protected: diff --git a/src/hb-aat-layout-lcar-table.hh b/src/hb-aat-layout-lcar-table.hh new file mode 100644 index 000000000..e57836a08 --- /dev/null +++ b/src/hb-aat-layout-lcar-table.hh @@ -0,0 +1,92 @@ +/* + * Copyright © 2018 Ebrahim Byagowi + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + */ +#ifndef HB_AAT_LAYOUT_LCAR_TABLE_HH +#define HB_AAT_LAYOUT_LCAR_TABLE_HH + +#include "hb-open-type.hh" +#include "hb-aat-layout-common.hh" + +/* + * lcar -- Ligature caret + * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6lcar.html + */ +#define HB_AAT_TAG_lcar HB_TAG('l','c','a','r') + + +namespace AAT { + +typedef ArrayOf LigCaretClassEntry; + +struct lcar +{ + static const hb_tag_t tableTag = HB_AAT_TAG_lcar; + + inline unsigned int get_lig_carets (hb_font_t *font, + hb_direction_t direction, + hb_codepoint_t glyph, + unsigned int start_offset, + unsigned int *caret_count /* IN/OUT */, + hb_position_t *caret_array /* OUT */) const + { + const OffsetTo* entry_offset = lookup.get_value (glyph, font->face->num_glyphs); + const LigCaretClassEntry& array = entry_offset ? this+*entry_offset : Null (LigCaretClassEntry); + if (caret_count && *caret_count) + { + const HBINT16 *arr = array.sub_array (start_offset, caret_count); + unsigned int count = *caret_count; + for (unsigned int i = 0; i < count; ++i) + switch (format) + { + case 0: caret_array[i] = font->em_scale_dir (arr[i], direction); break; + case 1: + hb_position_t x, y; + font->get_glyph_contour_point_for_origin (glyph, arr[i], direction, &x, &y); + caret_array[i] = HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y; + break; + } + } + return array.len; + } + + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (likely (c->check_struct (this) && + version.major == 1 && + lookup.sanitize (c, this))); + } + + protected: + FixedVersion<>version; /* Version number of the ligature caret table */ + HBUINT16 format; /* Format of the ligature caret table. */ + Lookup > + lookup; /* data Lookup table associating glyphs */ + + public: + DEFINE_SIZE_MIN (8); +}; + +} /* namespace AAT */ + +#endif /* HB_AAT_LAYOUT_LCAR_TABLE_HH */ diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh index c579c1193..3b55967c8 100644 --- a/src/hb-aat-layout-trak-table.hh +++ b/src/hb-aat-layout-trak-table.hh @@ -147,9 +147,9 @@ struct TrackData inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); - return_trace (c->check_struct (this) && - sizeTable.sanitize (c, base, nSizes) && - trackTable.sanitize (c, nTracks, base, nSizes)); + return_trace (likely (c->check_struct (this) && + sizeTable.sanitize (c, base, nSizes) && + trackTable.sanitize (c, nTracks, base, nSizes))); } protected: @@ -171,15 +171,6 @@ struct trak inline bool has_data (void) const { return version.to_int () != 0; } - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - - return_trace (unlikely (c->check_struct (this) && - horizData.sanitize (c, this, this) && - vertData.sanitize (c, this, this))); - } - inline bool apply (hb_aat_apply_context_t *c) const { TRACE_APPLY (this); @@ -221,15 +212,27 @@ struct trak return_trace (true); } + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + + return_trace (likely (c->check_struct (this) && + version.major == 1 && + horizData.sanitize (c, this, this) && + vertData.sanitize (c, this, this))); + } + protected: - FixedVersion<> version; /* Version of the tracking table + FixedVersion<>version; /* Version of the tracking table * (0x00010000u for version 1.0). */ - HBUINT16 format; /* Format of the tracking table (set to 0). */ - OffsetTo horizData; /* Offset from start of tracking table to TrackData - * for horizontal text (or 0 if none). */ - OffsetTo vertData; /* Offset from start of tracking table to TrackData - * for vertical text (or 0 if none). */ - HBUINT16 reserved; /* Reserved. Set to 0. */ + HBUINT16 format; /* Format of the tracking table (set to 0). */ + OffsetTo + horizData; /* Offset from start of tracking table to TrackData + * for horizontal text (or 0 if none). */ + OffsetTo + vertData; /* Offset from start of tracking table to TrackData + * for vertical text (or 0 if none). */ + HBUINT16 reserved; /* Reserved. Set to 0. */ public: DEFINE_SIZE_STATIC (12); diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 9ccd7f255..2540d438b 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -356,7 +356,12 @@ hb_bsearch_r (const void *key, const void *base, } -/* From https://github.com/noporpoise/sort_r */ +/* From https://github.com/noporpoise/sort_r + * With following modifications: + * + * 10 November 2018: + * https://github.com/noporpoise/sort_r/issues/7 + */ /* Isaac Turner 29 April 2014 Public Domain */ @@ -412,7 +417,7 @@ static inline void sort_r_simple(void *base, size_t nel, size_t w, /* Use median of first, middle and last items as pivot */ char *x, *y, *xend, ch; - char *pl, *pr; + char *pl, *pm, *pr; char *last = b+w*(nel-1), *tmp; char *l[3]; l[0] = b; @@ -434,13 +439,15 @@ static inline void sort_r_simple(void *base, size_t nel, size_t w, pr = last; while(pl < pr) { - for(; pl < pr; pl += w) { + pm = pl+((pr-pl+1)>>1); + for(; pl < pm; pl += w) { if(sort_r_cmpswap(pl, pr, w, compar, arg)) { pr -= w; /* pivot now at pl */ break; } } - for(; pl < pr; pr -= w) { + pm = pl+((pr-pl)>>1); + for(; pm < pr; pr -= w) { if(sort_r_cmpswap(pl, pr, w, compar, arg)) { pl += w; /* pivot now at pr */ break; @@ -517,7 +524,10 @@ struct hb_bytes_t inline hb_bytes_t (const char *bytes_, unsigned int len_) : arrayZ (bytes_), len (len_) {} inline hb_bytes_t (const void *bytes_, unsigned int len_) : arrayZ ((const char *) bytes_), len (len_) {} template - inline hb_bytes_t (const T& array) : arrayZ ((const char *) array.arrayZ), len (array.len) {} + inline hb_bytes_t (const T& array) : arrayZ ((const char *) array.arrayZ), len (array.len * sizeof (array.arrayZ[0])) {} + + inline operator const void * (void) const { return arrayZ; } + inline operator const char * (void) const { return arrayZ; } inline void free (void) { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; } @@ -526,6 +536,9 @@ struct hb_bytes_t if (len != a.len) return (int) a.len - (int) len; + if (!len) + return 0; /* glibc's memcmp() declares args non-NULL, and UBSan doesn't like that. :( */ + return memcmp (a.arrayZ, arrayZ, len); } static inline int cmp (const void *pa, const void *pb) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 6d6dd7b27..56fa43345 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -337,8 +337,16 @@ struct UnsizedArrayOf { HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); - inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; } - inline Type& operator [] (unsigned int i) { return arrayZ[i]; } + /* Unlikely other places, use "int i" instead of "unsigned int i" for our + * indexing operator. For two reasons: + * 1. For UnsizedArrayOf, it's not totally unimaginable to want to look + * at items before the start of current array. + * 2. Fixes MSVC 2008 "overloads have similar conversions" issue with the + * built-in operator [] that takes int, in expressions like sizeof(array[0])). + * I suppose I could fix that by replacing 0 with 0u, but like this fix + * more now. */ + inline const Type& operator [] (int i) const { return arrayZ[i]; } + inline Type& operator [] (int i) { return arrayZ[i]; } template inline operator T * (void) { return arrayZ; } template inline operator const T * (void) const { return arrayZ; } diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh index b480af51d..fa40223b7 100644 --- a/src/hb-ot-color-colr-table.hh +++ b/src/hb-ot-color-colr-table.hh @@ -103,7 +103,12 @@ struct COLR unsigned int *count, /* IN/OUT. May be NULL. */ hb_ot_color_layer_t *layers /* OUT. May be NULL. */) const { - const BaseGlyphRecord &record = get_glyph_record (glyph); + const BaseGlyphRecord *rec = (BaseGlyphRecord *) bsearch (&glyph, + &(this+baseGlyphsZ), + numBaseGlyphs, + sizeof (BaseGlyphRecord), + BaseGlyphRecord::cmp); + const BaseGlyphRecord &record = rec ? *rec : Null (BaseGlyphRecord); hb_array_t all_layers ((this+layersZ).arrayZ, numLayers); hb_array_t glyph_layers = all_layers.sub_array (record.firstLayerIdx, @@ -129,17 +134,6 @@ struct COLR (this+layersZ).sanitize (c, numLayers))); } - private: - inline const BaseGlyphRecord &get_glyph_record (hb_codepoint_t glyph_id) const - { - const BaseGlyphRecord *rec = (BaseGlyphRecord *) bsearch (&glyph_id, - &(this+baseGlyphsZ), - numBaseGlyphs, - sizeof (BaseGlyphRecord), - BaseGlyphRecord::cmp); - return rec ? *rec : Null(BaseGlyphRecord); - } - protected: HBUINT16 version; /* Table version number (starts at 0). */ HBUINT16 numBaseGlyphs; /* Number of Base Glyph Records. */ diff --git a/src/hb-ot-face.hh b/src/hb-ot-face.hh index 987dae38f..61f85e1c9 100644 --- a/src/hb-ot-face.hh +++ b/src/hb-ot-face.hh @@ -62,6 +62,7 @@ HB_OT_TABLE(AAT, kerx) \ HB_OT_TABLE(AAT, ankr) \ HB_OT_TABLE(AAT, trak) \ + HB_OT_TABLE(AAT, lcar) \ HB_OT_TABLE(AAT, ltag) \ /* OpenType variations. */ \ HB_OT_TABLE(OT, fvar) \ diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index d2a39f230..0623be892 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -149,7 +149,7 @@ struct glyf }; HBUINT16 flags; - HBUINT16 glyphIndex; + GlyphID glyphIndex; inline unsigned int get_size (void) const { diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh index ea5f1c07d..af7e5a833 100644 --- a/src/hb-ot-layout-gdef-table.hh +++ b/src/hb-ot-layout-gdef-table.hh @@ -123,10 +123,8 @@ struct CaretValueFormat2 inline hb_position_t get_caret_value (hb_font_t *font, hb_direction_t direction, hb_codepoint_t glyph_id) const { hb_position_t x, y; - if (font->get_glyph_contour_point_for_origin (glyph_id, caretValuePoint, direction, &x, &y)) - return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y; - else - return 0; + font->get_glyph_contour_point_for_origin (glyph_id, caretValuePoint, direction, &x, &y); + return HB_DIRECTION_IS_HORIZONTAL (direction) ? x : y; } inline bool sanitize (hb_sanitize_context_t *c) const diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index eb5140fc2..33bf03c13 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -42,6 +42,8 @@ #include "hb-ot-kern-table.hh" #include "hb-ot-name-table.hh" +#include "hb-aat-layout-lcar-table.hh" + /** * SECTION:hb-ot-layout @@ -275,12 +277,15 @@ hb_ot_layout_get_ligature_carets (hb_font_t *font, unsigned int *caret_count /* IN/OUT */, hb_position_t *caret_array /* OUT */) { - return font->face->table.GDEF->table->get_lig_carets (font, - direction, - glyph, - start_offset, - caret_count, - caret_array); + unsigned int result_caret_count = 0; + unsigned int result = font->face->table.GDEF->table->get_lig_carets (font, direction, glyph, start_offset, &result_caret_count, caret_array); + if (result) + { + if (caret_count) *caret_count = result_caret_count; + } + else + result = font->face->table.lcar->get_lig_carets (font, direction, glyph, start_offset, caret_count, caret_array); + return result; } diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index 18f9976bc..77eef3f5c 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -73,28 +73,15 @@ struct post { static const hb_tag_t tableTag = HB_OT_TAG_post; - inline bool sanitize (hb_sanitize_context_t *c) const - { - TRACE_SANITIZE (this); - if (unlikely (!c->check_struct (this))) - return_trace (false); - if (version.to_int () == 0x00020000) - { - const postV2Tail &v2 = StructAfter (*this); - return_trace (v2.sanitize (c)); - } - return_trace (true); - } - inline bool subset (hb_subset_plan_t *plan) const { unsigned int post_prime_length; hb_blob_t *post_blob = hb_sanitize_context_t().reference_table(plan->source); - hb_blob_t *post_prime_blob = hb_blob_create_sub_blob (post_blob, 0, post::static_size); + hb_blob_t *post_prime_blob = hb_blob_create_sub_blob (post_blob, 0, post::min_size); post *post_prime = (post *) hb_blob_get_data_writable (post_prime_blob, &post_prime_length); hb_blob_destroy (post_blob); - if (unlikely (!post_prime || post_prime_length != post::static_size)) + if (unlikely (!post_prime || post_prime_length != post::min_size)) { hb_blob_destroy (post_prime_blob); DEBUG_MSG(SUBSET, nullptr, "Invalid source post table with length %d.", post_prime_length); @@ -122,7 +109,7 @@ struct post if (version != 0x00020000) return; - const postV2Tail &v2 = StructAfter (*table); + const postV2Tail &v2 = table->v2; glyphNameIndex = &v2.glyphNameIndex; pool = &StructAfter (v2.glyphNameIndex); @@ -259,12 +246,21 @@ struct post private: hb_blob_t *blob; uint32_t version; - hb_nonnull_ptr_t > glyphNameIndex; + const ArrayOf *glyphNameIndex; hb_vector_t index_to_offset; const uint8_t *pool; hb_atomic_ptr_t gids_sorted_by_name; }; + inline bool sanitize (hb_sanitize_context_t *c) const + { + TRACE_SANITIZE (this); + return_trace (likely (c->check_struct (this) && + (version.to_int () == 0x00010000 || + (version.to_int () == 0x00020000 && v2.sanitize (c)) || + version.to_int () == 0x00030000))); + } + public: FixedVersion<>version; /* 0x00010000 for version 1.0 * 0x00020000 for version 2.0 @@ -297,8 +293,8 @@ struct post * is downloaded as a Type 1 font. */ HBUINT32 maxMemType1; /* Maximum memory usage when an OpenType font * is downloaded as a Type 1 font. */ -/*postV2Tail v2[VAR];*/ - DEFINE_SIZE_STATIC (32); + postV2Tail v2; + DEFINE_SIZE_MIN (32); }; struct post_accelerator_t : post::accelerator_t {}; diff --git a/src/hb-set.hh b/src/hb-set.hh index 21a22525f..c47f77b70 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -375,8 +375,8 @@ struct hb_set_t if (!resize (count)) return; population = other->population; - memcpy (pages, other->pages, count * sizeof (pages[0])); - memcpy (page_map, other->page_map, count * sizeof (page_map[0])); + memcpy (pages, other->pages, count * pages.item_size); + memcpy (page_map, other->page_map, count * page_map.item_size); } inline bool is_equal (const hb_set_t *other) const diff --git a/src/hb-vector.hh b/src/hb-vector.hh index fe06addf7..7056a5b54 100644 --- a/src/hb-vector.hh +++ b/src/hb-vector.hh @@ -34,6 +34,9 @@ template struct hb_vector_t { + typedef Type ItemType; + enum { item_size = sizeof (Type) }; + HB_NO_COPY_ASSIGN_TEMPLATE2 (hb_vector_t, Type, StaticSize); inline hb_vector_t (void) { init (); } inline ~hb_vector_t (void) { fini (); } diff --git a/test/api/Makefile.am b/test/api/Makefile.am index bd5f13ace..02c7f49fa 100644 --- a/test/api/Makefile.am +++ b/test/api/Makefile.am @@ -78,6 +78,7 @@ endif TEST_PROGS += \ test-ot-color \ + test-ot-ligature-carets \ test-ot-name \ test-ot-tag \ test-ot-extents-cff \ diff --git a/test/api/fonts/lcar.ttf b/test/api/fonts/lcar.ttf new file mode 100644 index 000000000..4d176636e Binary files /dev/null and b/test/api/fonts/lcar.ttf differ diff --git a/test/api/test-ot-ligature-carets.c b/test/api/test-ot-ligature-carets.c new file mode 100644 index 000000000..d84278513 --- /dev/null +++ b/test/api/test-ot-ligature-carets.c @@ -0,0 +1,67 @@ +/* + * Copyright © 2018 Ebrahim Byagowi + * + * This is part of HarfBuzz, a text shaping library. + * + * Permission is hereby granted, without written agreement and without + * license or royalty fees, to use, copy, modify, and distribute this + * software and its documentation for any purpose, provided that the + * above copyright notice and the following two paragraphs appear in + * all copies of this software. + * + * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES + * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN + * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH + * DAMAGE. + * + * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + * + */ + +#include "hb-test.h" + +#include + +static void +test_ot_layout_feature_get_name_ids_and_characters (void) +{ + hb_face_t *face = hb_test_open_font_file ("fonts/lcar.ttf"); + hb_font_t *font = hb_font_create (face); + hb_font_set_scale (font, hb_face_get_upem (face) * 2, hb_face_get_upem (face) * 4); + + hb_position_t caret_array[2]; + unsigned int caret_count = 2; + g_assert_cmpuint (2, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_RTL, + 98, 0, &caret_count, + caret_array)); + + g_assert_cmpuint (2, ==, caret_count); + g_assert_cmpuint (1130, ==, caret_array[0]); + g_assert_cmpuint (2344, ==, caret_array[1]); + + g_assert_cmpuint (2, ==, hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_BTT, + 98, 0, &caret_count, + caret_array)); + + g_assert_cmpuint (2, ==, caret_count); + g_assert_cmpuint (2260, ==, caret_array[0]); + g_assert_cmpuint (4688, ==, caret_array[1]); + + hb_font_destroy (font); + hb_face_destroy (face); +} + +int +main (int argc, char **argv) +{ + g_test_init (&argc, &argv, NULL); + + hb_test_add (test_ot_layout_feature_get_name_ids_and_characters); + + return hb_test_run (); +} diff --git a/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5634443633491968 b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5634443633491968 new file mode 100644 index 000000000..c63bcc582 Binary files /dev/null and b/test/fuzzing/fonts/clusterfuzz-testcase-minimized-hb-shape-fuzzer-5634443633491968 differ diff --git a/test/shaping/data/text-rendering-tests/DISABLED b/test/shaping/data/text-rendering-tests/DISABLED index ef987a4df..b0719043e 100644 --- a/test/shaping/data/text-rendering-tests/DISABLED +++ b/test/shaping/data/text-rendering-tests/DISABLED @@ -1,3 +1,4 @@ +tests/MORX-31.tests tests/MORX-41.tests # Non-Unicode cmap diff --git a/test/shaping/data/text-rendering-tests/Makefile.sources b/test/shaping/data/text-rendering-tests/Makefile.sources index 136a14d32..052a61236 100644 --- a/test/shaping/data/text-rendering-tests/Makefile.sources +++ b/test/shaping/data/text-rendering-tests/Makefile.sources @@ -51,7 +51,6 @@ TESTS = \ tests/MORX-29.tests \ tests/MORX-2.tests \ tests/MORX-30.tests \ - tests/MORX-31.tests \ tests/MORX-32.tests \ tests/MORX-33.tests \ tests/MORX-34.tests \ @@ -74,6 +73,7 @@ TESTS = \ DISBALED_TESTS = \ tests/CMAP-3.tests \ + tests/MORX-31.tests \ tests/MORX-41.tests \ tests/SHARAN-1.tests \ tests/SHBALI-1.tests \ diff --git a/test/shaping/data/text-rendering-tests/tests/MORX-31.tests b/test/shaping/data/text-rendering-tests/tests/MORX-31.tests index 6cc40b6e1..ac09e27b4 100644 --- a/test/shaping/data/text-rendering-tests/tests/MORX-31.tests +++ b/test/shaping/data/text-rendering-tests/tests/MORX-31.tests @@ -1,8 +1,8 @@ -../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0058,U+0058,U+0041,U+0059,U+0059,U+0041,U+005A,U+005A:[X|X@364,0|I@728,0|N@1558,0|S@2388,0|A@3218,0|Y@4048,0|Y@4380,0|A@4712,0|Z@5542,0|Z@5864,0] -../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0058,U+0058,U+0041,U+0059,U+0059,U+0042,U+0059,U+0059:[X|X@364,0|A@728,0|I@1558,0|N@2388,0|S@3218,0|Y@4048,0|Y@4380,0|B@4712,0|Y@5542,0|Y@5874,0] -../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0058,U+0058,U+0042,U+0059,U+0059,U+0041,U+005A,U+005A:[X|X@364,0|I@728,0|N@1558,0|S@2388,0|B@3218,0|Y@4048,0|Y@4380,0|A@4712,0|Z@5542,0|Z@5864,0] -../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0058,U+0058,U+0042,U+0059,U+0059,U+0042,U+005A,U+005A:[X|X@364,0|B@728,0|I@1558,0|N@2388,0|S@3218,0|Y@4048,0|Y@4380,0|B@4712,0|Z@5542,0|Z@5864,0] -../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0041,U+0058,U+0059,U+005A,U+0041:[I|N@830,0|S@1660,0|M@2490,0|P@3320,0|Q@3653,0|R@4019,0|I@4370,0|N@5200,0|S@6030,0|A@6860,0|X@7690,0|Y@8054,0|Z@8386,0|A@8708,0] -../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0041,U+0058,U+0059,U+005A,U+0042:[I|N@830,0|S@1660,0|M@2490,0|P@3320,0|Q@3653,0|R@4019,0|A@4370,0|I@5200,0|N@6030,0|S@6860,0|X@7690,0|Y@8054,0|Z@8386,0|B@8708,0] -../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0042,U+0058,U+0059,U+005A,U+0041:[M|I@830,0|N@1660,0|S@2490,0|P@3320,0|Q@3653,0|R@4019,0|I@4370,0|N@5200,0|S@6030,0|B@6860,0|X@7690,0|Y@8054,0|Z@8386,0|A@8708,0] -../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0042,U+0058,U+0059,U+005A,U+0042:[M|I@830,0|N@1660,0|S@2490,0|P@3320,0|Q@3653,0|R@4019,0|B@4370,0|I@5200,0|N@6030,0|S@6860,0|X@7690,0|Y@8054,0|Z@8386,0|B@8708,0] +../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0058,U+0058,U+0041,U+0059,U+0059,U+0041,U+005A,U+005A:[I|N@830,0|I@1660,0|N@2490,0|S@3320,0|S@4150,0|X@4980,0|X@5344,0|A@5708,0|Y@6538,0|Y@6870,0|A@7202,0|Z@8032,0|Z@8354,0] +../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0058,U+0058,U+0041,U+0059,U+0059,U+0042,U+0059,U+0059:[I|N@830,0|S@1660,0|I@2490,0|N@3320,0|S@4150,0|X@4980,0|X@5344,0|A@5708,0|Y@6538,0|Y@6870,0|B@7202,0|Y@8032,0|Y@8364,0] +../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0058,U+0058,U+0042,U+0059,U+0059,U+0041,U+005A,U+005A:[X|I@364,0|I@1194,0|N@2024,0|S@2854,0|N@3684,0|S@4514,0|X@5344,0|B@5708,0|Y@6538,0|Y@6870,0|A@7202,0|Z@8032,0|Z@8354,0] +../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0058,U+0058,U+0042,U+0059,U+0059,U+0042,U+005A,U+005A:[X|I@364,0|N@1194,0|I@2024,0|N@2854,0|S@3684,0|S@4514,0|X@5344,0|B@5708,0|Y@6538,0|Y@6870,0|B@7202,0|Z@8032,0|Z@8354,0] +../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0041,U+0058,U+0059,U+005A,U+0041:[I|N@830,0|S@1660,0|M@2490,0|I@3320,0|N@4150,0|S@4980,0|P@5810,0|Q@6143,0|R@6509,0|A@6860,0|X@7690,0|Y@8054,0|Z@8386,0|A@8708,0] +../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0041,U+0058,U+0059,U+005A,U+0042:[I|N@830,0|S@1660,0|M@2490,0|P@3320,0|I@3653,0|N@4483,0|S@5313,0|Q@6143,0|R@6509,0|A@6860,0|X@7690,0|Y@8054,0|Z@8386,0|B@8708,0] +../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0042,U+0058,U+0059,U+005A,U+0041:[M|I@830,0|N@1660,0|S@2490,0|I@3320,0|N@4150,0|S@4980,0|P@5810,0|Q@6143,0|R@6509,0|B@6860,0|X@7690,0|Y@8054,0|Z@8386,0|A@8708,0] +../fonts/TestMORXThirtyone.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+004D,U+0050,U+0051,U+0052,U+0042,U+0058,U+0059,U+005A,U+0042:[M|I@830,0|N@1660,0|S@2490,0|P@3320,0|I@3653,0|N@4483,0|S@5313,0|Q@6143,0|R@6509,0|B@6860,0|X@7690,0|Y@8054,0|Z@8386,0|B@8708,0]