From fda994e1d45c4d34601af7272f37ea257f92a3d8 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Fri, 7 Sep 2018 15:02:57 -0400 Subject: [PATCH 01/39] Use enum instead of "static const" in class scope Technically, static const needs an out-of-class definition. Eg: CXXLD libharfbuzz-subset.la Undefined symbols for architecture x86_64: "OT::FeatureVariationRecord::min_size", referenced from: bool OT::GSUBGPOS::subset(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o bool OT::GSUBGPOS::subset(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o "OT::Record::min_size", referenced from: OT::Script::subset(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o "OT::IntType::min_size", referenced from: OT::Script::subset(hb_subset_context_t*) constin libharfbuzz_subset_la-hb-subset.o OT::RecordListOf::subset(hb_subset_context_t*) const in libharfbuzz_subset_la-hb-subset.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make[4]: *** [libharfbuzz-subset.la] Error 1 make[3]: *** [all-recursive] Error 1 make[2]: *** [all] Error 2 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2 Exited with code 2 --- src/hb-buffer.hh | 2 +- src/hb-machinery.hh | 8 ++++---- src/hb-open-file.hh | 2 +- src/hb-open-type.hh | 2 +- src/hb-ot-layout-common.hh | 2 +- src/hb-ot-layout.cc | 4 ++-- src/hb-set-digest.hh | 4 ++-- src/hb-set.hh | 12 ++++++------ 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/hb-buffer.hh b/src/hb-buffer.hh index 3e38fe1de..bcaf066c7 100644 --- a/src/hb-buffer.hh +++ b/src/hb-buffer.hh @@ -119,7 +119,7 @@ struct hb_buffer_t /* Text before / after the main buffer contents. * Always in Unicode, and ordered outward. * Index 0 is for "pre-context", 1 for "post-context". */ - static const unsigned int CONTEXT_LENGTH = 5; + enum { CONTEXT_LENGTH = 5 }; hb_codepoint_t context[2][CONTEXT_LENGTH]; unsigned int context_len[2]; diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index 689941601..62f490721 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -99,8 +99,8 @@ static inline Type& StructAfter(TObject &X) #define DEFINE_SIZE_STATIC(size) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size)); \ - static const unsigned int static_size = (size); \ - static const unsigned int min_size = (size); \ + enum { static_size = (size) }; \ + enum { min_size = (size) }; \ inline unsigned int get_size (void) const { return (size); } #define DEFINE_SIZE_UNION(size, _member) \ @@ -114,7 +114,7 @@ static inline Type& StructAfter(TObject &X) #define DEFINE_SIZE_ARRAY(size, array) \ DEFINE_INSTANCE_ASSERTION (sizeof (*this) == (size) + VAR * sizeof (array[0])); \ DEFINE_COMPILES_ASSERTION ((void) array[0].static_size) \ - static const unsigned int min_size = (size); \ + enum { min_size = (size) }; \ #define DEFINE_SIZE_ARRAY_SIZED(size, array) \ DEFINE_SIZE_ARRAY(size, array); \ @@ -133,7 +133,7 @@ static inline Type& StructAfter(TObject &X) template struct hb_dispatch_context_t { - static const unsigned int max_debug_depth = MaxDebugDepth; + enum { max_debug_depth = MaxDebugDepth }; typedef Return return_t; template inline bool may_dispatch (const T *obj, const F *format) { return true; } diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh index 847f9b060..d3b748602 100644 --- a/src/hb-open-file.hh +++ b/src/hb-open-file.hh @@ -115,7 +115,7 @@ typedef struct OffsetTable * table list. */ int i = tables.len < 64 ? tables.lsearch (t) : tables.bsearch (t); if (table_index) - *table_index = i == -1 ? Index::NOT_FOUND_INDEX : (unsigned int) i; + *table_index = i == -1 ? (unsigned) Index::NOT_FOUND_INDEX : (unsigned) i; return i != -1; } inline const TableRecord& get_table_by_tag (hb_tag_t tag) const diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 29afa9451..ef18163fa 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -150,7 +150,7 @@ typedef HBUINT16 NameID; /* Script/language-system/feature index */ struct Index : HBUINT16 { - static const unsigned int NOT_FOUND_INDEX = 0xFFFFu; + enum { NOT_FOUND_INDEX = 0xFFFFu }; }; DECLARE_NULL_NAMESPACE_BYTES (OT, Index); diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index ca3d7d5d1..dd65f3384 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1743,7 +1743,7 @@ struct FeatureVariationRecord struct FeatureVariations { - static const unsigned int NOT_FOUND_INDEX = 0xFFFFFFFFu; + enum { NOT_FOUND_INDEX = 0xFFFFFFFFu }; inline bool find_index (const int *coords, unsigned int coord_len, unsigned int *index) const diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index 345078917..a1220f4dd 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1068,7 +1068,7 @@ hb_ot_layout_get_size_params (hb_face_t *face, struct GSUBProxy { - static const unsigned int table_index = 0; + enum { table_index = 0 }; static const bool inplace = false; typedef OT::SubstLookup Lookup; @@ -1082,7 +1082,7 @@ struct GSUBProxy struct GPOSProxy { - static const unsigned int table_index = 1; + enum { table_index = 1 }; static const bool inplace = true; typedef OT::PosLookup Lookup; diff --git a/src/hb-set-digest.hh b/src/hb-set-digest.hh index 4cd7c3ff8..0f9329f62 100644 --- a/src/hb-set-digest.hh +++ b/src/hb-set-digest.hh @@ -50,8 +50,8 @@ struct hb_set_digest_lowest_bits_t { ASSERT_POD (); - static const unsigned int mask_bytes = sizeof (mask_t); - static const unsigned int mask_bits = sizeof (mask_t) * 8; + enum { mask_bytes = sizeof (mask_t) }; + enum { mask_bits = sizeof (mask_t) * 8 }; static const unsigned int num_bits = 0 + (mask_bytes >= 1 ? 3 : 0) + (mask_bytes >= 2 ? 1 : 0) diff --git a/src/hb-set.hh b/src/hb-set.hh index a179ad13d..353403e92 100644 --- a/src/hb-set.hh +++ b/src/hb-set.hh @@ -157,7 +157,7 @@ struct hb_set_t } typedef unsigned long long elt_t; - static const unsigned int PAGE_BITS = 512; + enum { PAGE_BITS = 512 }; static_assert ((PAGE_BITS & ((PAGE_BITS) - 1)) == 0, ""); static inline unsigned int elt_get_min (const elt_t &elt) { return hb_ctz (elt); } @@ -165,11 +165,11 @@ struct hb_set_t typedef hb_vector_size_t vector_t; - static const unsigned int ELT_BITS = sizeof (elt_t) * 8; - static const unsigned int ELT_MASK = ELT_BITS - 1; - static const unsigned int BITS = sizeof (vector_t) * 8; - static const unsigned int MASK = BITS - 1; - static_assert (PAGE_BITS == BITS, ""); + enum { ELT_BITS = sizeof (elt_t) * 8 }; + enum { ELT_MASK = ELT_BITS - 1 }; + enum { BITS = sizeof (vector_t) * 8 }; + enum { MASK = BITS - 1 }; + static_assert ((unsigned) PAGE_BITS == (unsigned) BITS, ""); elt_t &elt (hb_codepoint_t g) { return v[(g & MASK) / ELT_BITS]; } elt_t const &elt (hb_codepoint_t g) const { return v[(g & MASK) / ELT_BITS]; } From d42f0e5809964136911cbbd845bc423a8dfd5e31 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 11:05:33 +0200 Subject: [PATCH 02/39] [atomic] Fix pointer type passed to InterlockedExchangeAdd() John Emmas reported on mailing list that build with MSVC is failing. Not sure why bots don't catch it, but this should fix. --- src/hb-atomic.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hb-atomic.hh b/src/hb-atomic.hh index d494c8955..6e3672c18 100644 --- a/src/hb-atomic.hh +++ b/src/hb-atomic.hh @@ -98,7 +98,7 @@ static inline void _hb_memory_barrier (void) { #if !defined(MemoryBarrier) /* MinGW has a convoluted history of supporting MemoryBarrier. */ - long dummy = 0; + LONG dummy = 0; InterlockedExchange (&dummy, 1); #else MemoryBarrier (); @@ -106,7 +106,8 @@ static inline void _hb_memory_barrier (void) } #define _hb_memory_barrier() _hb_memory_barrier () -#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd ((unsigned *) (AI), (V)) +#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd ((LONG *) (AI), (V)) +static_assert ((sizeof (LONG) == sizeof (int)), ""); #define hb_atomic_ptr_impl_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O)) From 616fd34a69bb69bc35c7e4ea939e71c3ea2e92cb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 11:19:49 +0200 Subject: [PATCH 03/39] [subset] Disable GSUB/GPOS subsetting for now So I can get a release out. I haven't debugged those yet, and they are producing bad tables. --- src/hb-subset.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hb-subset.cc b/src/hb-subset.cc index 2bed35868..b714f291a 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -179,10 +179,10 @@ _subset_table (hb_subset_plan_t *plan, break; case HB_OT_TAG_GSUB: - result = _subset2 (plan); + //result = _subset2 (plan); break; case HB_OT_TAG_GPOS: - result = _subset2 (plan); + //result = _subset2 (plan); break; default: From 54d332dd9b0263821376161cdffb60ffb3c7847f Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 11:37:24 +0200 Subject: [PATCH 04/39] 1.9.0 --- NEWS | 19 +++++++++++++++++++ configure.ac | 2 +- src/hb-face.cc | 10 +++++----- src/hb-unicode.h | 5 +++++ src/hb-version.h | 6 +++--- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 3ae857ef3..c9af0f368 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,22 @@ +Overview of changes leading to 1.9.0 +Monday, September 10, 2018 +==================================== +- Added 'cmap' API to hb_face_t. +- Face-builder API. +- hb-ot-font re-creation should be much leaner now, as the + font tables it uses are cached on hb_face_t now. +- Internal source header file name changes: + hb-*-private.hh is renamed to hb-*.hh. + +New API: ++HB_UNICODE_MAX ++hb_face_collect_unicodes() ++hb_face_collect_variation_selectors() ++hb_face_collect_variation_unicodes() ++hb_face_builder_create() ++hb_face_builder_add_table() + + Overview of changes leading to 1.8.8 Tuesday, August 14, 2018 ==================================== diff --git a/configure.ac b/configure.ac index 55cc12b3f..1c6980871 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.64]) AC_INIT([HarfBuzz], - [1.8.8], + [1.9.0], [https://github.com/harfbuzz/harfbuzz/issues/new], [harfbuzz], [http://harfbuzz.org/]) diff --git a/src/hb-face.cc b/src/hb-face.cc index 2fb5a0a36..92c341523 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -526,7 +526,7 @@ hb_face_get_table_tags (const hb_face_t *face, * @face: font face. * @out: set to add Unicode characters covered by @face to. * - * Since: REPLACEME + * Since: 1.9.0 */ void hb_face_collect_unicodes (hb_face_t *face, @@ -543,7 +543,7 @@ hb_face_collect_unicodes (hb_face_t *face, * * * - * Since: REPLACEME + * Since: 1.9.0 */ void hb_face_collect_variation_selectors (hb_face_t *face, @@ -560,7 +560,7 @@ hb_face_collect_variation_selectors (hb_face_t *face, * * * - * Since: REPLACEME + * Since: 1.9.0 */ void hb_face_collect_variation_unicodes (hb_face_t *face, @@ -684,7 +684,7 @@ _hb_face_builder_reference_table (hb_face_t *face, hb_tag_t tag, void *user_data * * Return value: (transfer full) New face. * - * Since: REPLACEME + * Since: 1.9.0 **/ hb_face_t * hb_face_builder_create (void) @@ -703,7 +703,7 @@ hb_face_builder_create (void) * Add table for @tag with data provided by @blob to the face. @face must * be created using hb_face_builder_create(). * - * Since: REPLACEME + * Since: 1.9.0 **/ hb_bool_t hb_face_builder_add_table (hb_face_t *face, hb_tag_t tag, hb_blob_t *blob) diff --git a/src/hb-unicode.h b/src/hb-unicode.h index 226c5d5c9..c8d87e4d1 100644 --- a/src/hb-unicode.h +++ b/src/hb-unicode.h @@ -40,6 +40,11 @@ HB_BEGIN_DECLS +/** + * HB_UNICODE_MAX + * + * Since: 1.9.0 + */ #define HB_UNICODE_MAX 0x10FFFFu diff --git a/src/hb-version.h b/src/hb-version.h index e0816d1e6..346495104 100644 --- a/src/hb-version.h +++ b/src/hb-version.h @@ -37,10 +37,10 @@ HB_BEGIN_DECLS #define HB_VERSION_MAJOR 1 -#define HB_VERSION_MINOR 8 -#define HB_VERSION_MICRO 8 +#define HB_VERSION_MINOR 9 +#define HB_VERSION_MICRO 0 -#define HB_VERSION_STRING "1.8.8" +#define HB_VERSION_STRING "1.9.0" #define HB_VERSION_ATLEAST(major,minor,micro) \ ((major)*10000+(minor)*100+(micro) <= \ From 20a11a824d2a07a8544649477ad03e809bdd8e19 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 13:56:28 +0200 Subject: [PATCH 05/39] Revert "[subset] Disable GSUB/GPOS subsetting for now" This reverts commit 616fd34a69bb69bc35c7e4ea939e71c3ea2e92cb. --- src/hb-subset.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/hb-subset.cc b/src/hb-subset.cc index b714f291a..2bed35868 100644 --- a/src/hb-subset.cc +++ b/src/hb-subset.cc @@ -179,10 +179,10 @@ _subset_table (hb_subset_plan_t *plan, break; case HB_OT_TAG_GSUB: - //result = _subset2 (plan); + result = _subset2 (plan); break; case HB_OT_TAG_GPOS: - //result = _subset2 (plan); + result = _subset2 (plan); break; default: From 5dfd6e07626a9022a995eb7fa16767eff66c6047 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 15:45:32 +0200 Subject: [PATCH 06/39] Fix sanitize or Context Rule Fixes https://github.com/harfbuzz/harfbuzz/issues/1110 --- src/hb-ot-layout-gsubgpos.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 315951a34..bd4611d22 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -1267,7 +1267,7 @@ struct Rule return_trace (inputCount.sanitize (c) && lookupCount.sanitize (c) && c->check_range (inputZ, - inputZ[0].static_size * inputCount + + inputZ[0].static_size * (inputCount ? inputCount - 1 : 0) + LookupRecord::static_size * lookupCount)); } From e46c51f1e985ac9c0ffa90fda4ea436d54b4009c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 17:38:19 +0200 Subject: [PATCH 07/39] [indic] Do NOT allow matra after Halant,ZWJ Fixes https://github.com/harfbuzz/harfbuzz/issues/556 Devanagari regresses 12 tests, and Gujarati 2. See: https://github.com/harfbuzz/harfbuzz/issues/556#issuecomment-419957472 New numbers: BENGALI: 353725 out of 354188 tests passed. 463 failed (0.130722%) DEVANAGARI: 707299 out of 707394 tests passed. 95 failed (0.0134296%) GUJARATI: 366353 out of 366457 tests passed. 104 failed (0.0283799%) GURMUKHI: 60729 out of 60747 tests passed. 18 failed (0.0296311%) KANNADA: 951300 out of 951913 tests passed. 613 failed (0.0643966%) MALAYALAM: 1048136 out of 1048334 tests passed. 198 failed (0.0188871%) ORIYA: 42327 out of 42329 tests passed. 2 failed (0.00472489%) SINHALA: 271596 out of 271847 tests passed. 251 failed (0.0923313%) TAMIL: 1091754 out of 1091754 tests passed. 0 failed (0%) TELUGU: 970555 out of 970573 tests passed. 18 failed (0.00185457%) --- src/hb-ot-shape-complex-indic-machine.hh | 1688 ++++++++++------------ src/hb-ot-shape-complex-indic-machine.rl | 2 +- 2 files changed, 784 insertions(+), 906 deletions(-) diff --git a/src/hb-ot-shape-complex-indic-machine.hh b/src/hb-ot-shape-complex-indic-machine.hh index f67a525c5..351d5970c 100644 --- a/src/hb-ot-shape-complex-indic-machine.hh +++ b/src/hb-ot-shape-complex-indic-machine.hh @@ -34,850 +34,754 @@ #line 36 "hb-ot-shape-complex-indic-machine.hh" static const unsigned char _indic_syllable_machine_trans_keys[] = { - 8u, 8u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, + 8u, 8u, 4u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, - 16u, 16u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, - 4u, 13u, 4u, 8u, 4u, 13u, 8u, 8u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, - 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, - 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, - 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, - 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 8u, 8u, 5u, 8u, - 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, - 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, - 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, - 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, - 8u, 8u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, - 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, - 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, - 16u, 16u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, - 4u, 13u, 4u, 8u, 4u, 13u, 4u, 13u, 5u, 8u, 5u, 8u, 5u, 7u, 5u, 8u, - 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, - 8u, 8u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, - 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 8u, 8u, 1u, 19u, 3u, 17u, + 16u, 16u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, + 4u, 8u, 4u, 13u, 8u, 8u, 4u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, + 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 4u, 8u, + 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, + 4u, 8u, 6u, 6u, 16u, 16u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, + 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 8u, 8u, 4u, 8u, 5u, 7u, 7u, 7u, + 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, + 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, + 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 13u, 4u, 8u, 4u, 13u, + 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, 8u, 8u, 4u, 8u, 5u, 7u, + 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, 5u, 7u, 7u, 7u, 5u, 8u, + 5u, 7u, 7u, 7u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, + 4u, 8u, 6u, 6u, 16u, 16u, 4u, 8u, 6u, 6u, 16u, 16u, 4u, 13u, 4u, 8u, + 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 8u, 4u, 13u, 4u, 13u, + 5u, 8u, 8u, 8u, 1u, 19u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, - 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, - 3u, 17u, 4u, 17u, 5u, 10u, 5u, 10u, 5u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, - 5u, 10u, 3u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, + 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 10u, 5u, 10u, + 5u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 5u, 10u, 3u, 10u, 5u, 10u, 3u, 10u, + 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, + 3u, 10u, 4u, 10u, 4u, 10u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, + 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, + 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, + 3u, 17u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, + 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, + 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 10u, 5u, 10u, 5u, 10u, 10u, 10u, + 10u, 10u, 10u, 10u, 5u, 10u, 3u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, - 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, - 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, - 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, - 3u, 17u, 3u, 17u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, + 4u, 10u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, + 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, + 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 4u, 8u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, - 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 10u, 5u, 10u, 5u, 10u, - 10u, 10u, 10u, 10u, 10u, 10u, 5u, 10u, 3u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, - 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, - 5u, 10u, 3u, 10u, 4u, 10u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, - 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, - 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, - 1u, 16u, 1u, 16u, 1u, 16u, 4u, 8u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, - 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, - 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 5u, 10u, - 5u, 10u, 5u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 5u, 10u, 3u, 10u, 3u, 10u, - 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, - 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 3u, 17u, 3u, 17u, 1u, 16u, + 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, + 4u, 17u, 5u, 10u, 5u, 10u, 5u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 5u, 10u, + 3u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, + 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 4u, 10u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, - 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, - 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 4u, 13u, 3u, 17u, 4u, 8u, - 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, - 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, - 3u, 17u, 3u, 17u, 4u, 17u, 5u, 10u, 5u, 10u, 5u, 10u, 10u, 10u, 10u, 10u, - 10u, 10u, 5u, 10u, 3u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, + 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, + 1u, 16u, 1u, 16u, 4u, 13u, 3u, 17u, 4u, 8u, 3u, 17u, 3u, 17u, 4u, 17u, + 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, + 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, 1u, 16u, 3u, 17u, 3u, 17u, 4u, 17u, + 5u, 10u, 5u, 10u, 5u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 5u, 10u, 3u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, - 4u, 10u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, - 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, - 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, + 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 4u, 10u, 3u, 17u, 3u, 17u, 1u, 16u, + 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, + 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 3u, 17u, 1u, 16u, 1u, 16u, 1u, 16u, 3u, 17u, 1u, 17u, 3u, 17u, 1u, 17u, 4u, 13u, 5u, 10u, 10u, 10u, - 10u, 10u, 10u, 10u, 5u, 10u, 1u, 16u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, - 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, 3u, 10u, 4u, 10u, 5u, 10u, - 3u, 10u, 5u, 10u, 5u, 10u, 10u, 10u, 10u, 10u, 10u, 10u, 5u, 10u, 1u, 16u, - 0 + 10u, 10u, 10u, 10u, 5u, 10u, 1u, 16u, 3u, 10u, 5u, 10u, 5u, 10u, 10u, 10u, + 10u, 10u, 10u, 10u, 5u, 10u, 1u, 16u, 0 }; static const char _indic_syllable_machine_key_spans[] = { - 1, 4, 3, 1, 4, 3, 1, 4, + 1, 5, 3, 1, 4, 3, 1, 4, 3, 1, 4, 3, 1, 5, 1, 1, 5, 1, 1, 5, 1, 1, 5, 1, - 1, 5, 10, 5, 10, 5, 10, 5, - 10, 5, 10, 1, 4, 3, 1, 4, - 3, 1, 4, 3, 1, 4, 3, 1, - 5, 1, 1, 5, 1, 1, 5, 1, - 1, 5, 1, 1, 5, 10, 5, 10, - 5, 10, 5, 10, 5, 10, 1, 4, - 3, 1, 4, 3, 1, 4, 3, 1, - 4, 3, 1, 5, 1, 1, 5, 1, + 1, 10, 5, 10, 5, 10, 5, 10, + 5, 10, 1, 5, 3, 1, 4, 3, + 1, 4, 3, 1, 4, 3, 1, 5, + 1, 1, 5, 1, 1, 5, 1, 1, + 5, 1, 1, 10, 5, 10, 5, 10, + 5, 10, 5, 10, 1, 5, 3, 1, + 4, 3, 1, 4, 3, 1, 4, 3, 1, 5, 1, 1, 5, 1, 1, 5, - 10, 5, 10, 5, 10, 5, 10, 5, + 1, 1, 5, 1, 1, 10, 5, 10, + 5, 10, 5, 10, 5, 1, 5, 3, 1, 4, 3, 1, 4, 3, 1, 4, - 3, 1, 4, 3, 1, 5, 1, 1, - 5, 1, 1, 5, 1, 1, 5, 1, - 1, 5, 10, 5, 10, 5, 10, 5, - 10, 5, 10, 10, 4, 4, 3, 4, - 3, 1, 4, 3, 1, 4, 3, 1, - 1, 5, 1, 1, 5, 1, 1, 5, - 1, 1, 5, 1, 1, 1, 19, 15, + 3, 1, 5, 1, 1, 5, 1, 1, + 5, 1, 1, 5, 1, 1, 10, 5, + 10, 5, 10, 5, 10, 5, 10, 10, + 4, 1, 19, 15, 15, 14, 16, 15, 15, 14, 16, 15, 15, 14, 16, 15, - 15, 14, 16, 15, 15, 14, 16, 15, - 15, 14, 6, 6, 6, 1, 1, 1, - 6, 8, 8, 7, 6, 8, 7, 6, + 15, 14, 16, 15, 15, 14, 6, 6, + 6, 1, 1, 1, 6, 8, 6, 8, + 7, 6, 8, 7, 6, 8, 7, 6, + 8, 7, 7, 15, 15, 16, 16, 16, + 15, 15, 16, 16, 16, 15, 15, 16, + 16, 16, 15, 15, 16, 16, 16, 15, + 15, 15, 15, 14, 16, 15, 15, 14, + 16, 15, 15, 14, 16, 15, 15, 14, + 16, 15, 15, 14, 6, 6, 6, 1, + 1, 1, 6, 8, 6, 8, 7, 6, 8, 7, 6, 8, 7, 6, 8, 7, - 15, 15, 16, 16, 16, 16, 15, 15, - 16, 16, 16, 16, 15, 15, 16, 16, - 16, 16, 15, 15, 16, 16, 16, 16, - 15, 15, 15, 15, 14, 16, 15, 15, + 7, 15, 15, 16, 16, 16, 15, 15, + 16, 16, 16, 15, 15, 16, 16, 16, + 15, 15, 16, 16, 16, 5, 15, 15, 14, 16, 15, 15, 14, 16, 15, 15, - 14, 16, 15, 15, 14, 6, 6, 6, - 1, 1, 1, 6, 8, 8, 7, 6, - 8, 7, 6, 8, 7, 6, 8, 7, - 6, 8, 7, 15, 15, 16, 16, 16, - 16, 15, 15, 16, 16, 16, 16, 15, - 15, 16, 16, 16, 16, 15, 15, 16, - 16, 16, 16, 5, 15, 15, 14, 16, - 15, 15, 14, 16, 15, 15, 14, 16, - 15, 15, 14, 16, 15, 15, 14, 6, - 6, 6, 1, 1, 1, 6, 8, 8, - 7, 6, 8, 7, 6, 8, 7, 6, - 8, 7, 6, 8, 7, 15, 15, 16, + 14, 16, 15, 15, 14, 16, 15, 15, + 14, 6, 6, 6, 1, 1, 1, 6, + 8, 6, 8, 7, 6, 8, 7, 6, + 8, 7, 6, 8, 7, 7, 15, 15, 16, 16, 16, 15, 15, 16, 16, 16, - 16, 15, 15, 16, 16, 16, 16, 15, - 15, 16, 16, 16, 16, 10, 15, 5, - 15, 15, 14, 16, 15, 15, 14, 16, - 15, 15, 14, 16, 15, 15, 14, 16, - 15, 15, 14, 6, 6, 6, 1, 1, - 1, 6, 8, 8, 7, 6, 8, 7, + 15, 15, 16, 16, 16, 15, 15, 16, + 16, 16, 10, 15, 5, 15, 15, 14, + 16, 15, 15, 14, 16, 15, 15, 14, + 16, 15, 15, 14, 16, 15, 15, 14, + 6, 6, 6, 1, 1, 1, 6, 8, 6, 8, 7, 6, 8, 7, 6, 8, - 7, 15, 15, 16, 16, 16, 16, 15, - 15, 16, 16, 16, 16, 15, 15, 16, - 16, 16, 16, 15, 15, 16, 16, 16, + 7, 6, 8, 7, 7, 15, 15, 16, + 16, 16, 15, 15, 16, 16, 16, 15, + 15, 16, 16, 16, 15, 15, 16, 16, 16, 15, 17, 15, 17, 10, 6, 1, - 1, 1, 6, 16, 8, 7, 6, 8, - 7, 6, 8, 7, 6, 8, 7, 6, - 8, 6, 6, 1, 1, 1, 6, 16 + 1, 1, 6, 16, 8, 6, 6, 1, + 1, 1, 6, 16 }; static const short _indic_syllable_machine_index_offsets[] = { - 0, 2, 7, 11, 13, 18, 22, 24, - 29, 33, 35, 40, 44, 46, 52, 54, - 56, 62, 64, 66, 72, 74, 76, 82, - 84, 86, 92, 103, 109, 120, 126, 137, - 143, 154, 160, 171, 173, 178, 182, 184, - 189, 193, 195, 200, 204, 206, 211, 215, - 217, 223, 225, 227, 233, 235, 237, 243, - 245, 247, 253, 255, 257, 263, 274, 280, - 291, 297, 308, 314, 325, 331, 342, 344, - 349, 353, 355, 360, 364, 366, 371, 375, - 377, 382, 386, 388, 394, 396, 398, 404, - 406, 408, 414, 416, 418, 424, 426, 428, - 434, 445, 451, 462, 468, 479, 485, 496, - 502, 504, 509, 513, 515, 520, 524, 526, - 531, 535, 537, 542, 546, 548, 554, 556, - 558, 564, 566, 568, 574, 576, 578, 584, - 586, 588, 594, 605, 611, 622, 628, 639, - 645, 656, 662, 673, 684, 689, 694, 698, - 703, 707, 709, 714, 718, 720, 725, 729, - 731, 733, 739, 741, 743, 749, 751, 753, - 759, 761, 763, 769, 771, 773, 775, 795, - 811, 827, 842, 859, 875, 891, 906, 923, - 939, 955, 970, 987, 1003, 1019, 1034, 1051, - 1067, 1083, 1098, 1105, 1112, 1119, 1121, 1123, - 1125, 1132, 1141, 1150, 1158, 1165, 1174, 1182, - 1189, 1198, 1206, 1213, 1222, 1230, 1237, 1246, - 1254, 1270, 1286, 1303, 1320, 1337, 1354, 1370, - 1386, 1403, 1420, 1437, 1454, 1470, 1486, 1503, - 1520, 1537, 1554, 1570, 1586, 1603, 1620, 1637, - 1654, 1670, 1686, 1702, 1718, 1733, 1750, 1766, - 1782, 1797, 1814, 1830, 1846, 1861, 1878, 1894, - 1910, 1925, 1942, 1958, 1974, 1989, 1996, 2003, - 2010, 2012, 2014, 2016, 2023, 2032, 2041, 2049, - 2056, 2065, 2073, 2080, 2089, 2097, 2104, 2113, - 2121, 2128, 2137, 2145, 2161, 2177, 2194, 2211, - 2228, 2245, 2261, 2277, 2294, 2311, 2328, 2345, - 2361, 2377, 2394, 2411, 2428, 2445, 2461, 2477, - 2494, 2511, 2528, 2545, 2551, 2567, 2583, 2598, - 2615, 2631, 2647, 2662, 2679, 2695, 2711, 2726, - 2743, 2759, 2775, 2790, 2807, 2823, 2839, 2854, - 2861, 2868, 2875, 2877, 2879, 2881, 2888, 2897, - 2906, 2914, 2921, 2930, 2938, 2945, 2954, 2962, - 2969, 2978, 2986, 2993, 3002, 3010, 3026, 3042, - 3059, 3076, 3093, 3110, 3126, 3142, 3159, 3176, - 3193, 3210, 3226, 3242, 3259, 3276, 3293, 3310, - 3326, 3342, 3359, 3376, 3393, 3410, 3421, 3437, - 3443, 3459, 3475, 3490, 3507, 3523, 3539, 3554, - 3571, 3587, 3603, 3618, 3635, 3651, 3667, 3682, - 3699, 3715, 3731, 3746, 3753, 3760, 3767, 3769, - 3771, 3773, 3780, 3789, 3798, 3806, 3813, 3822, - 3830, 3837, 3846, 3854, 3861, 3870, 3878, 3885, - 3894, 3902, 3918, 3934, 3951, 3968, 3985, 4002, - 4018, 4034, 4051, 4068, 4085, 4102, 4118, 4134, - 4151, 4168, 4185, 4202, 4218, 4234, 4251, 4268, - 4285, 4302, 4318, 4336, 4352, 4370, 4381, 4388, - 4390, 4392, 4394, 4401, 4418, 4427, 4435, 4442, - 4451, 4459, 4466, 4475, 4483, 4490, 4499, 4507, - 4514, 4523, 4530, 4537, 4539, 4541, 4543, 4550 + 0, 2, 8, 12, 14, 19, 23, 25, + 30, 34, 36, 41, 45, 47, 53, 55, + 57, 63, 65, 67, 73, 75, 77, 83, + 85, 87, 98, 104, 115, 121, 132, 138, + 149, 155, 166, 168, 174, 178, 180, 185, + 189, 191, 196, 200, 202, 207, 211, 213, + 219, 221, 223, 229, 231, 233, 239, 241, + 243, 249, 251, 253, 264, 270, 281, 287, + 298, 304, 315, 321, 332, 334, 340, 344, + 346, 351, 355, 357, 362, 366, 368, 373, + 377, 379, 385, 387, 389, 395, 397, 399, + 405, 407, 409, 415, 417, 419, 430, 436, + 447, 453, 464, 470, 481, 487, 489, 495, + 499, 501, 506, 510, 512, 517, 521, 523, + 528, 532, 534, 540, 542, 544, 550, 552, + 554, 560, 562, 564, 570, 572, 574, 585, + 591, 602, 608, 619, 625, 636, 642, 653, + 664, 669, 671, 691, 707, 723, 738, 755, + 771, 787, 802, 819, 835, 851, 866, 883, + 899, 915, 930, 947, 963, 979, 994, 1001, + 1008, 1015, 1017, 1019, 1021, 1028, 1037, 1044, + 1053, 1061, 1068, 1077, 1085, 1092, 1101, 1109, + 1116, 1125, 1133, 1141, 1157, 1173, 1190, 1207, + 1224, 1240, 1256, 1273, 1290, 1307, 1323, 1339, + 1356, 1373, 1390, 1406, 1422, 1439, 1456, 1473, + 1489, 1505, 1521, 1537, 1552, 1569, 1585, 1601, + 1616, 1633, 1649, 1665, 1680, 1697, 1713, 1729, + 1744, 1761, 1777, 1793, 1808, 1815, 1822, 1829, + 1831, 1833, 1835, 1842, 1851, 1858, 1867, 1875, + 1882, 1891, 1899, 1906, 1915, 1923, 1930, 1939, + 1947, 1955, 1971, 1987, 2004, 2021, 2038, 2054, + 2070, 2087, 2104, 2121, 2137, 2153, 2170, 2187, + 2204, 2220, 2236, 2253, 2270, 2287, 2293, 2309, + 2325, 2340, 2357, 2373, 2389, 2404, 2421, 2437, + 2453, 2468, 2485, 2501, 2517, 2532, 2549, 2565, + 2581, 2596, 2603, 2610, 2617, 2619, 2621, 2623, + 2630, 2639, 2646, 2655, 2663, 2670, 2679, 2687, + 2694, 2703, 2711, 2718, 2727, 2735, 2743, 2759, + 2775, 2792, 2809, 2826, 2842, 2858, 2875, 2892, + 2909, 2925, 2941, 2958, 2975, 2992, 3008, 3024, + 3041, 3058, 3075, 3086, 3102, 3108, 3124, 3140, + 3155, 3172, 3188, 3204, 3219, 3236, 3252, 3268, + 3283, 3300, 3316, 3332, 3347, 3364, 3380, 3396, + 3411, 3418, 3425, 3432, 3434, 3436, 3438, 3445, + 3454, 3461, 3470, 3478, 3485, 3494, 3502, 3509, + 3518, 3526, 3533, 3542, 3550, 3558, 3574, 3590, + 3607, 3624, 3641, 3657, 3673, 3690, 3707, 3724, + 3740, 3756, 3773, 3790, 3807, 3823, 3839, 3856, + 3873, 3890, 3906, 3924, 3940, 3958, 3969, 3976, + 3978, 3980, 3982, 3989, 4006, 4015, 4022, 4029, + 4031, 4033, 4035, 4042 }; static const short _indic_syllable_machine_indicies[] = { - 1, 0, 2, 2, 3, 1, 0, 4, - 4, 3, 0, 3, 0, 5, 5, 6, - 1, 0, 7, 7, 6, 0, 6, 0, - 8, 8, 9, 1, 0, 10, 10, 9, - 0, 9, 0, 11, 11, 12, 1, 0, - 13, 13, 12, 0, 12, 0, 14, 0, - 0, 0, 1, 0, 15, 0, 16, 0, - 17, 11, 11, 12, 1, 0, 18, 0, - 19, 0, 20, 8, 8, 9, 1, 0, - 21, 0, 22, 0, 23, 5, 5, 6, - 1, 0, 24, 0, 25, 0, 26, 2, - 2, 3, 1, 0, 26, 2, 2, 3, - 1, 0, 0, 0, 0, 27, 0, 28, - 2, 2, 3, 1, 0, 28, 2, 2, - 3, 1, 0, 0, 0, 0, 29, 0, - 30, 2, 2, 3, 1, 0, 30, 2, - 2, 3, 1, 0, 0, 0, 0, 31, - 0, 32, 2, 2, 3, 1, 0, 32, - 2, 2, 3, 1, 0, 0, 0, 0, - 33, 0, 34, 2, 2, 3, 1, 0, - 34, 2, 2, 3, 1, 0, 0, 0, - 0, 35, 0, 37, 36, 38, 38, 39, - 37, 36, 40, 40, 39, 36, 39, 36, - 41, 41, 42, 37, 36, 43, 43, 42, - 36, 42, 36, 44, 44, 45, 37, 36, - 46, 46, 45, 36, 45, 36, 47, 47, - 48, 37, 36, 49, 49, 48, 36, 48, - 36, 50, 36, 36, 36, 37, 36, 51, - 36, 52, 36, 53, 47, 47, 48, 37, - 36, 54, 36, 55, 36, 56, 44, 44, - 45, 37, 36, 57, 36, 58, 36, 59, - 41, 41, 42, 37, 36, 60, 36, 61, - 36, 62, 38, 38, 39, 37, 36, 62, - 38, 38, 39, 37, 36, 36, 36, 36, - 63, 36, 64, 38, 38, 39, 37, 36, - 64, 38, 38, 39, 37, 36, 36, 36, - 36, 65, 36, 66, 38, 38, 39, 37, - 36, 66, 38, 38, 39, 37, 36, 36, - 36, 36, 67, 36, 68, 38, 38, 39, - 37, 36, 68, 38, 38, 39, 37, 36, - 36, 36, 36, 69, 36, 70, 38, 38, - 39, 37, 36, 70, 38, 38, 39, 37, - 36, 36, 36, 36, 71, 36, 73, 72, - 74, 74, 75, 73, 72, 77, 77, 75, - 76, 75, 76, 78, 78, 79, 73, 72, - 80, 80, 79, 72, 79, 72, 81, 81, - 82, 73, 72, 83, 83, 82, 72, 82, - 72, 84, 84, 85, 73, 72, 86, 86, - 85, 72, 85, 72, 87, 72, 72, 72, - 73, 72, 88, 72, 89, 72, 90, 84, - 84, 85, 73, 72, 91, 72, 92, 72, - 93, 81, 81, 82, 73, 72, 94, 72, - 95, 72, 96, 78, 78, 79, 73, 72, - 97, 72, 98, 72, 99, 74, 74, 75, - 73, 72, 99, 74, 74, 75, 73, 72, - 72, 72, 72, 100, 72, 101, 74, 74, - 75, 73, 72, 101, 74, 74, 75, 73, - 72, 72, 72, 72, 102, 72, 103, 74, - 74, 75, 73, 72, 103, 74, 74, 75, - 73, 72, 72, 72, 72, 104, 72, 105, - 74, 74, 75, 73, 72, 105, 74, 74, - 75, 73, 72, 72, 72, 72, 106, 72, - 107, 74, 74, 75, 73, 72, 109, 108, - 110, 110, 111, 109, 108, 112, 112, 111, - 108, 111, 108, 113, 113, 114, 109, 108, - 115, 115, 114, 108, 114, 108, 116, 116, - 117, 109, 108, 118, 118, 117, 108, 117, - 108, 119, 119, 120, 109, 108, 121, 121, - 120, 108, 120, 108, 122, 108, 108, 108, - 109, 108, 123, 108, 124, 108, 125, 119, - 119, 120, 109, 108, 126, 108, 127, 108, - 128, 116, 116, 117, 109, 108, 129, 108, - 130, 108, 131, 113, 113, 114, 109, 108, - 132, 108, 133, 108, 134, 110, 110, 111, - 109, 108, 134, 110, 110, 111, 109, 108, - 108, 108, 108, 135, 108, 136, 110, 110, - 111, 109, 108, 136, 110, 110, 111, 109, - 108, 108, 108, 108, 137, 108, 138, 110, - 110, 111, 109, 108, 138, 110, 110, 111, - 109, 108, 108, 108, 108, 139, 108, 140, - 110, 110, 111, 109, 108, 140, 110, 110, - 111, 109, 108, 108, 108, 108, 141, 108, - 142, 110, 110, 111, 109, 108, 142, 110, - 110, 111, 109, 108, 108, 108, 108, 143, - 108, 107, 74, 74, 75, 73, 72, 72, - 72, 72, 144, 72, 77, 77, 75, 1, - 0, 145, 145, 146, 1, 0, 4, 4, - 146, 0, 147, 147, 148, 149, 0, 150, - 150, 148, 0, 148, 0, 151, 151, 152, - 149, 0, 153, 153, 152, 0, 152, 0, - 154, 154, 155, 149, 0, 156, 156, 155, - 0, 155, 0, 149, 0, 157, 0, 0, - 0, 149, 0, 158, 0, 159, 0, 160, - 154, 154, 155, 149, 0, 161, 0, 162, - 0, 163, 151, 151, 152, 149, 0, 164, - 0, 165, 0, 166, 147, 147, 148, 149, - 0, 167, 0, 168, 0, 170, 169, 172, - 173, 174, 175, 176, 177, 75, 73, 171, - 178, 179, 179, 144, 171, 180, 181, 182, - 183, 184, 171, 186, 187, 188, 189, 3, - 1, 185, 190, 185, 185, 35, 185, 185, - 185, 191, 185, 192, 187, 193, 193, 3, - 1, 185, 190, 185, 185, 185, 185, 185, - 185, 191, 185, 187, 193, 193, 3, 1, - 185, 190, 185, 185, 185, 185, 185, 185, - 191, 185, 194, 185, 185, 185, 16, 195, - 185, 1, 185, 190, 185, 185, 185, 185, - 185, 194, 185, 196, 197, 198, 199, 3, - 1, 185, 190, 185, 185, 33, 185, 185, - 185, 191, 185, 200, 197, 201, 201, 3, - 1, 185, 190, 185, 185, 185, 185, 185, - 185, 191, 185, 197, 201, 201, 3, 1, - 185, 190, 185, 185, 185, 185, 185, 185, - 191, 185, 202, 185, 185, 185, 16, 203, - 185, 1, 185, 190, 185, 185, 185, 185, - 185, 202, 185, 204, 205, 206, 207, 3, - 1, 185, 190, 185, 185, 31, 185, 185, - 185, 191, 185, 208, 205, 209, 209, 3, - 1, 185, 190, 185, 185, 185, 185, 185, - 185, 191, 185, 205, 209, 209, 3, 1, - 185, 190, 185, 185, 185, 185, 185, 185, - 191, 185, 210, 185, 185, 185, 16, 211, - 185, 1, 185, 190, 185, 185, 185, 185, - 185, 210, 185, 212, 213, 214, 215, 3, - 1, 185, 190, 185, 185, 29, 185, 185, - 185, 191, 185, 216, 213, 217, 217, 3, - 1, 185, 190, 185, 185, 185, 185, 185, - 185, 191, 185, 213, 217, 217, 3, 1, - 185, 190, 185, 185, 185, 185, 185, 185, - 191, 185, 218, 185, 185, 185, 16, 219, - 185, 1, 185, 190, 185, 185, 185, 185, - 185, 218, 185, 220, 221, 222, 223, 3, - 1, 185, 190, 185, 185, 27, 185, 185, - 185, 191, 185, 224, 221, 225, 225, 3, - 1, 185, 190, 185, 185, 185, 185, 185, - 185, 191, 185, 221, 225, 225, 3, 1, - 185, 190, 185, 185, 185, 185, 185, 185, - 191, 185, 16, 226, 185, 1, 185, 190, - 185, 227, 227, 185, 1, 185, 190, 185, - 228, 185, 185, 229, 185, 190, 185, 190, - 185, 230, 185, 231, 185, 228, 185, 185, - 185, 185, 190, 185, 16, 185, 232, 232, - 3, 1, 185, 190, 185, 233, 25, 234, - 235, 6, 1, 185, 190, 185, 25, 234, - 235, 6, 1, 185, 190, 185, 234, 234, - 6, 1, 185, 190, 185, 236, 22, 237, - 238, 9, 1, 185, 190, 185, 22, 237, - 238, 9, 1, 185, 190, 185, 237, 237, - 9, 1, 185, 190, 185, 239, 19, 240, - 241, 12, 1, 185, 190, 185, 19, 240, - 241, 12, 1, 185, 190, 185, 240, 240, - 12, 1, 185, 190, 185, 242, 16, 227, - 243, 185, 1, 185, 190, 185, 16, 227, - 243, 185, 1, 185, 190, 185, 227, 244, - 185, 1, 185, 190, 185, 16, 185, 227, - 227, 185, 1, 185, 190, 185, 221, 225, - 225, 3, 1, 185, 190, 185, 220, 221, - 225, 225, 3, 1, 185, 190, 185, 185, - 185, 185, 185, 185, 191, 185, 220, 221, - 222, 225, 3, 1, 185, 190, 185, 185, - 27, 185, 185, 185, 191, 185, 218, 185, - 245, 185, 232, 232, 3, 1, 185, 190, - 185, 185, 185, 185, 185, 218, 185, 218, - 185, 185, 185, 227, 227, 185, 1, 185, - 190, 185, 185, 185, 185, 185, 218, 185, - 218, 185, 185, 185, 227, 246, 185, 1, - 185, 190, 185, 185, 185, 185, 185, 218, - 185, 218, 185, 245, 185, 227, 227, 185, - 1, 185, 190, 185, 185, 185, 185, 185, - 218, 185, 212, 213, 217, 217, 3, 1, - 185, 190, 185, 185, 185, 185, 185, 185, - 191, 185, 212, 213, 214, 217, 3, 1, - 185, 190, 185, 185, 29, 185, 185, 185, - 191, 185, 210, 185, 247, 185, 232, 232, - 3, 1, 185, 190, 185, 185, 185, 185, - 185, 210, 185, 210, 185, 185, 185, 227, - 227, 185, 1, 185, 190, 185, 185, 185, - 185, 185, 210, 185, 210, 185, 185, 185, - 227, 248, 185, 1, 185, 190, 185, 185, - 185, 185, 185, 210, 185, 210, 185, 247, - 185, 227, 227, 185, 1, 185, 190, 185, - 185, 185, 185, 185, 210, 185, 204, 205, - 209, 209, 3, 1, 185, 190, 185, 185, - 185, 185, 185, 185, 191, 185, 204, 205, - 206, 209, 3, 1, 185, 190, 185, 185, - 31, 185, 185, 185, 191, 185, 202, 185, - 249, 185, 232, 232, 3, 1, 185, 190, - 185, 185, 185, 185, 185, 202, 185, 202, - 185, 185, 185, 227, 227, 185, 1, 185, - 190, 185, 185, 185, 185, 185, 202, 185, - 202, 185, 185, 185, 227, 250, 185, 1, - 185, 190, 185, 185, 185, 185, 185, 202, - 185, 202, 185, 249, 185, 227, 227, 185, - 1, 185, 190, 185, 185, 185, 185, 185, - 202, 185, 196, 197, 201, 201, 3, 1, - 185, 190, 185, 185, 185, 185, 185, 185, - 191, 185, 196, 197, 198, 201, 3, 1, - 185, 190, 185, 185, 33, 185, 185, 185, - 191, 185, 194, 185, 251, 185, 232, 232, - 3, 1, 185, 190, 185, 185, 185, 185, - 185, 194, 185, 194, 185, 185, 185, 227, - 227, 185, 1, 185, 190, 185, 185, 185, - 185, 185, 194, 185, 194, 185, 185, 185, - 227, 252, 185, 1, 185, 190, 185, 185, - 185, 185, 185, 194, 185, 194, 185, 251, - 185, 227, 227, 185, 1, 185, 190, 185, - 185, 185, 185, 185, 194, 185, 186, 187, - 193, 193, 3, 1, 185, 190, 185, 185, - 185, 185, 185, 185, 191, 185, 186, 187, - 188, 193, 3, 1, 185, 190, 185, 185, - 35, 185, 185, 185, 191, 185, 254, 255, - 256, 257, 39, 37, 253, 258, 253, 253, - 71, 253, 253, 253, 259, 253, 260, 255, - 261, 257, 39, 37, 253, 258, 253, 253, - 253, 253, 253, 253, 259, 253, 255, 261, - 257, 39, 37, 253, 258, 253, 253, 253, - 253, 253, 253, 259, 253, 262, 253, 253, - 253, 52, 263, 253, 37, 253, 258, 253, - 253, 253, 253, 253, 262, 253, 264, 265, - 266, 267, 39, 37, 253, 258, 253, 253, - 69, 253, 253, 253, 259, 253, 268, 265, - 269, 269, 39, 37, 253, 258, 253, 253, - 253, 253, 253, 253, 259, 253, 265, 269, - 269, 39, 37, 253, 258, 253, 253, 253, - 253, 253, 253, 259, 253, 270, 253, 253, - 253, 52, 271, 253, 37, 253, 258, 253, - 253, 253, 253, 253, 270, 253, 272, 273, - 274, 275, 39, 37, 253, 258, 253, 253, - 67, 253, 253, 253, 259, 253, 276, 273, - 277, 277, 39, 37, 253, 258, 253, 253, - 253, 253, 253, 253, 259, 253, 273, 277, - 277, 39, 37, 253, 258, 253, 253, 253, - 253, 253, 253, 259, 253, 278, 253, 253, - 253, 52, 279, 253, 37, 253, 258, 253, - 253, 253, 253, 253, 278, 253, 280, 281, - 282, 283, 39, 37, 253, 258, 253, 253, - 65, 253, 253, 253, 259, 253, 284, 281, - 285, 285, 39, 37, 253, 258, 253, 253, - 253, 253, 253, 253, 259, 253, 281, 285, - 285, 39, 37, 253, 258, 253, 253, 253, - 253, 253, 253, 259, 253, 286, 253, 253, - 253, 52, 287, 253, 37, 253, 258, 253, - 253, 253, 253, 253, 286, 253, 288, 289, - 290, 291, 39, 37, 253, 258, 253, 253, - 63, 253, 253, 253, 259, 253, 292, 289, - 293, 293, 39, 37, 253, 258, 253, 253, - 253, 253, 253, 253, 259, 253, 289, 293, - 293, 39, 37, 253, 258, 253, 253, 253, - 253, 253, 253, 259, 253, 52, 294, 253, - 37, 253, 258, 253, 295, 295, 253, 37, - 253, 258, 253, 296, 253, 253, 297, 253, - 258, 253, 258, 253, 298, 253, 299, 253, - 296, 253, 253, 253, 253, 258, 253, 52, - 253, 300, 300, 39, 37, 253, 258, 253, - 301, 61, 302, 303, 42, 37, 253, 258, - 253, 61, 302, 303, 42, 37, 253, 258, - 253, 302, 302, 42, 37, 253, 258, 253, - 304, 58, 305, 306, 45, 37, 253, 258, - 253, 58, 305, 306, 45, 37, 253, 258, - 253, 305, 305, 45, 37, 253, 258, 253, - 307, 55, 308, 309, 48, 37, 253, 258, - 253, 55, 308, 309, 48, 37, 253, 258, - 253, 308, 308, 48, 37, 253, 258, 253, - 310, 52, 295, 311, 253, 37, 253, 258, - 253, 52, 295, 311, 253, 37, 253, 258, - 253, 295, 312, 253, 37, 253, 258, 253, - 52, 253, 295, 295, 253, 37, 253, 258, - 253, 289, 293, 293, 39, 37, 253, 258, - 253, 288, 289, 293, 293, 39, 37, 253, - 258, 253, 253, 253, 253, 253, 253, 259, - 253, 288, 289, 290, 293, 39, 37, 253, - 258, 253, 253, 63, 253, 253, 253, 259, - 253, 286, 253, 313, 253, 300, 300, 39, - 37, 253, 258, 253, 253, 253, 253, 253, - 286, 253, 286, 253, 253, 253, 295, 295, - 253, 37, 253, 258, 253, 253, 253, 253, - 253, 286, 253, 286, 253, 253, 253, 295, - 314, 253, 37, 253, 258, 253, 253, 253, - 253, 253, 286, 253, 286, 253, 313, 253, - 295, 295, 253, 37, 253, 258, 253, 253, - 253, 253, 253, 286, 253, 280, 281, 285, - 285, 39, 37, 253, 258, 253, 253, 253, - 253, 253, 253, 259, 253, 280, 281, 282, - 285, 39, 37, 253, 258, 253, 253, 65, - 253, 253, 253, 259, 253, 278, 253, 315, - 253, 300, 300, 39, 37, 253, 258, 253, - 253, 253, 253, 253, 278, 253, 278, 253, - 253, 253, 295, 295, 253, 37, 253, 258, - 253, 253, 253, 253, 253, 278, 253, 278, - 253, 253, 253, 295, 316, 253, 37, 253, - 258, 253, 253, 253, 253, 253, 278, 253, - 278, 253, 315, 253, 295, 295, 253, 37, - 253, 258, 253, 253, 253, 253, 253, 278, - 253, 272, 273, 277, 277, 39, 37, 253, - 258, 253, 253, 253, 253, 253, 253, 259, - 253, 272, 273, 274, 277, 39, 37, 253, - 258, 253, 253, 67, 253, 253, 253, 259, - 253, 270, 253, 317, 253, 300, 300, 39, - 37, 253, 258, 253, 253, 253, 253, 253, - 270, 253, 270, 253, 253, 253, 295, 295, - 253, 37, 253, 258, 253, 253, 253, 253, - 253, 270, 253, 270, 253, 253, 253, 295, - 318, 253, 37, 253, 258, 253, 253, 253, - 253, 253, 270, 253, 270, 253, 317, 253, - 295, 295, 253, 37, 253, 258, 253, 253, - 253, 253, 253, 270, 253, 264, 265, 269, - 269, 39, 37, 253, 258, 253, 253, 253, - 253, 253, 253, 259, 253, 264, 265, 266, - 269, 39, 37, 253, 258, 253, 253, 69, - 253, 253, 253, 259, 253, 262, 253, 319, - 253, 300, 300, 39, 37, 253, 258, 253, - 253, 253, 253, 253, 262, 253, 262, 253, - 253, 253, 295, 295, 253, 37, 253, 258, - 253, 253, 253, 253, 253, 262, 253, 262, - 253, 253, 253, 295, 320, 253, 37, 253, - 258, 253, 253, 253, 253, 253, 262, 253, - 262, 253, 319, 253, 295, 295, 253, 37, - 253, 258, 253, 253, 253, 253, 253, 262, - 253, 70, 38, 38, 39, 37, 253, 254, - 255, 261, 257, 39, 37, 253, 258, 253, - 253, 253, 253, 253, 253, 259, 253, 322, - 175, 323, 323, 75, 73, 321, 178, 321, - 321, 321, 321, 321, 321, 182, 321, 175, - 323, 323, 75, 73, 321, 178, 321, 321, - 321, 321, 321, 321, 182, 321, 324, 321, - 321, 321, 89, 325, 321, 73, 321, 178, - 321, 321, 321, 321, 321, 324, 321, 326, - 327, 328, 329, 75, 73, 321, 178, 321, - 321, 106, 321, 321, 321, 182, 321, 330, - 327, 331, 331, 75, 73, 321, 178, 321, - 321, 321, 321, 321, 321, 182, 321, 327, - 331, 331, 75, 73, 321, 178, 321, 321, - 321, 321, 321, 321, 182, 321, 332, 321, - 321, 321, 89, 333, 321, 73, 321, 178, - 321, 321, 321, 321, 321, 332, 321, 334, - 335, 336, 337, 75, 73, 321, 178, 321, - 321, 104, 321, 321, 321, 182, 321, 338, - 335, 339, 339, 75, 73, 321, 178, 321, - 321, 321, 321, 321, 321, 182, 321, 335, - 339, 339, 75, 73, 321, 178, 321, 321, - 321, 321, 321, 321, 182, 321, 340, 321, - 321, 321, 89, 341, 321, 73, 321, 178, - 321, 321, 321, 321, 321, 340, 321, 342, - 343, 344, 345, 75, 73, 321, 178, 321, - 321, 102, 321, 321, 321, 182, 321, 346, - 343, 347, 347, 75, 73, 321, 178, 321, - 321, 321, 321, 321, 321, 182, 321, 343, - 347, 347, 75, 73, 321, 178, 321, 321, - 321, 321, 321, 321, 182, 321, 348, 321, - 321, 321, 89, 349, 321, 73, 321, 178, - 321, 321, 321, 321, 321, 348, 321, 350, - 351, 352, 353, 75, 73, 321, 178, 321, - 321, 100, 321, 321, 321, 182, 321, 354, - 351, 355, 355, 75, 73, 321, 178, 321, - 321, 321, 321, 321, 321, 182, 321, 351, - 355, 355, 75, 73, 321, 178, 321, 321, - 321, 321, 321, 321, 182, 321, 89, 356, - 321, 73, 321, 178, 321, 357, 357, 321, - 73, 321, 178, 321, 358, 321, 321, 359, - 321, 178, 321, 178, 321, 360, 321, 361, - 321, 358, 321, 321, 321, 321, 178, 321, - 89, 321, 362, 362, 75, 73, 321, 178, - 321, 363, 98, 364, 365, 79, 73, 321, - 178, 321, 98, 364, 365, 79, 73, 321, - 178, 321, 364, 364, 79, 73, 321, 178, - 321, 366, 95, 367, 368, 82, 73, 321, - 178, 321, 95, 367, 368, 82, 73, 321, - 178, 321, 367, 367, 82, 73, 321, 178, - 321, 369, 92, 370, 371, 85, 73, 321, - 178, 321, 92, 370, 371, 85, 73, 321, - 178, 321, 370, 370, 85, 73, 321, 178, - 321, 372, 89, 357, 373, 321, 73, 321, - 178, 321, 89, 357, 373, 321, 73, 321, - 178, 321, 357, 374, 321, 73, 321, 178, - 321, 89, 321, 357, 357, 321, 73, 321, - 178, 321, 351, 355, 355, 75, 73, 321, - 178, 321, 350, 351, 355, 355, 75, 73, - 321, 178, 321, 321, 321, 321, 321, 321, - 182, 321, 350, 351, 352, 355, 75, 73, - 321, 178, 321, 321, 100, 321, 321, 321, - 182, 321, 348, 321, 375, 321, 362, 362, - 75, 73, 321, 178, 321, 321, 321, 321, - 321, 348, 321, 348, 321, 321, 321, 357, - 357, 321, 73, 321, 178, 321, 321, 321, - 321, 321, 348, 321, 348, 321, 321, 321, - 357, 376, 321, 73, 321, 178, 321, 321, - 321, 321, 321, 348, 321, 348, 321, 375, - 321, 357, 357, 321, 73, 321, 178, 321, - 321, 321, 321, 321, 348, 321, 342, 343, - 347, 347, 75, 73, 321, 178, 321, 321, - 321, 321, 321, 321, 182, 321, 342, 343, - 344, 347, 75, 73, 321, 178, 321, 321, - 102, 321, 321, 321, 182, 321, 340, 321, - 377, 321, 362, 362, 75, 73, 321, 178, - 321, 321, 321, 321, 321, 340, 321, 340, - 321, 321, 321, 357, 357, 321, 73, 321, - 178, 321, 321, 321, 321, 321, 340, 321, - 340, 321, 321, 321, 357, 378, 321, 73, - 321, 178, 321, 321, 321, 321, 321, 340, - 321, 340, 321, 377, 321, 357, 357, 321, - 73, 321, 178, 321, 321, 321, 321, 321, - 340, 321, 334, 335, 339, 339, 75, 73, - 321, 178, 321, 321, 321, 321, 321, 321, - 182, 321, 334, 335, 336, 339, 75, 73, - 321, 178, 321, 321, 104, 321, 321, 321, - 182, 321, 332, 321, 379, 321, 362, 362, - 75, 73, 321, 178, 321, 321, 321, 321, - 321, 332, 321, 332, 321, 321, 321, 357, - 357, 321, 73, 321, 178, 321, 321, 321, - 321, 321, 332, 321, 332, 321, 321, 321, - 357, 380, 321, 73, 321, 178, 321, 321, - 321, 321, 321, 332, 321, 332, 321, 379, - 321, 357, 357, 321, 73, 321, 178, 321, - 321, 321, 321, 321, 332, 321, 326, 327, - 331, 331, 75, 73, 321, 178, 321, 321, - 321, 321, 321, 321, 182, 321, 326, 327, - 328, 331, 75, 73, 321, 178, 321, 321, - 106, 321, 321, 321, 182, 321, 324, 321, - 381, 321, 362, 362, 75, 73, 321, 178, - 321, 321, 321, 321, 321, 324, 321, 324, - 321, 321, 321, 357, 357, 321, 73, 321, - 178, 321, 321, 321, 321, 321, 324, 321, - 324, 321, 321, 321, 357, 382, 321, 73, - 321, 178, 321, 321, 321, 321, 321, 324, - 321, 324, 321, 381, 321, 357, 357, 321, - 73, 321, 178, 321, 321, 321, 321, 321, - 324, 321, 107, 74, 74, 75, 73, 383, - 383, 383, 383, 144, 383, 174, 175, 323, - 323, 75, 73, 321, 178, 321, 321, 321, - 321, 321, 321, 182, 321, 107, 74, 74, - 75, 73, 383, 385, 386, 387, 388, 111, - 109, 384, 389, 384, 384, 143, 384, 384, - 384, 390, 384, 391, 386, 388, 388, 111, - 109, 384, 389, 384, 384, 384, 384, 384, - 384, 390, 384, 386, 388, 388, 111, 109, - 384, 389, 384, 384, 384, 384, 384, 384, - 390, 384, 392, 384, 384, 384, 124, 393, - 384, 109, 384, 389, 384, 384, 384, 384, - 384, 392, 384, 394, 395, 396, 397, 111, - 109, 384, 389, 384, 384, 141, 384, 384, - 384, 390, 384, 398, 395, 399, 399, 111, - 109, 384, 389, 384, 384, 384, 384, 384, - 384, 390, 384, 395, 399, 399, 111, 109, - 384, 389, 384, 384, 384, 384, 384, 384, - 390, 384, 400, 384, 384, 384, 124, 401, - 384, 109, 384, 389, 384, 384, 384, 384, - 384, 400, 384, 402, 403, 404, 405, 111, - 109, 384, 389, 384, 384, 139, 384, 384, - 384, 390, 384, 406, 403, 407, 407, 111, - 109, 384, 389, 384, 384, 384, 384, 384, - 384, 390, 384, 403, 407, 407, 111, 109, - 384, 389, 384, 384, 384, 384, 384, 384, - 390, 384, 408, 384, 384, 384, 124, 409, - 384, 109, 384, 389, 384, 384, 384, 384, - 384, 408, 384, 410, 411, 412, 413, 111, - 109, 384, 389, 384, 384, 137, 384, 384, - 384, 390, 384, 414, 411, 415, 415, 111, - 109, 384, 389, 384, 384, 384, 384, 384, - 384, 390, 384, 411, 415, 415, 111, 109, - 384, 389, 384, 384, 384, 384, 384, 384, - 390, 384, 416, 384, 384, 384, 124, 417, - 384, 109, 384, 389, 384, 384, 384, 384, - 384, 416, 384, 418, 419, 420, 421, 111, - 109, 384, 389, 384, 384, 135, 384, 384, - 384, 390, 384, 422, 419, 423, 423, 111, - 109, 384, 389, 384, 384, 384, 384, 384, - 384, 390, 384, 419, 423, 423, 111, 109, - 384, 389, 384, 384, 384, 384, 384, 384, - 390, 384, 124, 424, 384, 109, 384, 389, - 384, 425, 425, 384, 109, 384, 389, 384, - 426, 384, 384, 427, 384, 389, 384, 389, - 384, 428, 384, 429, 384, 426, 384, 384, - 384, 384, 389, 384, 124, 384, 430, 430, - 111, 109, 384, 389, 384, 431, 133, 432, - 433, 114, 109, 384, 389, 384, 133, 432, - 433, 114, 109, 384, 389, 384, 432, 432, - 114, 109, 384, 389, 384, 434, 130, 435, - 436, 117, 109, 384, 389, 384, 130, 435, - 436, 117, 109, 384, 389, 384, 435, 435, - 117, 109, 384, 389, 384, 437, 127, 438, - 439, 120, 109, 384, 389, 384, 127, 438, - 439, 120, 109, 384, 389, 384, 438, 438, - 120, 109, 384, 389, 384, 440, 124, 425, - 441, 384, 109, 384, 389, 384, 124, 425, - 441, 384, 109, 384, 389, 384, 425, 442, - 384, 109, 384, 389, 384, 124, 384, 425, - 425, 384, 109, 384, 389, 384, 419, 423, - 423, 111, 109, 384, 389, 384, 418, 419, - 423, 423, 111, 109, 384, 389, 384, 384, - 384, 384, 384, 384, 390, 384, 418, 419, - 420, 423, 111, 109, 384, 389, 384, 384, - 135, 384, 384, 384, 390, 384, 416, 384, - 443, 384, 430, 430, 111, 109, 384, 389, - 384, 384, 384, 384, 384, 416, 384, 416, - 384, 384, 384, 425, 425, 384, 109, 384, - 389, 384, 384, 384, 384, 384, 416, 384, - 416, 384, 384, 384, 425, 444, 384, 109, - 384, 389, 384, 384, 384, 384, 384, 416, - 384, 416, 384, 443, 384, 425, 425, 384, - 109, 384, 389, 384, 384, 384, 384, 384, - 416, 384, 410, 411, 415, 415, 111, 109, - 384, 389, 384, 384, 384, 384, 384, 384, - 390, 384, 410, 411, 412, 415, 111, 109, - 384, 389, 384, 384, 137, 384, 384, 384, - 390, 384, 408, 384, 445, 384, 430, 430, - 111, 109, 384, 389, 384, 384, 384, 384, - 384, 408, 384, 408, 384, 384, 384, 425, - 425, 384, 109, 384, 389, 384, 384, 384, - 384, 384, 408, 384, 408, 384, 384, 384, - 425, 446, 384, 109, 384, 389, 384, 384, - 384, 384, 384, 408, 384, 408, 384, 445, - 384, 425, 425, 384, 109, 384, 389, 384, - 384, 384, 384, 384, 408, 384, 402, 403, - 407, 407, 111, 109, 384, 389, 384, 384, - 384, 384, 384, 384, 390, 384, 402, 403, - 404, 407, 111, 109, 384, 389, 384, 384, - 139, 384, 384, 384, 390, 384, 400, 384, - 447, 384, 430, 430, 111, 109, 384, 389, - 384, 384, 384, 384, 384, 400, 384, 400, - 384, 384, 384, 425, 425, 384, 109, 384, - 389, 384, 384, 384, 384, 384, 400, 384, - 400, 384, 384, 384, 425, 448, 384, 109, - 384, 389, 384, 384, 384, 384, 384, 400, - 384, 400, 384, 447, 384, 425, 425, 384, - 109, 384, 389, 384, 384, 384, 384, 384, - 400, 384, 394, 395, 399, 399, 111, 109, - 384, 389, 384, 384, 384, 384, 384, 384, - 390, 384, 394, 395, 396, 399, 111, 109, - 384, 389, 384, 384, 141, 384, 384, 384, - 390, 384, 392, 384, 449, 384, 430, 430, - 111, 109, 384, 389, 384, 384, 384, 384, - 384, 392, 384, 392, 384, 384, 384, 425, - 425, 384, 109, 384, 389, 384, 384, 384, - 384, 384, 392, 384, 392, 384, 384, 384, - 425, 450, 384, 109, 384, 389, 384, 384, - 384, 384, 384, 392, 384, 392, 384, 449, - 384, 425, 425, 384, 109, 384, 389, 384, - 384, 384, 384, 384, 392, 384, 385, 386, - 388, 388, 111, 109, 384, 389, 384, 384, - 384, 384, 384, 384, 390, 384, 172, 173, - 174, 175, 451, 323, 75, 73, 321, 178, - 179, 179, 144, 321, 321, 172, 182, 321, - 186, 452, 188, 189, 3, 1, 185, 190, - 185, 185, 35, 185, 185, 185, 191, 185, - 194, 173, 174, 175, 453, 454, 75, 149, - 185, 455, 185, 179, 144, 185, 185, 194, - 182, 185, 107, 456, 456, 75, 149, 185, - 190, 185, 185, 144, 185, 457, 185, 185, - 458, 185, 455, 185, 455, 185, 459, 185, - 231, 185, 457, 185, 185, 185, 185, 455, - 185, 194, 185, 251, 107, 460, 460, 146, - 149, 185, 190, 185, 185, 185, 185, 185, - 194, 185, 461, 168, 462, 463, 148, 149, - 185, 455, 185, 168, 462, 463, 148, 149, - 185, 455, 185, 462, 462, 148, 149, 185, - 455, 185, 464, 165, 465, 466, 152, 149, - 185, 455, 185, 165, 465, 466, 152, 149, - 185, 455, 185, 465, 465, 152, 149, 185, - 455, 185, 467, 162, 468, 469, 155, 149, - 185, 455, 185, 162, 468, 469, 155, 149, - 185, 455, 185, 468, 468, 155, 149, 185, - 455, 185, 470, 159, 471, 472, 185, 149, - 185, 455, 185, 159, 471, 472, 185, 149, - 185, 455, 185, 471, 471, 185, 149, 185, - 455, 185, 474, 473, 475, 475, 473, 170, - 473, 476, 473, 475, 475, 473, 170, 473, - 476, 473, 477, 473, 473, 478, 473, 476, - 473, 476, 473, 479, 473, 480, 473, 477, - 473, 473, 473, 473, 476, 473, 172, 383, - 383, 383, 383, 383, 383, 383, 383, 383, - 179, 383, 383, 383, 383, 172, 383, 0 + 1, 0, 2, 3, 3, 4, 1, 0, + 5, 5, 4, 0, 4, 0, 6, 6, + 7, 1, 0, 8, 8, 7, 0, 7, + 0, 9, 9, 10, 1, 0, 11, 11, + 10, 0, 10, 0, 12, 12, 13, 1, + 0, 14, 14, 13, 0, 13, 0, 15, + 0, 0, 0, 1, 0, 16, 0, 17, + 0, 18, 12, 12, 13, 1, 0, 19, + 0, 20, 0, 21, 9, 9, 10, 1, + 0, 22, 0, 23, 0, 24, 6, 6, + 7, 1, 0, 25, 0, 26, 0, 2, + 3, 3, 4, 1, 0, 0, 0, 0, + 27, 0, 28, 3, 3, 4, 1, 0, + 28, 3, 3, 4, 1, 0, 0, 0, + 0, 29, 0, 30, 3, 3, 4, 1, + 0, 30, 3, 3, 4, 1, 0, 0, + 0, 0, 31, 0, 32, 3, 3, 4, + 1, 0, 32, 3, 3, 4, 1, 0, + 0, 0, 0, 33, 0, 34, 3, 3, + 4, 1, 0, 34, 3, 3, 4, 1, + 0, 0, 0, 0, 35, 0, 37, 36, + 38, 39, 39, 40, 37, 36, 41, 41, + 40, 36, 40, 36, 42, 42, 43, 37, + 36, 44, 44, 43, 36, 43, 36, 45, + 45, 46, 37, 36, 47, 47, 46, 36, + 46, 36, 48, 48, 49, 37, 36, 50, + 50, 49, 36, 49, 36, 51, 36, 36, + 36, 37, 36, 52, 36, 53, 36, 54, + 48, 48, 49, 37, 36, 55, 36, 56, + 36, 57, 45, 45, 46, 37, 36, 58, + 36, 59, 36, 60, 42, 42, 43, 37, + 36, 61, 36, 62, 36, 38, 39, 39, + 40, 37, 36, 36, 36, 36, 63, 36, + 64, 39, 39, 40, 37, 36, 64, 39, + 39, 40, 37, 36, 36, 36, 36, 65, + 36, 66, 39, 39, 40, 37, 36, 66, + 39, 39, 40, 37, 36, 36, 36, 36, + 67, 36, 68, 39, 39, 40, 37, 36, + 68, 39, 39, 40, 37, 36, 36, 36, + 36, 69, 36, 70, 39, 39, 40, 37, + 36, 70, 39, 39, 40, 37, 36, 36, + 36, 36, 71, 36, 73, 72, 74, 75, + 75, 76, 73, 72, 78, 78, 76, 77, + 76, 77, 79, 79, 80, 73, 72, 81, + 81, 80, 72, 80, 72, 82, 82, 83, + 73, 72, 84, 84, 83, 72, 83, 72, + 85, 85, 86, 73, 72, 87, 87, 86, + 72, 86, 72, 88, 72, 72, 72, 73, + 72, 89, 72, 90, 72, 91, 85, 85, + 86, 73, 72, 92, 72, 93, 72, 94, + 82, 82, 83, 73, 72, 95, 72, 96, + 72, 97, 79, 79, 80, 73, 72, 98, + 72, 99, 72, 74, 75, 75, 76, 73, + 72, 72, 72, 72, 100, 72, 101, 75, + 75, 76, 73, 72, 101, 75, 75, 76, + 73, 72, 72, 72, 72, 102, 72, 103, + 75, 75, 76, 73, 72, 103, 75, 75, + 76, 73, 72, 72, 72, 72, 104, 72, + 105, 75, 75, 76, 73, 72, 105, 75, + 75, 76, 73, 72, 72, 72, 72, 106, + 72, 107, 75, 75, 76, 73, 72, 109, + 108, 110, 111, 111, 112, 109, 108, 113, + 113, 112, 108, 112, 108, 114, 114, 115, + 109, 108, 116, 116, 115, 108, 115, 108, + 117, 117, 118, 109, 108, 119, 119, 118, + 108, 118, 108, 120, 120, 121, 109, 108, + 122, 122, 121, 108, 121, 108, 123, 108, + 108, 108, 109, 108, 124, 108, 125, 108, + 126, 120, 120, 121, 109, 108, 127, 108, + 128, 108, 129, 117, 117, 118, 109, 108, + 130, 108, 131, 108, 132, 114, 114, 115, + 109, 108, 133, 108, 134, 108, 110, 111, + 111, 112, 109, 108, 108, 108, 108, 135, + 108, 136, 111, 111, 112, 109, 108, 136, + 111, 111, 112, 109, 108, 108, 108, 108, + 137, 108, 138, 111, 111, 112, 109, 108, + 138, 111, 111, 112, 109, 108, 108, 108, + 108, 139, 108, 140, 111, 111, 112, 109, + 108, 140, 111, 111, 112, 109, 108, 108, + 108, 108, 141, 108, 142, 111, 111, 112, + 109, 108, 142, 111, 111, 112, 109, 108, + 108, 108, 108, 143, 108, 107, 75, 75, + 76, 73, 72, 72, 72, 72, 144, 72, + 78, 78, 76, 1, 0, 146, 145, 148, + 149, 150, 151, 152, 153, 76, 73, 147, + 154, 155, 155, 144, 147, 156, 157, 158, + 159, 160, 147, 162, 163, 164, 165, 4, + 1, 161, 166, 161, 161, 35, 161, 161, + 161, 167, 161, 168, 163, 169, 169, 4, + 1, 161, 166, 161, 161, 161, 161, 161, + 161, 167, 161, 163, 169, 169, 4, 1, + 161, 166, 161, 161, 161, 161, 161, 161, + 167, 161, 170, 161, 161, 161, 17, 171, + 161, 1, 161, 166, 161, 161, 161, 161, + 161, 170, 161, 172, 173, 174, 175, 4, + 1, 161, 166, 161, 161, 33, 161, 161, + 161, 167, 161, 176, 173, 177, 177, 4, + 1, 161, 166, 161, 161, 161, 161, 161, + 161, 167, 161, 173, 177, 177, 4, 1, + 161, 166, 161, 161, 161, 161, 161, 161, + 167, 161, 178, 161, 161, 161, 17, 179, + 161, 1, 161, 166, 161, 161, 161, 161, + 161, 178, 161, 180, 181, 182, 183, 4, + 1, 161, 166, 161, 161, 31, 161, 161, + 161, 167, 161, 184, 181, 185, 185, 4, + 1, 161, 166, 161, 161, 161, 161, 161, + 161, 167, 161, 181, 185, 185, 4, 1, + 161, 166, 161, 161, 161, 161, 161, 161, + 167, 161, 186, 161, 161, 161, 17, 187, + 161, 1, 161, 166, 161, 161, 161, 161, + 161, 186, 161, 188, 189, 190, 191, 4, + 1, 161, 166, 161, 161, 29, 161, 161, + 161, 167, 161, 192, 189, 193, 193, 4, + 1, 161, 166, 161, 161, 161, 161, 161, + 161, 167, 161, 189, 193, 193, 4, 1, + 161, 166, 161, 161, 161, 161, 161, 161, + 167, 161, 194, 161, 161, 161, 17, 195, + 161, 1, 161, 166, 161, 161, 161, 161, + 161, 194, 161, 196, 197, 198, 199, 4, + 1, 161, 166, 161, 161, 27, 161, 161, + 161, 167, 161, 200, 197, 201, 201, 4, + 1, 161, 166, 161, 161, 161, 161, 161, + 161, 167, 161, 197, 201, 201, 4, 1, + 161, 166, 161, 161, 161, 161, 161, 161, + 167, 161, 17, 202, 161, 1, 161, 166, + 161, 203, 203, 161, 1, 161, 166, 161, + 204, 161, 161, 205, 161, 166, 161, 166, + 161, 206, 161, 207, 161, 204, 161, 161, + 161, 161, 166, 161, 17, 161, 203, 203, + 161, 1, 161, 166, 161, 203, 202, 161, + 1, 161, 166, 161, 208, 26, 209, 210, + 7, 1, 161, 166, 161, 26, 209, 210, + 7, 1, 161, 166, 161, 209, 209, 7, + 1, 161, 166, 161, 211, 23, 212, 213, + 10, 1, 161, 166, 161, 23, 212, 213, + 10, 1, 161, 166, 161, 212, 212, 10, + 1, 161, 166, 161, 214, 20, 215, 216, + 13, 1, 161, 166, 161, 20, 215, 216, + 13, 1, 161, 166, 161, 215, 215, 13, + 1, 161, 166, 161, 217, 17, 203, 218, + 161, 1, 161, 166, 161, 17, 203, 218, + 161, 1, 161, 166, 161, 197, 201, 201, + 4, 1, 161, 166, 161, 196, 197, 201, + 201, 4, 1, 161, 166, 161, 161, 161, + 161, 161, 161, 167, 161, 196, 197, 198, + 201, 4, 1, 161, 166, 161, 161, 27, + 161, 161, 161, 167, 161, 194, 161, 219, + 161, 203, 203, 161, 1, 161, 166, 161, + 161, 161, 161, 161, 194, 161, 194, 161, + 161, 161, 203, 203, 161, 1, 161, 166, + 161, 161, 161, 161, 161, 194, 161, 194, + 161, 161, 161, 203, 195, 161, 1, 161, + 166, 161, 161, 161, 161, 161, 194, 161, + 188, 189, 193, 193, 4, 1, 161, 166, + 161, 161, 161, 161, 161, 161, 167, 161, + 188, 189, 190, 193, 4, 1, 161, 166, + 161, 161, 29, 161, 161, 161, 167, 161, + 186, 161, 220, 161, 203, 203, 161, 1, + 161, 166, 161, 161, 161, 161, 161, 186, + 161, 186, 161, 161, 161, 203, 203, 161, + 1, 161, 166, 161, 161, 161, 161, 161, + 186, 161, 186, 161, 161, 161, 203, 187, + 161, 1, 161, 166, 161, 161, 161, 161, + 161, 186, 161, 180, 181, 185, 185, 4, + 1, 161, 166, 161, 161, 161, 161, 161, + 161, 167, 161, 180, 181, 182, 185, 4, + 1, 161, 166, 161, 161, 31, 161, 161, + 161, 167, 161, 178, 161, 221, 161, 203, + 203, 161, 1, 161, 166, 161, 161, 161, + 161, 161, 178, 161, 178, 161, 161, 161, + 203, 203, 161, 1, 161, 166, 161, 161, + 161, 161, 161, 178, 161, 178, 161, 161, + 161, 203, 179, 161, 1, 161, 166, 161, + 161, 161, 161, 161, 178, 161, 172, 173, + 177, 177, 4, 1, 161, 166, 161, 161, + 161, 161, 161, 161, 167, 161, 172, 173, + 174, 177, 4, 1, 161, 166, 161, 161, + 33, 161, 161, 161, 167, 161, 170, 161, + 222, 161, 203, 203, 161, 1, 161, 166, + 161, 161, 161, 161, 161, 170, 161, 170, + 161, 161, 161, 203, 203, 161, 1, 161, + 166, 161, 161, 161, 161, 161, 170, 161, + 170, 161, 161, 161, 203, 171, 161, 1, + 161, 166, 161, 161, 161, 161, 161, 170, + 161, 162, 163, 169, 169, 4, 1, 161, + 166, 161, 161, 161, 161, 161, 161, 167, + 161, 162, 163, 164, 169, 4, 1, 161, + 166, 161, 161, 35, 161, 161, 161, 167, + 161, 224, 225, 226, 227, 40, 37, 223, + 228, 223, 223, 71, 223, 223, 223, 229, + 223, 230, 225, 231, 227, 40, 37, 223, + 228, 223, 223, 223, 223, 223, 223, 229, + 223, 225, 231, 227, 40, 37, 223, 228, + 223, 223, 223, 223, 223, 223, 229, 223, + 232, 223, 223, 223, 53, 233, 223, 37, + 223, 228, 223, 223, 223, 223, 223, 232, + 223, 234, 235, 236, 237, 40, 37, 223, + 228, 223, 223, 69, 223, 223, 223, 229, + 223, 238, 235, 239, 239, 40, 37, 223, + 228, 223, 223, 223, 223, 223, 223, 229, + 223, 235, 239, 239, 40, 37, 223, 228, + 223, 223, 223, 223, 223, 223, 229, 223, + 240, 223, 223, 223, 53, 241, 223, 37, + 223, 228, 223, 223, 223, 223, 223, 240, + 223, 242, 243, 244, 245, 40, 37, 223, + 228, 223, 223, 67, 223, 223, 223, 229, + 223, 246, 243, 247, 247, 40, 37, 223, + 228, 223, 223, 223, 223, 223, 223, 229, + 223, 243, 247, 247, 40, 37, 223, 228, + 223, 223, 223, 223, 223, 223, 229, 223, + 248, 223, 223, 223, 53, 249, 223, 37, + 223, 228, 223, 223, 223, 223, 223, 248, + 223, 250, 251, 252, 253, 40, 37, 223, + 228, 223, 223, 65, 223, 223, 223, 229, + 223, 254, 251, 255, 255, 40, 37, 223, + 228, 223, 223, 223, 223, 223, 223, 229, + 223, 251, 255, 255, 40, 37, 223, 228, + 223, 223, 223, 223, 223, 223, 229, 223, + 256, 223, 223, 223, 53, 257, 223, 37, + 223, 228, 223, 223, 223, 223, 223, 256, + 223, 258, 259, 260, 261, 40, 37, 223, + 228, 223, 223, 63, 223, 223, 223, 229, + 223, 262, 259, 263, 263, 40, 37, 223, + 228, 223, 223, 223, 223, 223, 223, 229, + 223, 259, 263, 263, 40, 37, 223, 228, + 223, 223, 223, 223, 223, 223, 229, 223, + 53, 264, 223, 37, 223, 228, 223, 265, + 265, 223, 37, 223, 228, 223, 266, 223, + 223, 267, 223, 228, 223, 228, 223, 268, + 223, 269, 223, 266, 223, 223, 223, 223, + 228, 223, 53, 223, 265, 265, 223, 37, + 223, 228, 223, 265, 264, 223, 37, 223, + 228, 223, 270, 62, 271, 272, 43, 37, + 223, 228, 223, 62, 271, 272, 43, 37, + 223, 228, 223, 271, 271, 43, 37, 223, + 228, 223, 273, 59, 274, 275, 46, 37, + 223, 228, 223, 59, 274, 275, 46, 37, + 223, 228, 223, 274, 274, 46, 37, 223, + 228, 223, 276, 56, 277, 278, 49, 37, + 223, 228, 223, 56, 277, 278, 49, 37, + 223, 228, 223, 277, 277, 49, 37, 223, + 228, 223, 279, 53, 265, 280, 223, 37, + 223, 228, 223, 53, 265, 280, 223, 37, + 223, 228, 223, 259, 263, 263, 40, 37, + 223, 228, 223, 258, 259, 263, 263, 40, + 37, 223, 228, 223, 223, 223, 223, 223, + 223, 229, 223, 258, 259, 260, 263, 40, + 37, 223, 228, 223, 223, 63, 223, 223, + 223, 229, 223, 256, 223, 281, 223, 265, + 265, 223, 37, 223, 228, 223, 223, 223, + 223, 223, 256, 223, 256, 223, 223, 223, + 265, 265, 223, 37, 223, 228, 223, 223, + 223, 223, 223, 256, 223, 256, 223, 223, + 223, 265, 257, 223, 37, 223, 228, 223, + 223, 223, 223, 223, 256, 223, 250, 251, + 255, 255, 40, 37, 223, 228, 223, 223, + 223, 223, 223, 223, 229, 223, 250, 251, + 252, 255, 40, 37, 223, 228, 223, 223, + 65, 223, 223, 223, 229, 223, 248, 223, + 282, 223, 265, 265, 223, 37, 223, 228, + 223, 223, 223, 223, 223, 248, 223, 248, + 223, 223, 223, 265, 265, 223, 37, 223, + 228, 223, 223, 223, 223, 223, 248, 223, + 248, 223, 223, 223, 265, 249, 223, 37, + 223, 228, 223, 223, 223, 223, 223, 248, + 223, 242, 243, 247, 247, 40, 37, 223, + 228, 223, 223, 223, 223, 223, 223, 229, + 223, 242, 243, 244, 247, 40, 37, 223, + 228, 223, 223, 67, 223, 223, 223, 229, + 223, 240, 223, 283, 223, 265, 265, 223, + 37, 223, 228, 223, 223, 223, 223, 223, + 240, 223, 240, 223, 223, 223, 265, 265, + 223, 37, 223, 228, 223, 223, 223, 223, + 223, 240, 223, 240, 223, 223, 223, 265, + 241, 223, 37, 223, 228, 223, 223, 223, + 223, 223, 240, 223, 234, 235, 239, 239, + 40, 37, 223, 228, 223, 223, 223, 223, + 223, 223, 229, 223, 234, 235, 236, 239, + 40, 37, 223, 228, 223, 223, 69, 223, + 223, 223, 229, 223, 232, 223, 284, 223, + 265, 265, 223, 37, 223, 228, 223, 223, + 223, 223, 223, 232, 223, 232, 223, 223, + 223, 265, 265, 223, 37, 223, 228, 223, + 223, 223, 223, 223, 232, 223, 232, 223, + 223, 223, 265, 233, 223, 37, 223, 228, + 223, 223, 223, 223, 223, 232, 223, 70, + 39, 39, 40, 37, 223, 224, 225, 231, + 227, 40, 37, 223, 228, 223, 223, 223, + 223, 223, 223, 229, 223, 286, 151, 287, + 287, 76, 73, 285, 154, 285, 285, 285, + 285, 285, 285, 158, 285, 151, 287, 287, + 76, 73, 285, 154, 285, 285, 285, 285, + 285, 285, 158, 285, 288, 285, 285, 285, + 90, 289, 285, 73, 285, 154, 285, 285, + 285, 285, 285, 288, 285, 290, 291, 292, + 293, 76, 73, 285, 154, 285, 285, 106, + 285, 285, 285, 158, 285, 294, 291, 295, + 295, 76, 73, 285, 154, 285, 285, 285, + 285, 285, 285, 158, 285, 291, 295, 295, + 76, 73, 285, 154, 285, 285, 285, 285, + 285, 285, 158, 285, 296, 285, 285, 285, + 90, 297, 285, 73, 285, 154, 285, 285, + 285, 285, 285, 296, 285, 298, 299, 300, + 301, 76, 73, 285, 154, 285, 285, 104, + 285, 285, 285, 158, 285, 302, 299, 303, + 303, 76, 73, 285, 154, 285, 285, 285, + 285, 285, 285, 158, 285, 299, 303, 303, + 76, 73, 285, 154, 285, 285, 285, 285, + 285, 285, 158, 285, 304, 285, 285, 285, + 90, 305, 285, 73, 285, 154, 285, 285, + 285, 285, 285, 304, 285, 306, 307, 308, + 309, 76, 73, 285, 154, 285, 285, 102, + 285, 285, 285, 158, 285, 310, 307, 311, + 311, 76, 73, 285, 154, 285, 285, 285, + 285, 285, 285, 158, 285, 307, 311, 311, + 76, 73, 285, 154, 285, 285, 285, 285, + 285, 285, 158, 285, 312, 285, 285, 285, + 90, 313, 285, 73, 285, 154, 285, 285, + 285, 285, 285, 312, 285, 314, 315, 316, + 317, 76, 73, 285, 154, 285, 285, 100, + 285, 285, 285, 158, 285, 318, 315, 319, + 319, 76, 73, 285, 154, 285, 285, 285, + 285, 285, 285, 158, 285, 315, 319, 319, + 76, 73, 285, 154, 285, 285, 285, 285, + 285, 285, 158, 285, 90, 320, 285, 73, + 285, 154, 285, 321, 321, 285, 73, 285, + 154, 285, 322, 285, 285, 323, 285, 154, + 285, 154, 285, 324, 285, 325, 285, 322, + 285, 285, 285, 285, 154, 285, 90, 285, + 321, 321, 285, 73, 285, 154, 285, 321, + 320, 285, 73, 285, 154, 285, 326, 99, + 327, 328, 80, 73, 285, 154, 285, 99, + 327, 328, 80, 73, 285, 154, 285, 327, + 327, 80, 73, 285, 154, 285, 329, 96, + 330, 331, 83, 73, 285, 154, 285, 96, + 330, 331, 83, 73, 285, 154, 285, 330, + 330, 83, 73, 285, 154, 285, 332, 93, + 333, 334, 86, 73, 285, 154, 285, 93, + 333, 334, 86, 73, 285, 154, 285, 333, + 333, 86, 73, 285, 154, 285, 335, 90, + 321, 336, 285, 73, 285, 154, 285, 90, + 321, 336, 285, 73, 285, 154, 285, 315, + 319, 319, 76, 73, 285, 154, 285, 314, + 315, 319, 319, 76, 73, 285, 154, 285, + 285, 285, 285, 285, 285, 158, 285, 314, + 315, 316, 319, 76, 73, 285, 154, 285, + 285, 100, 285, 285, 285, 158, 285, 312, + 285, 337, 285, 321, 321, 285, 73, 285, + 154, 285, 285, 285, 285, 285, 312, 285, + 312, 285, 285, 285, 321, 321, 285, 73, + 285, 154, 285, 285, 285, 285, 285, 312, + 285, 312, 285, 285, 285, 321, 313, 285, + 73, 285, 154, 285, 285, 285, 285, 285, + 312, 285, 306, 307, 311, 311, 76, 73, + 285, 154, 285, 285, 285, 285, 285, 285, + 158, 285, 306, 307, 308, 311, 76, 73, + 285, 154, 285, 285, 102, 285, 285, 285, + 158, 285, 304, 285, 338, 285, 321, 321, + 285, 73, 285, 154, 285, 285, 285, 285, + 285, 304, 285, 304, 285, 285, 285, 321, + 321, 285, 73, 285, 154, 285, 285, 285, + 285, 285, 304, 285, 304, 285, 285, 285, + 321, 305, 285, 73, 285, 154, 285, 285, + 285, 285, 285, 304, 285, 298, 299, 303, + 303, 76, 73, 285, 154, 285, 285, 285, + 285, 285, 285, 158, 285, 298, 299, 300, + 303, 76, 73, 285, 154, 285, 285, 104, + 285, 285, 285, 158, 285, 296, 285, 339, + 285, 321, 321, 285, 73, 285, 154, 285, + 285, 285, 285, 285, 296, 285, 296, 285, + 285, 285, 321, 321, 285, 73, 285, 154, + 285, 285, 285, 285, 285, 296, 285, 296, + 285, 285, 285, 321, 297, 285, 73, 285, + 154, 285, 285, 285, 285, 285, 296, 285, + 290, 291, 295, 295, 76, 73, 285, 154, + 285, 285, 285, 285, 285, 285, 158, 285, + 290, 291, 292, 295, 76, 73, 285, 154, + 285, 285, 106, 285, 285, 285, 158, 285, + 288, 285, 340, 285, 321, 321, 285, 73, + 285, 154, 285, 285, 285, 285, 285, 288, + 285, 288, 285, 285, 285, 321, 321, 285, + 73, 285, 154, 285, 285, 285, 285, 285, + 288, 285, 288, 285, 285, 285, 321, 289, + 285, 73, 285, 154, 285, 285, 285, 285, + 285, 288, 285, 107, 75, 75, 76, 73, + 341, 341, 341, 341, 144, 341, 150, 151, + 287, 287, 76, 73, 285, 154, 285, 285, + 285, 285, 285, 285, 158, 285, 107, 75, + 75, 76, 73, 341, 343, 344, 345, 346, + 112, 109, 342, 347, 342, 342, 143, 342, + 342, 342, 348, 342, 349, 344, 346, 346, + 112, 109, 342, 347, 342, 342, 342, 342, + 342, 342, 348, 342, 344, 346, 346, 112, + 109, 342, 347, 342, 342, 342, 342, 342, + 342, 348, 342, 350, 342, 342, 342, 125, + 351, 342, 109, 342, 347, 342, 342, 342, + 342, 342, 350, 342, 352, 353, 354, 355, + 112, 109, 342, 347, 342, 342, 141, 342, + 342, 342, 348, 342, 356, 353, 357, 357, + 112, 109, 342, 347, 342, 342, 342, 342, + 342, 342, 348, 342, 353, 357, 357, 112, + 109, 342, 347, 342, 342, 342, 342, 342, + 342, 348, 342, 358, 342, 342, 342, 125, + 359, 342, 109, 342, 347, 342, 342, 342, + 342, 342, 358, 342, 360, 361, 362, 363, + 112, 109, 342, 347, 342, 342, 139, 342, + 342, 342, 348, 342, 364, 361, 365, 365, + 112, 109, 342, 347, 342, 342, 342, 342, + 342, 342, 348, 342, 361, 365, 365, 112, + 109, 342, 347, 342, 342, 342, 342, 342, + 342, 348, 342, 366, 342, 342, 342, 125, + 367, 342, 109, 342, 347, 342, 342, 342, + 342, 342, 366, 342, 368, 369, 370, 371, + 112, 109, 342, 347, 342, 342, 137, 342, + 342, 342, 348, 342, 372, 369, 373, 373, + 112, 109, 342, 347, 342, 342, 342, 342, + 342, 342, 348, 342, 369, 373, 373, 112, + 109, 342, 347, 342, 342, 342, 342, 342, + 342, 348, 342, 374, 342, 342, 342, 125, + 375, 342, 109, 342, 347, 342, 342, 342, + 342, 342, 374, 342, 376, 377, 378, 379, + 112, 109, 342, 347, 342, 342, 135, 342, + 342, 342, 348, 342, 380, 377, 381, 381, + 112, 109, 342, 347, 342, 342, 342, 342, + 342, 342, 348, 342, 377, 381, 381, 112, + 109, 342, 347, 342, 342, 342, 342, 342, + 342, 348, 342, 125, 382, 342, 109, 342, + 347, 342, 383, 383, 342, 109, 342, 347, + 342, 384, 342, 342, 385, 342, 347, 342, + 347, 342, 386, 342, 387, 342, 384, 342, + 342, 342, 342, 347, 342, 125, 342, 383, + 383, 342, 109, 342, 347, 342, 383, 382, + 342, 109, 342, 347, 342, 388, 134, 389, + 390, 115, 109, 342, 347, 342, 134, 389, + 390, 115, 109, 342, 347, 342, 389, 389, + 115, 109, 342, 347, 342, 391, 131, 392, + 393, 118, 109, 342, 347, 342, 131, 392, + 393, 118, 109, 342, 347, 342, 392, 392, + 118, 109, 342, 347, 342, 394, 128, 395, + 396, 121, 109, 342, 347, 342, 128, 395, + 396, 121, 109, 342, 347, 342, 395, 395, + 121, 109, 342, 347, 342, 397, 125, 383, + 398, 342, 109, 342, 347, 342, 125, 383, + 398, 342, 109, 342, 347, 342, 377, 381, + 381, 112, 109, 342, 347, 342, 376, 377, + 381, 381, 112, 109, 342, 347, 342, 342, + 342, 342, 342, 342, 348, 342, 376, 377, + 378, 381, 112, 109, 342, 347, 342, 342, + 135, 342, 342, 342, 348, 342, 374, 342, + 399, 342, 383, 383, 342, 109, 342, 347, + 342, 342, 342, 342, 342, 374, 342, 374, + 342, 342, 342, 383, 383, 342, 109, 342, + 347, 342, 342, 342, 342, 342, 374, 342, + 374, 342, 342, 342, 383, 375, 342, 109, + 342, 347, 342, 342, 342, 342, 342, 374, + 342, 368, 369, 373, 373, 112, 109, 342, + 347, 342, 342, 342, 342, 342, 342, 348, + 342, 368, 369, 370, 373, 112, 109, 342, + 347, 342, 342, 137, 342, 342, 342, 348, + 342, 366, 342, 400, 342, 383, 383, 342, + 109, 342, 347, 342, 342, 342, 342, 342, + 366, 342, 366, 342, 342, 342, 383, 383, + 342, 109, 342, 347, 342, 342, 342, 342, + 342, 366, 342, 366, 342, 342, 342, 383, + 367, 342, 109, 342, 347, 342, 342, 342, + 342, 342, 366, 342, 360, 361, 365, 365, + 112, 109, 342, 347, 342, 342, 342, 342, + 342, 342, 348, 342, 360, 361, 362, 365, + 112, 109, 342, 347, 342, 342, 139, 342, + 342, 342, 348, 342, 358, 342, 401, 342, + 383, 383, 342, 109, 342, 347, 342, 342, + 342, 342, 342, 358, 342, 358, 342, 342, + 342, 383, 383, 342, 109, 342, 347, 342, + 342, 342, 342, 342, 358, 342, 358, 342, + 342, 342, 383, 359, 342, 109, 342, 347, + 342, 342, 342, 342, 342, 358, 342, 352, + 353, 357, 357, 112, 109, 342, 347, 342, + 342, 342, 342, 342, 342, 348, 342, 352, + 353, 354, 357, 112, 109, 342, 347, 342, + 342, 141, 342, 342, 342, 348, 342, 350, + 342, 402, 342, 383, 383, 342, 109, 342, + 347, 342, 342, 342, 342, 342, 350, 342, + 350, 342, 342, 342, 383, 383, 342, 109, + 342, 347, 342, 342, 342, 342, 342, 350, + 342, 350, 342, 342, 342, 383, 351, 342, + 109, 342, 347, 342, 342, 342, 342, 342, + 350, 342, 343, 344, 346, 346, 112, 109, + 342, 347, 342, 342, 342, 342, 342, 342, + 348, 342, 148, 149, 150, 151, 403, 287, + 76, 73, 285, 154, 155, 155, 144, 285, + 285, 148, 158, 285, 162, 404, 164, 165, + 4, 1, 161, 166, 161, 161, 35, 161, + 161, 161, 167, 161, 170, 149, 150, 151, + 405, 406, 76, 407, 161, 408, 161, 155, + 144, 161, 161, 170, 158, 161, 107, 409, + 409, 76, 407, 161, 166, 161, 161, 144, + 161, 410, 161, 161, 411, 161, 408, 161, + 408, 161, 412, 161, 207, 161, 410, 161, + 161, 161, 161, 408, 161, 170, 161, 222, + 107, 409, 409, 76, 407, 161, 166, 161, + 161, 161, 161, 161, 170, 161, 414, 413, + 415, 415, 413, 146, 413, 416, 413, 415, + 415, 413, 146, 413, 416, 413, 417, 413, + 413, 418, 413, 416, 413, 416, 413, 419, + 413, 420, 413, 417, 413, 413, 413, 413, + 416, 413, 148, 341, 341, 341, 341, 341, + 341, 341, 341, 341, 155, 341, 341, 341, + 341, 148, 341, 0 }; static const short _indic_syllable_machine_trans_targs[] = { - 166, 188, 2, 194, 3, 5, 197, 6, - 8, 200, 9, 11, 203, 12, 14, 15, - 187, 17, 18, 202, 20, 21, 199, 23, - 24, 196, 205, 208, 212, 214, 218, 220, - 224, 226, 230, 232, 166, 255, 37, 261, - 38, 40, 264, 41, 43, 267, 44, 46, - 270, 47, 49, 50, 254, 52, 53, 269, - 55, 56, 266, 58, 59, 263, 272, 275, - 279, 281, 285, 287, 291, 293, 297, 300, - 166, 321, 72, 327, 166, 73, 75, 330, - 76, 78, 333, 79, 81, 336, 82, 84, - 85, 320, 87, 88, 335, 90, 91, 332, - 93, 94, 329, 338, 341, 345, 347, 351, - 353, 357, 359, 363, 166, 389, 106, 395, - 107, 109, 398, 110, 112, 401, 113, 115, - 404, 116, 118, 119, 388, 121, 122, 403, - 124, 125, 400, 127, 128, 397, 406, 409, - 413, 415, 419, 421, 425, 427, 431, 433, - 366, 142, 444, 144, 447, 438, 145, 147, - 450, 148, 150, 453, 151, 154, 155, 455, - 157, 158, 452, 160, 161, 449, 163, 164, - 446, 166, 458, 166, 167, 234, 301, 303, - 365, 367, 323, 368, 434, 435, 340, 456, - 463, 166, 168, 170, 34, 233, 190, 207, - 169, 33, 171, 228, 172, 174, 32, 227, - 173, 31, 175, 222, 176, 178, 30, 221, - 177, 29, 179, 216, 180, 182, 28, 215, - 181, 27, 183, 210, 184, 186, 26, 209, - 185, 25, 193, 0, 189, 192, 191, 166, - 1, 195, 4, 22, 198, 7, 19, 201, - 10, 16, 204, 13, 206, 211, 213, 217, - 219, 223, 225, 229, 231, 166, 235, 237, - 69, 299, 257, 274, 236, 68, 238, 295, - 239, 241, 67, 294, 240, 66, 242, 289, - 243, 245, 65, 288, 244, 64, 246, 283, - 247, 249, 63, 282, 248, 62, 250, 277, - 251, 253, 61, 276, 252, 60, 260, 35, - 256, 259, 258, 166, 36, 262, 39, 57, - 265, 42, 54, 268, 45, 51, 271, 48, - 273, 278, 280, 284, 286, 290, 292, 296, - 298, 166, 302, 103, 304, 361, 305, 307, - 102, 360, 306, 101, 308, 355, 309, 311, - 100, 354, 310, 99, 312, 349, 313, 315, - 98, 348, 314, 97, 316, 343, 317, 319, - 96, 342, 318, 95, 326, 70, 322, 325, - 324, 166, 71, 328, 74, 92, 331, 77, - 89, 334, 80, 86, 337, 83, 339, 344, - 346, 350, 352, 356, 358, 362, 364, 166, - 166, 369, 371, 138, 137, 391, 408, 370, - 372, 429, 373, 375, 136, 428, 374, 135, - 376, 423, 377, 379, 134, 422, 378, 133, - 380, 417, 381, 383, 132, 416, 382, 131, - 384, 411, 385, 387, 130, 410, 386, 129, - 394, 104, 390, 393, 392, 166, 105, 396, - 108, 126, 399, 111, 123, 402, 114, 120, - 405, 117, 407, 412, 414, 418, 420, 424, - 426, 430, 432, 139, 436, 437, 443, 440, - 140, 439, 442, 441, 141, 445, 143, 162, - 448, 146, 159, 451, 149, 156, 454, 152, - 153, 166, 457, 165, 460, 459, 462, 461, - 166 + 138, 160, 166, 2, 167, 3, 5, 170, + 6, 8, 173, 9, 11, 176, 12, 14, + 15, 159, 17, 18, 175, 20, 21, 172, + 23, 24, 169, 179, 183, 184, 188, 189, + 193, 194, 198, 199, 138, 222, 228, 36, + 229, 37, 39, 232, 40, 42, 235, 43, + 45, 238, 46, 48, 49, 221, 51, 52, + 237, 54, 55, 234, 57, 58, 231, 241, + 245, 246, 250, 251, 255, 256, 260, 262, + 138, 283, 289, 70, 290, 138, 71, 73, + 293, 74, 76, 296, 77, 79, 299, 80, + 82, 83, 282, 85, 86, 298, 88, 89, + 295, 91, 92, 292, 302, 306, 307, 311, + 312, 316, 317, 321, 138, 346, 352, 103, + 353, 104, 106, 356, 107, 109, 359, 110, + 112, 362, 113, 115, 116, 345, 118, 119, + 361, 121, 122, 358, 124, 125, 355, 365, + 369, 370, 374, 375, 379, 380, 384, 385, + 323, 138, 398, 138, 139, 201, 263, 265, + 322, 324, 285, 325, 386, 387, 301, 396, + 403, 138, 140, 142, 33, 200, 162, 178, + 141, 32, 143, 196, 144, 146, 31, 195, + 145, 30, 147, 191, 148, 150, 29, 190, + 149, 28, 151, 186, 152, 154, 27, 185, + 153, 26, 155, 181, 156, 158, 25, 180, + 157, 1, 165, 0, 161, 164, 163, 138, + 168, 4, 22, 171, 7, 19, 174, 10, + 16, 177, 13, 182, 187, 192, 197, 138, + 202, 204, 67, 261, 224, 240, 203, 66, + 205, 258, 206, 208, 65, 257, 207, 64, + 209, 253, 210, 212, 63, 252, 211, 62, + 213, 248, 214, 216, 61, 247, 215, 60, + 217, 243, 218, 220, 59, 242, 219, 35, + 227, 34, 223, 226, 225, 138, 230, 38, + 56, 233, 41, 53, 236, 44, 50, 239, + 47, 244, 249, 254, 259, 138, 264, 100, + 266, 319, 267, 269, 99, 318, 268, 98, + 270, 314, 271, 273, 97, 313, 272, 96, + 274, 309, 275, 277, 95, 308, 276, 94, + 278, 304, 279, 281, 93, 303, 280, 69, + 288, 68, 284, 287, 286, 138, 291, 72, + 90, 294, 75, 87, 297, 78, 84, 300, + 81, 305, 310, 315, 320, 138, 138, 326, + 328, 134, 133, 348, 364, 327, 329, 382, + 330, 332, 132, 381, 331, 131, 333, 377, + 334, 336, 130, 376, 335, 129, 337, 372, + 338, 340, 128, 371, 339, 127, 341, 367, + 342, 344, 126, 366, 343, 102, 351, 101, + 347, 350, 349, 138, 354, 105, 123, 357, + 108, 120, 360, 111, 117, 363, 114, 368, + 373, 378, 383, 135, 388, 389, 395, 390, + 392, 136, 391, 394, 393, 138, 397, 137, + 400, 399, 402, 401, 138 }; static const char _indic_syllable_machine_trans_actions[] = { - 1, 0, 0, 2, 0, 0, 2, 0, - 0, 2, 0, 0, 2, 0, 0, 0, - 2, 0, 0, 2, 0, 0, 2, 0, - 0, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 3, 0, 0, 2, - 0, 0, 2, 0, 0, 2, 0, 0, - 2, 0, 0, 0, 2, 0, 0, 2, - 0, 0, 2, 0, 0, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, - 4, 0, 0, 2, 5, 0, 0, 2, + 1, 0, 2, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, 0, 0, 0, 2, 0, 0, 2, 0, 0, 2, - 0, 0, 2, 2, 6, 2, 6, 2, - 6, 2, 6, 2, 7, 0, 0, 2, - 0, 0, 2, 0, 0, 2, 0, 0, - 2, 0, 0, 0, 2, 0, 0, 2, - 0, 0, 2, 0, 0, 2, 2, 2, + 0, 0, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 3, 0, 2, 0, + 2, 0, 0, 2, 0, 0, 2, 0, + 0, 2, 0, 0, 0, 2, 0, 0, + 2, 0, 0, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 6, 0, 2, 0, 2, 0, 0, 0, - 2, 0, 0, 2, 0, 0, 0, 2, + 4, 0, 2, 0, 2, 5, 0, 0, + 2, 0, 0, 2, 0, 0, 2, 0, 0, 0, 2, 0, 0, 2, 0, 0, - 2, 8, 0, 11, 2, 2, 6, 0, + 2, 0, 0, 2, 6, 2, 6, 2, + 6, 2, 6, 2, 7, 0, 2, 0, + 2, 0, 0, 2, 0, 0, 2, 0, + 0, 2, 0, 0, 0, 2, 0, 0, + 2, 0, 0, 2, 0, 0, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, + 6, 8, 0, 11, 2, 2, 6, 0, 12, 12, 0, 2, 6, 2, 6, 2, 0, 13, 2, 0, 0, 2, 0, 2, 2, 0, 2, 2, 2, 0, 0, 2, @@ -885,38 +789,33 @@ static const char _indic_syllable_machine_trans_actions[] = { 2, 0, 2, 2, 2, 0, 0, 2, 2, 0, 2, 2, 2, 0, 0, 2, 2, 0, 2, 0, 0, 0, 0, 14, + 2, 0, 0, 2, 0, 0, 2, 0, + 0, 2, 0, 2, 2, 2, 2, 15, + 2, 0, 0, 2, 0, 2, 2, 0, + 2, 2, 2, 0, 0, 2, 2, 0, + 2, 2, 2, 0, 0, 2, 2, 0, + 2, 2, 2, 0, 0, 2, 2, 0, + 2, 2, 2, 0, 0, 2, 2, 0, + 2, 0, 0, 0, 0, 16, 2, 0, 0, 2, 0, 0, 2, 0, 0, 2, - 0, 0, 2, 0, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 15, 2, 0, - 0, 2, 0, 2, 2, 0, 2, 2, + 0, 2, 2, 2, 2, 17, 6, 0, + 6, 2, 6, 0, 0, 6, 6, 0, + 6, 2, 6, 0, 0, 6, 6, 0, + 6, 2, 6, 0, 0, 6, 6, 0, + 6, 2, 6, 0, 0, 6, 6, 0, + 2, 0, 0, 0, 0, 18, 2, 0, + 0, 2, 0, 0, 2, 0, 0, 2, + 0, 2, 2, 2, 2, 19, 20, 2, + 0, 0, 0, 0, 2, 2, 2, 2, 2, 0, 0, 2, 2, 0, 2, 2, 2, 0, 0, 2, 2, 0, 2, 2, 2, 0, 0, 2, 2, 0, 2, 2, 2, 0, 0, 2, 2, 0, 2, 0, - 0, 0, 0, 16, 0, 2, 0, 0, - 2, 0, 0, 2, 0, 0, 2, 0, - 2, 2, 2, 2, 2, 2, 2, 2, - 2, 17, 6, 0, 6, 6, 6, 0, - 0, 6, 6, 0, 6, 6, 6, 0, - 0, 6, 6, 0, 6, 6, 6, 0, - 0, 6, 6, 0, 6, 6, 6, 0, - 0, 6, 6, 0, 6, 0, 0, 0, - 0, 18, 0, 2, 0, 0, 2, 0, - 0, 2, 0, 0, 2, 0, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 19, - 20, 2, 0, 0, 0, 0, 2, 2, - 2, 2, 2, 0, 0, 2, 2, 0, - 2, 2, 2, 0, 0, 2, 2, 0, - 2, 2, 2, 0, 0, 2, 2, 0, - 2, 2, 2, 0, 0, 2, 2, 0, - 2, 0, 0, 0, 0, 21, 0, 2, - 0, 0, 2, 0, 0, 2, 0, 0, - 2, 0, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 0, 0, 22, 2, 0, - 0, 0, 0, 0, 0, 2, 0, 0, - 2, 0, 0, 2, 0, 0, 2, 0, - 0, 23, 2, 0, 0, 0, 0, 0, - 24 + 0, 0, 0, 21, 2, 0, 0, 2, + 0, 0, 2, 0, 0, 2, 0, 2, + 2, 2, 2, 0, 0, 22, 22, 0, + 0, 0, 0, 0, 0, 23, 2, 0, + 0, 0, 0, 0, 24 }; static const char _indic_syllable_machine_to_state_actions[] = { @@ -937,10 +836,7 @@ static const char _indic_syllable_machine_to_state_actions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 9, 0, + 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -973,11 +869,7 @@ static const char _indic_syllable_machine_to_state_actions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0 }; static const char _indic_syllable_machine_from_state_actions[] = { @@ -998,10 +890,7 @@ static const char _indic_syllable_machine_from_state_actions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 10, 0, + 0, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -1034,11 +923,7 @@ static const char _indic_syllable_machine_from_state_actions[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0 + 0, 0, 0, 0 }; static const short _indic_syllable_machine_eof_trans[] = { @@ -1046,67 +931,60 @@ static const short _indic_syllable_machine_eof_trans[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 37, 37, 37, 37, 37, + 1, 1, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, 37, - 37, 37, 37, 37, 37, 37, 73, 73, - 77, 77, 73, 73, 73, 73, 73, 73, + 37, 37, 37, 37, 73, 73, 78, 78, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 73, 73, 73, 73, 73, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 109, 109, 109, 109, 109, - 109, 109, 109, 73, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 170, 0, 186, - 186, 186, 186, 186, 186, 186, 186, 186, - 186, 186, 186, 186, 186, 186, 186, 186, - 186, 186, 186, 186, 186, 186, 186, 186, - 186, 186, 186, 186, 186, 186, 186, 186, - 186, 186, 186, 186, 186, 186, 186, 186, - 186, 186, 186, 186, 186, 186, 186, 186, - 186, 186, 186, 186, 186, 186, 186, 186, - 186, 186, 186, 186, 186, 186, 186, 186, - 186, 186, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 254, 254, 254, - 254, 254, 254, 254, 254, 322, 322, 322, - 322, 322, 322, 322, 322, 322, 322, 322, - 322, 322, 322, 322, 322, 322, 322, 322, - 322, 322, 322, 322, 322, 322, 322, 322, - 322, 322, 322, 322, 322, 322, 322, 322, - 322, 322, 322, 322, 322, 322, 322, 322, - 322, 322, 322, 322, 322, 322, 322, 322, - 322, 322, 322, 322, 322, 322, 322, 322, - 322, 322, 322, 322, 322, 384, 322, 384, - 385, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 385, 385, 385, 385, 385, 385, - 385, 385, 322, 186, 186, 186, 186, 186, - 186, 186, 186, 186, 186, 186, 186, 186, - 186, 186, 186, 186, 186, 186, 186, 186, - 474, 474, 474, 474, 474, 474, 474, 384 + 109, 109, 109, 109, 109, 109, 109, 73, + 1, 146, 0, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 162, 162, 162, 162, + 162, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 286, + 286, 286, 286, 286, 286, 286, 286, 286, + 286, 286, 286, 286, 286, 286, 286, 286, + 286, 286, 286, 286, 286, 286, 286, 286, + 286, 286, 286, 286, 286, 286, 286, 286, + 286, 286, 286, 286, 286, 286, 286, 286, + 286, 286, 286, 286, 286, 286, 286, 286, + 286, 286, 286, 286, 286, 286, 286, 286, + 286, 286, 342, 286, 342, 343, 343, 343, + 343, 343, 343, 343, 343, 343, 343, 343, + 343, 343, 343, 343, 343, 343, 343, 343, + 343, 343, 343, 343, 343, 343, 343, 343, + 343, 343, 343, 343, 343, 343, 343, 343, + 343, 343, 343, 343, 343, 343, 343, 343, + 343, 343, 343, 343, 343, 343, 343, 343, + 343, 343, 343, 343, 343, 343, 343, 343, + 343, 343, 286, 162, 162, 162, 162, 162, + 162, 162, 162, 162, 414, 414, 414, 414, + 414, 414, 414, 342 }; -static const int indic_syllable_machine_start = 166; -static const int indic_syllable_machine_first_final = 166; +static const int indic_syllable_machine_start = 138; +static const int indic_syllable_machine_first_final = 138; static const int indic_syllable_machine_error = -1; -static const int indic_syllable_machine_en_main = 166; +static const int indic_syllable_machine_en_main = 138; #line 36 "hb-ot-shape-complex-indic-machine.rl" @@ -1133,7 +1011,7 @@ find_syllables (hb_buffer_t *buffer) int cs; hb_glyph_info_t *info = buffer->info; -#line 1137 "hb-ot-shape-complex-indic-machine.hh" +#line 1015 "hb-ot-shape-complex-indic-machine.hh" { cs = indic_syllable_machine_start; ts = 0; @@ -1150,7 +1028,7 @@ find_syllables (hb_buffer_t *buffer) unsigned int last = 0; unsigned int syllable_serial = 1; -#line 1154 "hb-ot-shape-complex-indic-machine.hh" +#line 1032 "hb-ot-shape-complex-indic-machine.hh" { int _slen; int _trans; @@ -1164,7 +1042,7 @@ _resume: #line 1 "NONE" {ts = p;} break; -#line 1168 "hb-ot-shape-complex-indic-machine.hh" +#line 1046 "hb-ot-shape-complex-indic-machine.hh" } _keys = _indic_syllable_machine_trans_keys + (cs<<1); @@ -1287,7 +1165,7 @@ _eof_trans: #line 88 "hb-ot-shape-complex-indic-machine.rl" {act = 6;} break; -#line 1291 "hb-ot-shape-complex-indic-machine.hh" +#line 1169 "hb-ot-shape-complex-indic-machine.hh" } _again: @@ -1296,7 +1174,7 @@ _again: #line 1 "NONE" {ts = 0;} break; -#line 1300 "hb-ot-shape-complex-indic-machine.hh" +#line 1178 "hb-ot-shape-complex-indic-machine.hh" } if ( ++p != pe ) diff --git a/src/hb-ot-shape-complex-indic-machine.rl b/src/hb-ot-shape-complex-indic-machine.rl index d384a68c3..c5c5fe698 100644 --- a/src/hb-ot-shape-complex-indic-machine.rl +++ b/src/hb-ot-shape-complex-indic-machine.rl @@ -69,7 +69,7 @@ syllable_tail = (z?.SM.SM?.ZWNJ?)? A{0,3}?; halant_group = (z?.H.(ZWJ.N?)?); final_halant_group = halant_group | H.ZWNJ; medial_group = CM?; -halant_or_matra_group = (final_halant_group | (H.ZWJ)? matra_group{0,4}); +halant_or_matra_group = (final_halant_group | matra_group{0,4}); consonant_syllable = (Repha|CS)? (cn.halant_group){0,4} cn medial_group halant_or_matra_group syllable_tail; From 24f1d9622489a016904314a5d4e3c637da2e1c77 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 18:19:37 +0200 Subject: [PATCH 08/39] Unbreak HB_OPTIONS Fixes https://github.com/harfbuzz/harfbuzz/issues/1154 --- src/hb-debug.hh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/hb-debug.hh b/src/hb-debug.hh index 49663d215..12b6c49ae 100644 --- a/src/hb-debug.hh +++ b/src/hb-debug.hh @@ -67,7 +67,10 @@ hb_options (void) u.i = _hb_options.get_relaxed (); if (unlikely (!u.i)) + { _hb_options_init (); + u.i = _hb_options.get_relaxed (); + } return u.opts; } From 1bc7a8d6c4deb9fa6e010d7be08b68cad88579ae Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 22:51:26 +0200 Subject: [PATCH 09/39] [indic] Cache hb_options().uniscribe_bug_compatible on indic_plan --- src/hb-ot-shape-complex-indic.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc index d4541bb18..369078cb2 100644 --- a/src/hb-ot-shape-complex-indic.cc +++ b/src/hb-ot-shape-complex-indic.cc @@ -273,6 +273,7 @@ struct indic_shape_plan_t const indic_config_t *config; bool is_old_spec; + bool uniscribe_bug_compatible; mutable hb_atomic_int_t virama_glyph; would_substitute_feature_t rphf; @@ -298,6 +299,7 @@ data_create_indic (const hb_ot_shape_plan_t *plan) } indic_plan->is_old_spec = indic_plan->config->has_old_spec && ((plan->map.chosen_script[0] & 0x000000FFu) != '2'); + indic_plan->uniscribe_bug_compatible = hb_options ().uniscribe_bug_compatible; indic_plan->virama_glyph.set_relaxed (-1); /* Use zero-context would_substitute() matching for new-spec of the main @@ -913,10 +915,12 @@ initial_reordering_standalone_cluster (const hb_ot_shape_plan_t *plan, hb_buffer_t *buffer, unsigned int start, unsigned int end) { + const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) plan->data; + /* We treat placeholder/dotted-circle as if they are consonants, so we * should just chain. Only if not in compatibility mode that is... */ - if (hb_options ().uniscribe_bug_compatible) + if (indic_plan->uniscribe_bug_compatible) { /* For dotted-circle, this is what Uniscribe does: * If dotted-circle is the last glyph, it just does nothing. @@ -1356,7 +1360,7 @@ final_reordering_syllable (const hb_ot_shape_plan_t *plan, * Uniscribe doesn't do this. * TEST: U+0930,U+094D,U+0915,U+094B,U+094D */ - if (!hb_options ().uniscribe_bug_compatible && + if (!indic_plan->uniscribe_bug_compatible && unlikely (is_halant (info[new_reph_pos]))) { for (unsigned int i = base + 1; i < new_reph_pos; i++) if (info[i].indic_category() == OT_M) { @@ -1462,7 +1466,7 @@ final_reordering_syllable (const hb_ot_shape_plan_t *plan, /* * Finish off the clusters and go home! */ - if (hb_options ().uniscribe_bug_compatible) + if (indic_plan->uniscribe_bug_compatible) { switch ((hb_tag_t) plan->props.script) { From bc485a98122131efc4768fef9147823f2bce146b Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 23:02:24 +0200 Subject: [PATCH 10/39] Port some VAR arrays to UnsizedArrayOf<> Fix avar sanitize(). --- src/hb-ot-layout-gsubgpos.hh | 59 +++++++++++++++++++----------------- src/hb-ot-var-avar-table.hh | 10 +++--- src/hb-ot-var-fvar-table.hh | 7 +++-- src/hb-ot-var-hvar-table.hh | 9 +++--- src/hb-ot-var-mvar-table.hh | 9 +++--- 5 files changed, 51 insertions(+), 43 deletions(-) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index bd4611d22..d4755655e 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -1222,42 +1222,42 @@ struct Rule inline bool intersects (const hb_set_t *glyphs, ContextClosureLookupContext &lookup_context) const { return context_intersects (glyphs, - inputCount, inputZ, + inputCount, inputZ.arrayZ, lookup_context); } inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const { TRACE_CLOSURE (this); - const LookupRecord *lookupRecord = &StructAtOffset (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); + const UnsizedArrayOf &lookupRecord = StructAtOffset > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); context_closure_lookup (c, - inputCount, inputZ, - lookupCount, lookupRecord, + inputCount, inputZ.arrayZ, + lookupCount, lookupRecord.arrayZ, lookup_context); } inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const { TRACE_COLLECT_GLYPHS (this); - const LookupRecord *lookupRecord = &StructAtOffset (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); + const UnsizedArrayOf &lookupRecord = StructAtOffset > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); context_collect_glyphs_lookup (c, - inputCount, inputZ, - lookupCount, lookupRecord, + inputCount, inputZ.arrayZ, + lookupCount, lookupRecord.arrayZ, lookup_context); } inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const { TRACE_WOULD_APPLY (this); - const LookupRecord *lookupRecord = &StructAtOffset (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); - return_trace (context_would_apply_lookup (c, inputCount, inputZ, lookupCount, lookupRecord, lookup_context)); + const UnsizedArrayOf &lookupRecord = StructAtOffset > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); + return_trace (context_would_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context)); } inline bool apply (hb_ot_apply_context_t *c, ContextApplyLookupContext &lookup_context) const { TRACE_APPLY (this); - const LookupRecord *lookupRecord = &StructAtOffset (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); - return_trace (context_apply_lookup (c, inputCount, inputZ, lookupCount, lookupRecord, lookup_context)); + const UnsizedArrayOf &lookupRecord = StructAtOffset > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); + return_trace (context_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context)); } public: @@ -1266,7 +1266,7 @@ struct Rule TRACE_SANITIZE (this); return_trace (inputCount.sanitize (c) && lookupCount.sanitize (c) && - c->check_range (inputZ, + c->check_range (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0) + LookupRecord::static_size * lookupCount)); } @@ -1276,9 +1276,11 @@ struct Rule * glyph sequence--includes the first * glyph */ HBUINT16 lookupCount; /* Number of LookupRecords */ - HBUINT16 inputZ[VAR]; /* Array of match inputs--start with + UnsizedArrayOf + inputZ; /* Array of match inputs--start with * second glyph */ -/*LookupRecord lookupRecordX[VAR];*/ /* Array of LookupRecords--in +/*UnsizedArrayOf + lookupRecordX;*/ /* Array of LookupRecords--in * design order */ public: DEFINE_SIZE_ARRAY (4, inputZ); @@ -1595,7 +1597,7 @@ struct ContextFormat3 this }; return context_intersects (glyphs, - glyphCount, (const HBUINT16 *) (coverageZ + 1), + glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), lookup_context); } @@ -1605,13 +1607,13 @@ struct ContextFormat3 if (!(this+coverageZ[0]).intersects (c->glyphs)) return; - const LookupRecord *lookupRecord = &StructAtOffset (coverageZ, coverageZ[0].static_size * glyphCount); + const LookupRecord *lookupRecord = &StructAtOffset (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount); struct ContextClosureLookupContext lookup_context = { {intersects_coverage}, this }; context_closure_lookup (c, - glyphCount, (const HBUINT16 *) (coverageZ + 1), + glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), lookupCount, lookupRecord, lookup_context); } @@ -1621,14 +1623,14 @@ struct ContextFormat3 TRACE_COLLECT_GLYPHS (this); (this+coverageZ[0]).add_coverage (c->input); - const LookupRecord *lookupRecord = &StructAtOffset (coverageZ, coverageZ[0].static_size * glyphCount); + const LookupRecord *lookupRecord = &StructAtOffset (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount); struct ContextCollectGlyphsLookupContext lookup_context = { {collect_coverage}, this }; context_collect_glyphs_lookup (c, - glyphCount, (const HBUINT16 *) (coverageZ + 1), + glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), lookupCount, lookupRecord, lookup_context); } @@ -1637,12 +1639,12 @@ struct ContextFormat3 { TRACE_WOULD_APPLY (this); - const LookupRecord *lookupRecord = &StructAtOffset (coverageZ, coverageZ[0].static_size * glyphCount); + const LookupRecord *lookupRecord = &StructAtOffset (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount); struct ContextApplyLookupContext lookup_context = { {match_coverage}, this }; - return_trace (context_would_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ + 1), lookupCount, lookupRecord, lookup_context)); + return_trace (context_would_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), lookupCount, lookupRecord, lookup_context)); } inline const Coverage &get_coverage (void) const @@ -1654,12 +1656,12 @@ struct ContextFormat3 unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().codepoint); if (likely (index == NOT_COVERED)) return_trace (false); - const LookupRecord *lookupRecord = &StructAtOffset (coverageZ, coverageZ[0].static_size * glyphCount); + const LookupRecord *lookupRecord = &StructAtOffset (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount); struct ContextApplyLookupContext lookup_context = { {match_coverage}, this }; - return_trace (context_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ + 1), lookupCount, lookupRecord, lookup_context)); + return_trace (context_apply_lookup (c, glyphCount, (const HBUINT16 *) (coverageZ.arrayZ + 1), lookupCount, lookupRecord, lookup_context)); } inline bool subset (hb_subset_context_t *c) const @@ -1675,10 +1677,10 @@ struct ContextFormat3 if (!c->check_struct (this)) return_trace (false); unsigned int count = glyphCount; if (!count) return_trace (false); /* We want to access coverageZ[0] freely. */ - if (!c->check_array (coverageZ, coverageZ[0].static_size, count)) return_trace (false); + if (!c->check_array (coverageZ.arrayZ, coverageZ[0].static_size, count)) return_trace (false); for (unsigned int i = 0; i < count; i++) if (!coverageZ[i].sanitize (c, this)) return_trace (false); - const LookupRecord *lookupRecord = &StructAtOffset (coverageZ, coverageZ[0].static_size * count); + const LookupRecord *lookupRecord = &StructAtOffset (coverageZ.arrayZ, coverageZ[0].static_size * count); return_trace (c->check_array (lookupRecord, lookupRecord[0].static_size, lookupCount)); } @@ -1687,10 +1689,11 @@ struct ContextFormat3 HBUINT16 glyphCount; /* Number of glyphs in the input glyph * sequence */ HBUINT16 lookupCount; /* Number of LookupRecords */ - OffsetTo - coverageZ[VAR]; /* Array of offsets to Coverage + UnsizedArrayOf > + coverageZ; /* Array of offsets to Coverage * table in glyph sequence order */ -/*LookupRecord lookupRecordX[VAR];*/ /* Array of LookupRecords--in +/*UnsizedArrayOf + lookupRecordX;*/ /* Array of LookupRecords--in * design order */ public: DEFINE_SIZE_ARRAY (6, coverageZ); diff --git a/src/hb-ot-var-avar-table.hh b/src/hb-ot-var-avar-table.hh index 8343018b3..5428c97bb 100644 --- a/src/hb-ot-var-avar-table.hh +++ b/src/hb-ot-var-avar-table.hh @@ -105,10 +105,11 @@ struct avar TRACE_SANITIZE (this); if (unlikely (!(version.sanitize (c) && version.major == 1 && - c->check_struct (this)))) + c->check_struct (this), + c->check_array(axisSegmentMapsZ.arrayZ, sizeof (axisSegmentMapsZ[0]), axisCount)))) return_trace (false); - const SegmentMaps *map = axisSegmentMapsZ; + const SegmentMaps *map = axisSegmentMapsZ.arrayZ; unsigned int count = axisCount; for (unsigned int i = 0; i < count; i++) { @@ -124,7 +125,7 @@ struct avar { unsigned int count = MIN (coords_length, axisCount); - const SegmentMaps *map = axisSegmentMapsZ; + const SegmentMaps *map = axisSegmentMapsZ.arrayZ; for (unsigned int i = 0; i < count; i++) { coords[i] = map->map (coords[i]); @@ -139,7 +140,8 @@ struct avar HBUINT16 axisCount; /* The number of variation axes in the font. This * must be the same number as axisCount in the * 'fvar' table. */ - SegmentMaps axisSegmentMapsZ[VAR]; + UnsizedArrayOf + axisSegmentMapsZ; public: DEFINE_SIZE_MIN (8); diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index afd29046e..1a85b6e5d 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -46,20 +46,21 @@ struct InstanceRecord { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - c->check_array (coordinates, coordinates[0].static_size, axis_count)); + c->check_array (coordinatesZ.arrayZ, coordinatesZ[0].static_size, axis_count)); } protected: 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. */ + UnsizedArrayOf + coordinatesZ; /* The coordinates array for this instance. */ //NameID postScriptNameIDX;/*Optional. The name ID for entries in the 'name' // * table that provide PostScript names for this // * instance. */ public: - DEFINE_SIZE_ARRAY (4, coordinates); + DEFINE_SIZE_ARRAY (4, coordinatesZ); }; struct AxisRecord diff --git a/src/hb-ot-var-hvar-table.hh b/src/hb-ot-var-hvar-table.hh index 086e922fd..97300f42b 100644 --- a/src/hb-ot-var-hvar-table.hh +++ b/src/hb-ot-var-hvar-table.hh @@ -39,7 +39,7 @@ struct DeltaSetIndexMap { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - c->check_array (mapData, get_width (), mapCount)); + c->check_array (mapDataZ.arrayZ, get_width (), mapCount)); } unsigned int map (unsigned int v) const /* Returns 16.16 outer.inner. */ @@ -55,7 +55,7 @@ struct DeltaSetIndexMap unsigned int u = 0; { /* Fetch it. */ unsigned int w = get_width (); - const HBUINT8 *p = mapData + w * v; + const HBUINT8 *p = mapDataZ.arrayZ + w * v; for (; w; w--) u = (u << 8) + *p++; } @@ -81,10 +81,11 @@ struct DeltaSetIndexMap HBUINT16 format; /* A packed field that describes the compressed * representation of delta-set indices. */ HBUINT16 mapCount; /* The number of mapping entries. */ - HBUINT8 mapData[VAR]; /* The delta-set index mapping data. */ + UnsizedArrayOf + mapDataZ; /* The delta-set index mapping data. */ public: - DEFINE_SIZE_ARRAY (4, mapData); + DEFINE_SIZE_ARRAY (4, mapDataZ); }; diff --git a/src/hb-ot-var-mvar-table.hh b/src/hb-ot-var-mvar-table.hh index 20dd2200c..d10c3e9d8 100644 --- a/src/hb-ot-var-mvar-table.hh +++ b/src/hb-ot-var-mvar-table.hh @@ -68,14 +68,14 @@ struct MVAR c->check_struct (this) && valueRecordSize >= VariationValueRecord::static_size && varStore.sanitize (c, this) && - c->check_array (values, valueRecordSize, valueRecordCount)); + c->check_array (valuesZ.arrayZ, valueRecordSize, valueRecordCount)); } inline float get_var (hb_tag_t tag, int *coords, unsigned int coord_count) const { const VariationValueRecord *record; - record = (VariationValueRecord *) bsearch (&tag, values, + record = (VariationValueRecord *) bsearch (&tag, valuesZ.arrayZ, valueRecordCount, valueRecordSize, tag_compare); if (!record) @@ -101,11 +101,12 @@ protected: HBUINT16 valueRecordCount;/* The number of value records — may be zero. */ OffsetTo varStore; /* Offset to item variation store table. */ - HBUINT8 values[VAR]; /* Array of value records. The records must be + UnsizedArrayOf + valuesZ; /* Array of value records. The records must be * in binary order of their valueTag field. */ public: - DEFINE_SIZE_ARRAY (12, values); + DEFINE_SIZE_ARRAY (12, valuesZ); }; } /* namespace OT */ From 9507b05a7a65962d5d02eb424e4f5d8570976f4e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 23:18:07 +0200 Subject: [PATCH 11/39] Simplify sanitize->check_array() Fix a bug in CBDT sanitize, and redundant check in avar. --- src/hb-aat-layout-common.hh | 10 ++++------ src/hb-aat-layout-morx-table.hh | 2 +- src/hb-machinery.hh | 3 ++- src/hb-open-type.hh | 6 +++--- src/hb-ot-color-cbdt-table.hh | 4 ++-- src/hb-ot-kern-table.hh | 2 +- src/hb-ot-layout-common.hh | 2 +- src/hb-ot-layout-gpos-table.hh | 8 ++++---- src/hb-ot-layout-gsubgpos.hh | 4 ++-- src/hb-ot-math-table.hh | 8 ++------ src/hb-ot-name-table.hh | 2 +- src/hb-ot-var-avar-table.hh | 4 ++-- src/hb-ot-var-fvar-table.hh | 2 +- src/hb-ot-var-hvar-table.hh | 2 +- src/hb-ot-var-mvar-table.hh | 2 +- 15 files changed, 28 insertions(+), 33 deletions(-) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 25f4fe14a..85c40a71d 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -129,7 +129,7 @@ struct BinSearchArrayOf TRACE_SANITIZE (this); return_trace (header.sanitize (c) && Type::static_size >= header.unitSize && - c->check_array (bytesZ, header.unitSize, header.nUnits)); + c->check_array (bytesZ, header.nUnits, header.unitSize)); } protected: @@ -480,8 +480,8 @@ struct StateTable while (state < num_states) { if (unlikely (!c->check_array (states, - states[0].static_size * nClasses, - num_states))) + num_states, + states[0].static_size * nClasses))) return_trace (false); { /* Sweep new states. */ const HBUINT16 *stop = &states[num_states * nClasses]; @@ -490,9 +490,7 @@ struct StateTable state = num_states; } - if (unlikely (!c->check_array (entries, - entries[0].static_size, - num_entries))) + if (unlikely (!c->check_array (entries, num_entries))) return_trace (false); { /* Sweep new entries. */ const Entry *stop = &entries[num_entries]; diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index ef452e22b..6f7bf770a 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -648,7 +648,7 @@ struct Chain !c->check_range (this, length)) return_trace (false); - if (!c->check_array (featureZ, featureZ[0].static_size, featureCount)) + if (!c->check_array (featureZ, featureCount)) return_trace (false); const ChainSubtable *subtable = &StructAtOffset (featureZ, featureZ[0].static_size * featureCount); diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh index 62f490721..f80cfdb2e 100644 --- a/src/hb-machinery.hh +++ b/src/hb-machinery.hh @@ -296,7 +296,8 @@ struct hb_sanitize_context_t : return likely (ok); } - inline bool check_array (const void *base, unsigned int record_size, unsigned int len) const + template + inline bool check_array (const T *base, unsigned int len, unsigned int record_size = T::static_size) const { const char *p = (const char *) base; bool overflows = hb_unsigned_mul_overflows (len, record_size); diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index ef18163fa..49e52c6eb 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -345,7 +345,7 @@ struct UnsizedArrayOf 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)); + return_trace (c->check_array (arrayZ, count)); } public: @@ -487,7 +487,7 @@ struct ArrayOf inline bool sanitize_shallow (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); - return_trace (len.sanitize (c) && c->check_array (arrayZ, Type::static_size, len)); + return_trace (len.sanitize (c) && c->check_array (arrayZ, len)); } public: @@ -596,7 +596,7 @@ struct HeadlessArrayOf { TRACE_SANITIZE (this); return_trace (len.sanitize (c) && - (!len || c->check_array (arrayZ, Type::static_size, len - 1))); + (!len || c->check_array (arrayZ, len - 1))); } public: diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh index 8bedf2224..a5636975b 100644 --- a/src/hb-ot-color-cbdt-table.hh +++ b/src/hb-ot-color-cbdt-table.hh @@ -128,7 +128,7 @@ struct IndexSubtableFormat1Or3 { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - c->check_array (offsetArrayZ, offsetArrayZ[0].static_size, glyph_count + 1)); + c->check_array (offsetArrayZ, glyph_count + 1)); } bool get_image_data (unsigned int idx, @@ -240,7 +240,7 @@ struct IndexSubtableArray inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const { TRACE_SANITIZE (this); - if (unlikely (!c->check_array (&indexSubtablesZ, indexSubtablesZ[0].static_size, count))) + if (unlikely (!c->check_array (indexSubtablesZ, count))) return_trace (false); for (unsigned int i = 0; i < count; i++) if (unlikely (!indexSubtablesZ[i].sanitize (c, this))) diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh index 40f94be29..e9f109c3f 100644 --- a/src/hb-ot-kern-table.hh +++ b/src/hb-ot-kern-table.hh @@ -208,7 +208,7 @@ struct KernSubTableWrapper TRACE_SANITIZE (this); return_trace (c->check_struct (thiz()) && thiz()->length >= T::min_size && - c->check_array (thiz(), 1, thiz()->length) && + c->check_array (thiz(), thiz()->length, 1) && thiz()->subtable.sanitize (c, thiz()->format)); } }; diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index dd65f3384..e469ff879 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1542,7 +1542,7 @@ struct VarData regionIndices.sanitize(c) && shortCount <= regionIndices.len && c->check_array (&StructAfter (regionIndices), - get_row_size (), itemCount)); + itemCount, get_row_size ())); } protected: diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index 5847306d6..b3651f933 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -199,7 +199,7 @@ struct ValueFormat : HBUINT16 TRACE_SANITIZE (this); unsigned int len = get_len (); - if (!c->check_array (values, get_size (), count)) return_trace (false); + if (!c->check_array (values, count, get_size ())) return_trace (false); if (!has_device ()) return_trace (true); @@ -376,7 +376,7 @@ struct AnchorMatrix if (!c->check_struct (this)) return_trace (false); if (unlikely (hb_unsigned_mul_overflows (rows, cols))) return_trace (false); unsigned int count = rows * cols; - if (!c->check_array (matrixZ, matrixZ[0].static_size, count)) return_trace (false); + if (!c->check_array (matrixZ, count)) return_trace (false); for (unsigned int i = 0; i < count; i++) if (!matrixZ[i].sanitize (c, this)) return_trace (false); return_trace (true); @@ -698,7 +698,7 @@ struct PairSet { TRACE_SANITIZE (this); if (!(c->check_struct (this) - && c->check_array (arrayZ, HBUINT16::static_size * closure->stride, len))) return_trace (false); + && c->check_array (arrayZ, len, HBUINT16::static_size * closure->stride))) return_trace (false); unsigned int count = len; const PairValueRecord *record = CastP (arrayZ); @@ -869,7 +869,7 @@ struct PairPosFormat2 unsigned int stride = len1 + len2; unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size (); unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count; - return_trace (c->check_array (values, record_size, count) && + return_trace (c->check_array (values, count, record_size) && valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) && valueFormat2.sanitize_values_stride_unsafe (c, this, &values[len1], count, stride)); } diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index d4755655e..719a5050a 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -1677,11 +1677,11 @@ struct ContextFormat3 if (!c->check_struct (this)) return_trace (false); unsigned int count = glyphCount; if (!count) return_trace (false); /* We want to access coverageZ[0] freely. */ - if (!c->check_array (coverageZ.arrayZ, coverageZ[0].static_size, count)) return_trace (false); + if (!c->check_array (coverageZ.arrayZ, count)) return_trace (false); for (unsigned int i = 0; i < count; i++) if (!coverageZ[i].sanitize (c, this)) return_trace (false); const LookupRecord *lookupRecord = &StructAtOffset (coverageZ.arrayZ, coverageZ[0].static_size * count); - return_trace (c->check_array (lookupRecord, lookupRecord[0].static_size, lookupCount)); + return_trace (c->check_array (lookupRecord, lookupCount)); } protected: diff --git a/src/hb-ot-math-table.hh b/src/hb-ot-math-table.hh index b7ca167b1..1b2d550a7 100644 --- a/src/hb-ot-math-table.hh +++ b/src/hb-ot-math-table.hh @@ -242,9 +242,7 @@ struct MathKern { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - c->check_array (mathValueRecords, - mathValueRecords[0].static_size, - 2 * heightCount + 1) && + c->check_array (mathValueRecords, 2 * heightCount + 1) && sanitize_math_value_records (c)); } @@ -598,9 +596,7 @@ struct MathVariants return_trace (c->check_struct (this) && vertGlyphCoverage.sanitize (c, this) && horizGlyphCoverage.sanitize (c, this) && - c->check_array (glyphConstruction, - glyphConstruction[0].static_size, - vertGlyphCount + horizGlyphCount) && + c->check_array (glyphConstruction, vertGlyphCount + horizGlyphCount) && sanitize_offsets (c)); } diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh index a1de1193f..c1e7adbdd 100644 --- a/src/hb-ot-name-table.hh +++ b/src/hb-ot-name-table.hh @@ -118,7 +118,7 @@ struct name TRACE_SANITIZE (this); return_trace (c->check_struct (this) && likely (format == 0 || format == 1) && - c->check_array (nameRecord, nameRecord[0].static_size, count) && + c->check_array (nameRecord, count) && sanitize_records (c)); } diff --git a/src/hb-ot-var-avar-table.hh b/src/hb-ot-var-avar-table.hh index 5428c97bb..d100ca21e 100644 --- a/src/hb-ot-var-avar-table.hh +++ b/src/hb-ot-var-avar-table.hh @@ -93,6 +93,7 @@ struct SegmentMaps : ArrayOf (value - arrayZ[i-1].fromCoord) + denom/2) / denom; } + public: DEFINE_SIZE_ARRAY (2, arrayZ); }; @@ -105,8 +106,7 @@ struct avar TRACE_SANITIZE (this); if (unlikely (!(version.sanitize (c) && version.major == 1 && - c->check_struct (this), - c->check_array(axisSegmentMapsZ.arrayZ, sizeof (axisSegmentMapsZ[0]), axisCount)))) + c->check_struct (this)))) return_trace (false); const SegmentMaps *map = axisSegmentMapsZ.arrayZ; diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh index 1a85b6e5d..1d17a97eb 100644 --- a/src/hb-ot-var-fvar-table.hh +++ b/src/hb-ot-var-fvar-table.hh @@ -46,7 +46,7 @@ struct InstanceRecord { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - c->check_array (coordinatesZ.arrayZ, coordinatesZ[0].static_size, axis_count)); + c->check_array (coordinatesZ.arrayZ, axis_count)); } protected: diff --git a/src/hb-ot-var-hvar-table.hh b/src/hb-ot-var-hvar-table.hh index 97300f42b..d87285b7f 100644 --- a/src/hb-ot-var-hvar-table.hh +++ b/src/hb-ot-var-hvar-table.hh @@ -39,7 +39,7 @@ struct DeltaSetIndexMap { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - c->check_array (mapDataZ.arrayZ, get_width (), mapCount)); + c->check_array (mapDataZ.arrayZ, mapCount, get_width ())); } unsigned int map (unsigned int v) const /* Returns 16.16 outer.inner. */ diff --git a/src/hb-ot-var-mvar-table.hh b/src/hb-ot-var-mvar-table.hh index d10c3e9d8..d60c6b910 100644 --- a/src/hb-ot-var-mvar-table.hh +++ b/src/hb-ot-var-mvar-table.hh @@ -68,7 +68,7 @@ struct MVAR c->check_struct (this) && valueRecordSize >= VariationValueRecord::static_size && varStore.sanitize (c, this) && - c->check_array (valuesZ.arrayZ, valueRecordSize, valueRecordCount)); + c->check_array (valuesZ.arrayZ, valueRecordCount, valueRecordSize)); } inline float get_var (hb_tag_t tag, From dff2c45f1e2a30767f6813d3cb6a70978d98d424 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 23:29:26 +0200 Subject: [PATCH 12/39] Port rest from VAR to UnsizedArrayOf<> --- src/hb-aat-layout-common.hh | 14 ++++++------- src/hb-aat-layout-morx-table.hh | 16 +++++++-------- src/hb-open-type.hh | 10 ++++----- src/hb-ot-cmap-table.hh | 8 +++++--- src/hb-ot-color-cbdt-table.hh | 16 +++++++-------- src/hb-ot-glyf-table.hh | 10 ++++----- src/hb-ot-hdmx-table.hh | 30 ++++++++++++--------------- src/hb-ot-hmtx-table.hh | 8 ++++---- src/hb-ot-kern-table.hh | 20 +++++++++--------- src/hb-ot-layout-common.hh | 9 +++++---- src/hb-ot-layout-gpos-table.hh | 26 ++++++++++++------------ src/hb-ot-math-table.hh | 36 +++++++++++++++++---------------- src/hb-ot-maxp-table.hh | 2 +- src/hb-ot-name-table.hh | 13 ++++++------ src/hb-ot-post-table.hh | 5 +++-- 15 files changed, 113 insertions(+), 110 deletions(-) diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh index 85c40a71d..7a5be84cc 100644 --- a/src/hb-aat-layout-common.hh +++ b/src/hb-aat-layout-common.hh @@ -67,11 +67,11 @@ struct BinSearchArrayOf inline const Type& operator [] (unsigned int i) const { if (unlikely (i >= header.nUnits)) return Null(Type); - return StructAtOffset (bytesZ, i * header.unitSize); + return StructAtOffset (&bytesZ, i * header.unitSize); } inline Type& operator [] (unsigned int i) { - return StructAtOffset (bytesZ, i * header.unitSize); + return StructAtOffset (&bytesZ, i * header.unitSize); } inline unsigned int get_size (void) const { return header.static_size + header.nUnits * header.unitSize; } @@ -88,7 +88,7 @@ struct BinSearchArrayOf * pointed to do have a simple sanitize(), ie. they do not * reference other structs via offsets. */ - (void) (false && StructAtOffset (bytesZ, 0).sanitize (c)); + (void) (false && StructAtOffset (&bytesZ, 0).sanitize (c)); return_trace (true); } @@ -111,7 +111,7 @@ struct BinSearchArrayOf while (min <= max) { int mid = (min + max) / 2; - const Type *p = (const Type *) (((const char *) bytesZ) + (mid * size)); + const Type *p = (const Type *) (((const char *) &bytesZ) + (mid * size)); int c = p->cmp (key); if (c < 0) max = mid - 1; @@ -129,12 +129,12 @@ struct BinSearchArrayOf TRACE_SANITIZE (this); return_trace (header.sanitize (c) && Type::static_size >= header.unitSize && - c->check_array (bytesZ, header.nUnits, header.unitSize)); + c->check_array (bytesZ.arrayZ, header.nUnits, header.unitSize)); } protected: - BinSearchHeader header; - HBUINT8 bytesZ[VAR]; + BinSearchHeader header; + UnsizedArrayOf bytesZ; public: DEFINE_SIZE_ARRAY (10, bytesZ); }; diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh index 6f7bf770a..e4774c4c6 100644 --- a/src/hb-aat-layout-morx-table.hh +++ b/src/hb-aat-layout-morx-table.hh @@ -619,7 +619,7 @@ struct Chain { inline void apply (hb_aat_apply_context_t *c) const { - const ChainSubtable *subtable = &StructAtOffset (featureZ, featureZ[0].static_size * featureCount); + const ChainSubtable *subtable = &StructAtOffset (&featureZ, featureZ[0].static_size * featureCount); unsigned int count = subtableCount; for (unsigned int i = 0; i < count; i++) { @@ -648,10 +648,10 @@ struct Chain !c->check_range (this, length)) return_trace (false); - if (!c->check_array (featureZ, featureCount)) + if (!c->check_array (featureZ.arrayZ, featureCount)) return_trace (false); - const ChainSubtable *subtable = &StructAtOffset (featureZ, featureZ[0].static_size * featureCount); + const ChainSubtable *subtable = &StructAtOffset (&featureZ, featureZ[0].static_size * featureCount); unsigned int count = subtableCount; for (unsigned int i = 0; i < count; i++) { @@ -669,8 +669,8 @@ struct Chain HBUINT32 featureCount; /* Number of feature subtable entries. */ HBUINT32 subtableCount; /* The number of subtables in the chain. */ - Feature featureZ[VAR]; /* Features. */ -/*ChainSubtable subtableX[VAR];*//* Subtables. */ + UnsizedArrayOf featureZ; /* Features. */ +/*ChainSubtable firstSubtable;*//* Subtables. */ /*subtableGlyphCoverageArray*/ /* Only if major == 3. */ public: @@ -689,7 +689,7 @@ struct morx inline void apply (hb_aat_apply_context_t *c) const { c->set_lookup_index (0); - const Chain *chain = chainsZ; + const Chain *chain = &firstChain; unsigned int count = chainCount; for (unsigned int i = 0; i < count; i++) { @@ -706,7 +706,7 @@ struct morx !chainCount.sanitize (c)) return_trace (false); - const Chain *chain = chainsZ; + const Chain *chain = &firstChain; unsigned int count = chainCount; for (unsigned int i = 0; i < count; i++) { @@ -723,7 +723,7 @@ struct morx * 1 for mort, 2 or 3 for morx. */ HBUINT32 chainCount; /* Number of metamorphosis chains contained in this * table. */ - Chain chainsZ[VAR]; /* Chains. */ + Chain firstChain; /* Chains. */ public: DEFINE_SIZE_MIN (8); diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 49e52c6eb..27ec77204 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -349,7 +349,7 @@ struct UnsizedArrayOf } public: - Type arrayZ[VAR]; + Type arrayZ[VAR]; public: DEFINE_SIZE_ARRAY (0, arrayZ); }; @@ -491,8 +491,8 @@ struct ArrayOf } public: - LenType len; - Type arrayZ[VAR]; + LenType len; + Type arrayZ[VAR]; public: DEFINE_SIZE_ARRAY (sizeof (LenType), arrayZ); }; @@ -600,8 +600,8 @@ struct HeadlessArrayOf } public: - LenType len; - Type arrayZ[VAR]; + LenType len; + Type arrayZ[VAR]; public: DEFINE_SIZE_ARRAY (sizeof (LenType), arrayZ); }; diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh index e6876d12c..3f5fa01f5 100644 --- a/src/hb-ot-cmap-table.hh +++ b/src/hb-ot-cmap-table.hh @@ -231,7 +231,7 @@ struct CmapSubtableFormat4 inline void init (const CmapSubtableFormat4 *subtable) { segCount = subtable->segCountX2 / 2; - endCount = subtable->values; + endCount = subtable->values.arrayZ; startCount = endCount + segCount + 1; idDelta = startCount + segCount; idRangeOffset = idDelta + segCount; @@ -369,7 +369,8 @@ struct CmapSubtableFormat4 HBUINT16 entrySelector; /* log2(searchRange/2) */ HBUINT16 rangeShift; /* 2 x segCount - searchRange */ - HBUINT16 values[VAR]; + UnsizedArrayOf + values; #if 0 HBUINT16 endCount[segCount]; /* End characterCode for each segment, * last=0xFFFFu. */ @@ -377,7 +378,8 @@ struct CmapSubtableFormat4 HBUINT16 startCount[segCount]; /* Start character code for each segment. */ HBINT16 idDelta[segCount]; /* Delta for all character codes in segment. */ HBUINT16 idRangeOffset[segCount];/* Offsets into glyphIdArray or 0 */ - HBUINT16 glyphIdArray[VAR]; /* Glyph index array (arbitrary length) */ + UnsizedArrayOf + glyphIdArray; /* Glyph index array (arbitrary length) */ #endif public: diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh index a5636975b..7c172ce43 100644 --- a/src/hb-ot-color-cbdt-table.hh +++ b/src/hb-ot-color-cbdt-table.hh @@ -128,7 +128,7 @@ struct IndexSubtableFormat1Or3 { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - c->check_array (offsetArrayZ, glyph_count + 1)); + c->check_array (offsetArrayZ.arrayZ, glyph_count + 1)); } bool get_image_data (unsigned int idx, @@ -144,7 +144,8 @@ struct IndexSubtableFormat1Or3 } IndexSubtableHeader header; - Offset offsetArrayZ[VAR]; + UnsizedArrayOf > + offsetArrayZ; public: DEFINE_SIZE_ARRAY(8, offsetArrayZ); }; @@ -240,7 +241,7 @@ struct IndexSubtableArray inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const { TRACE_SANITIZE (this); - if (unlikely (!c->check_array (indexSubtablesZ, count))) + if (unlikely (!c->check_array (indexSubtablesZ.arrayZ, count))) return_trace (false); for (unsigned int i = 0; i < count; i++) if (unlikely (!indexSubtablesZ[i].sanitize (c, this))) @@ -255,15 +256,14 @@ struct IndexSubtableArray { unsigned int firstGlyphIndex = indexSubtablesZ[i].firstGlyphIndex; unsigned int lastGlyphIndex = indexSubtablesZ[i].lastGlyphIndex; - if (firstGlyphIndex <= glyph && glyph <= lastGlyphIndex) { + if (firstGlyphIndex <= glyph && glyph <= lastGlyphIndex) return &indexSubtablesZ[i]; - } } return nullptr; } protected: - IndexSubtableRecord indexSubtablesZ[VAR]; + UnsizedArrayOf indexSubtablesZ; public: DEFINE_SIZE_ARRAY(0, indexSubtablesZ); }; @@ -527,8 +527,8 @@ struct CBDT protected: - FixedVersion<> version; - HBUINT8 dataZ[VAR]; + FixedVersion<> version; + UnsizedArrayOf dataZ; public: DEFINE_SIZE_ARRAY(4, dataZ); }; diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh index 7c2098360..2145ac02b 100644 --- a/src/hb-ot-glyf-table.hh +++ b/src/hb-ot-glyf-table.hh @@ -54,7 +54,7 @@ struct loca } protected: - HBUINT8 dataZ[VAR]; /* Location data. */ + UnsizedArrayOf dataZ; /* Location data. */ DEFINE_SIZE_ARRAY (0, dataZ); }; @@ -375,13 +375,13 @@ struct glyf if (short_offset) { - const HBUINT16 *offsets = (const HBUINT16 *) loca_table->dataZ; + const HBUINT16 *offsets = (const HBUINT16 *) loca_table->dataZ.arrayZ; *start_offset = 2 * offsets[glyph]; *end_offset = 2 * offsets[glyph + 1]; } else { - const HBUINT32 *offsets = (const HBUINT32 *) loca_table->dataZ; + const HBUINT32 *offsets = (const HBUINT32 *) loca_table->dataZ.arrayZ; *start_offset = offsets[glyph]; *end_offset = offsets[glyph + 1]; @@ -418,7 +418,7 @@ struct glyf } while (composite_it.move_to_next()); if ( (uint16_t) last->flags & CompositeGlyphHeader::WE_HAVE_INSTRUCTIONS) - *instruction_start = ((char *) last - (char *) glyf_table->dataZ) + last->get_size(); + *instruction_start = ((char *) last - (char *) glyf_table->dataZ.arrayZ) + last->get_size(); else *instruction_start = end_offset; *instruction_end = end_offset; @@ -483,7 +483,7 @@ struct glyf }; protected: - HBUINT8 dataZ[VAR]; /* Glyphs data. */ + UnsizedArrayOf dataZ; /* Glyphs data. */ DEFINE_SIZE_ARRAY (0, dataZ); }; diff --git a/src/hb-ot-hdmx-table.hh b/src/hb-ot-hdmx-table.hh index 87dd6d018..04511b5d0 100644 --- a/src/hb-ot-hdmx-table.hh +++ b/src/hb-ot-hdmx-table.hh @@ -66,7 +66,7 @@ struct DeviceRecord if (unlikely (i >= len())) return nullptr; hb_codepoint_t gid = this->subset_plan->glyphs [i]; - const HBUINT8* width = &(this->source_device_record->widths[gid]); + const HBUINT8* width = &(this->source_device_record->widthsZ[gid]); if (width < ((const HBUINT8 *) this->source_device_record) + size_device_record) return width; @@ -77,11 +77,7 @@ struct DeviceRecord static inline unsigned int get_size (unsigned int count) { - unsigned int raw_size = min_size + count * HBUINT8::static_size; - if (raw_size % 4) - /* Align to 32 bits */ - return raw_size + (4 - (raw_size % 4)); - return raw_size; + return hb_ceil_to_4 (min_size + count * HBUINT8::static_size); } inline bool serialize (hb_serialize_context_t *c, const SubsetView &subset_view) @@ -107,7 +103,7 @@ struct DeviceRecord DEBUG_MSG(SUBSET, nullptr, "HDMX width for new gid %d is missing.", i); return_trace (false); } - widths[i].set (*width); + widthsZ[i].set (*width); } return_trace (true); @@ -120,11 +116,11 @@ struct DeviceRecord c->check_range (this, size_device_record))); } - HBUINT8 pixel_size; /* Pixel size for following widths (as ppem). */ - HBUINT8 max_width; /* Maximum width. */ - HBUINT8 widths[VAR]; /* Array of widths (numGlyphs is from the 'maxp' table). */ + HBUINT8 pixel_size; /* Pixel size for following widths (as ppem). */ + HBUINT8 max_width; /* Maximum width. */ + UnsizedArrayOf widthsZ; /* Array of widths (numGlyphs is from the 'maxp' table). */ public: - DEFINE_SIZE_ARRAY (2, widths); + DEFINE_SIZE_ARRAY (2, widthsZ); }; @@ -140,7 +136,7 @@ struct hdmx inline const DeviceRecord& operator [] (unsigned int i) const { if (unlikely (i >= num_records)) return Null(DeviceRecord); - return StructAtOffset (this->data, i * size_device_record); + return StructAtOffset (&this->dataZ, i * size_device_record); } inline bool serialize (hb_serialize_context_t *c, const hdmx *source_hdmx, hb_subset_plan_t *plan) @@ -211,12 +207,12 @@ struct hdmx } protected: - HBUINT16 version; /* Table version number (0) */ - HBUINT16 num_records; /* Number of device records. */ - HBUINT32 size_device_record; /* Size of a device record, 32-bit aligned. */ - HBUINT8 data[VAR]; /* Array of device records. */ + HBUINT16 version; /* Table version number (0) */ + HBUINT16 num_records; /* Number of device records. */ + HBUINT32 size_device_record; /* Size of a device record, 32-bit aligned. */ + UnsizedArrayOf dataZ; /* Array of device records. */ public: - DEFINE_SIZE_ARRAY (8, data); + DEFINE_SIZE_ARRAY (8, dataZ); }; } /* namespace OT */ diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh index 3e4b3bdef..363395ab0 100644 --- a/src/hb-ot-hmtx-table.hh +++ b/src/hb-ot-hmtx-table.hh @@ -262,7 +262,7 @@ struct hmtxvmtx return default_advance; } - return table->longMetric[MIN (glyph, (uint32_t) num_advances - 1)].advance; + return table->longMetricZ[MIN (glyph, (uint32_t) num_advances - 1)].advance; } inline unsigned int get_advance (hb_codepoint_t glyph, @@ -295,7 +295,7 @@ struct hmtxvmtx }; protected: - LongMetric longMetric[VAR]; /* Paired advance width and leading + UnsizedArrayOflongMetricZ;/* Paired advance width and leading * bearing values for each glyph. The * value numOfHMetrics comes from * the 'hhea' table. If the font is @@ -303,7 +303,7 @@ struct hmtxvmtx * be in the array, but that entry is * required. The last entry applies to * all subsequent glyphs. */ -/*FWORD leadingBearingX[VAR];*/ /* Here the advance is assumed +/*UnsizedArrayOf leadingBearingX;*//* Here the advance is assumed * to be the same as the advance * for the last entry above. The * number of entries in this array is @@ -317,7 +317,7 @@ struct hmtxvmtx * font to vary the side bearing * values for each glyph. */ public: - DEFINE_SIZE_ARRAY (0, longMetric); + DEFINE_SIZE_ARRAY (0, longMetricZ); }; struct hmtx : hmtxvmtx { diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh index e9f109c3f..8ed6298f1 100644 --- a/src/hb-ot-kern-table.hh +++ b/src/hb-ot-kern-table.hh @@ -222,7 +222,7 @@ struct KernTable inline int get_h_kerning (hb_codepoint_t left, hb_codepoint_t right, unsigned int table_length) const { int v = 0; - const typename T::SubTableWrapper *st = CastP (thiz()->data); + const typename T::SubTableWrapper *st = CastP (&thiz()->dataZ); unsigned int count = thiz()->nTables; for (unsigned int i = 0; i < count; i++) { @@ -241,7 +241,7 @@ struct KernTable thiz()->version != T::VERSION)) return_trace (false); - const typename T::SubTableWrapper *st = CastP (thiz()->data); + const typename T::SubTableWrapper *st = CastP (&thiz()->dataZ); unsigned int count = thiz()->nTables; for (unsigned int i = 0; i < count; i++) { @@ -287,11 +287,11 @@ struct KernOT : KernTable }; protected: - HBUINT16 version; /* Version--0x0000u */ - HBUINT16 nTables; /* Number of subtables in the kerning table. */ - HBUINT8 data[VAR]; + HBUINT16 version; /* Version--0x0000u */ + HBUINT16 nTables; /* Number of subtables in the kerning table. */ + UnsizedArrayOf dataZ; public: - DEFINE_SIZE_ARRAY (4, data); + DEFINE_SIZE_ARRAY (4, dataZ); }; struct KernAAT : KernTable @@ -327,11 +327,11 @@ struct KernAAT : KernTable }; protected: - HBUINT32 version; /* Version--0x00010000u */ - HBUINT32 nTables; /* Number of subtables in the kerning table. */ - HBUINT8 data[VAR]; + HBUINT32 version; /* Version--0x00010000u */ + HBUINT32 nTables; /* Number of subtables in the kerning table. */ + UnsizedArrayOf dataZ; public: - DEFINE_SIZE_ARRAY (8, data); + DEFINE_SIZE_ARRAY (8, dataZ); }; struct kern diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh index e469ff879..8a3a703b3 100644 --- a/src/hb-ot-layout-common.hh +++ b/src/hb-ot-layout-common.hh @@ -1549,7 +1549,7 @@ struct VarData HBUINT16 itemCount; HBUINT16 shortCount; ArrayOf regionIndices; - HBUINT8 bytesX[VAR]; + UnsizedArrayOfbytesX; public: DEFINE_SIZE_ARRAY2 (6, regionIndices, bytesX); }; @@ -1844,7 +1844,7 @@ struct HintingDevice unsigned int s = ppem_size - startSize; - unsigned int byte = deltaValue[s >> (4 - f)]; + unsigned int byte = deltaValueZ[s >> (4 - f)]; unsigned int bits = (byte >> (16 - (((s & ((1 << (4 - f)) - 1)) + 1) << f))); unsigned int mask = (0xFFFFu >> (16 - (1 << f))); @@ -1864,9 +1864,10 @@ struct HintingDevice * 2 Signed 4-bit value, 4 values per uint16 * 3 Signed 8-bit value, 2 values per uint16 */ - HBUINT16 deltaValue[VAR]; /* Array of compressed data */ + UnsizedArrayOf + deltaValueZ; /* Array of compressed data */ public: - DEFINE_SIZE_ARRAY (6, deltaValue); + DEFINE_SIZE_ARRAY (6, deltaValueZ); }; struct VariationDevice diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh index b3651f933..1a96609d0 100644 --- a/src/hb-ot-layout-gpos-table.hh +++ b/src/hb-ot-layout-gpos-table.hh @@ -376,7 +376,7 @@ struct AnchorMatrix if (!c->check_struct (this)) return_trace (false); if (unlikely (hb_unsigned_mul_overflows (rows, cols))) return_trace (false); unsigned int count = rows * cols; - if (!c->check_array (matrixZ, count)) return_trace (false); + if (!c->check_array (matrixZ.arrayZ, count)) return_trace (false); for (unsigned int i = 0; i < count; i++) if (!matrixZ[i].sanitize (c, this)) return_trace (false); return_trace (true); @@ -384,8 +384,8 @@ struct AnchorMatrix HBUINT16 rows; /* Number of rows */ protected: - OffsetTo - matrixZ[VAR]; /* Matrix of offsets to Anchor tables-- + UnsizedArrayOf > + matrixZ; /* Matrix of offsets to Anchor tables-- * from beginning of AnchorMatrix table */ public: DEFINE_SIZE_ARRAY (2, matrixZ); @@ -621,7 +621,7 @@ struct PairSet unsigned int len2 = valueFormats[1].get_len (); unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2); - const PairValueRecord *record = CastP (arrayZ); + const PairValueRecord *record = &firstPairValueRecord; unsigned int count = len; for (unsigned int i = 0; i < count; i++) { @@ -640,7 +640,7 @@ struct PairSet unsigned int len2 = valueFormats[1].get_len (); unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2); - const PairValueRecord *record = CastP (arrayZ); + const PairValueRecord *record = &firstPairValueRecord; c->input->add_array (&record->secondGlyph, len, record_size); } @@ -654,7 +654,6 @@ struct PairSet unsigned int len2 = valueFormats[1].get_len (); unsigned int record_size = HBUINT16::static_size * (1 + len1 + len2); - const PairValueRecord *record_array = CastP (arrayZ); unsigned int count = len; /* Hand-coded bsearch. */ @@ -665,7 +664,7 @@ struct PairSet while (min <= max) { int mid = (min + max) / 2; - const PairValueRecord *record = &StructAtOffset (record_array, record_size * mid); + const PairValueRecord *record = &StructAtOffset (&firstPairValueRecord, record_size * mid); hb_codepoint_t mid_x = record->secondGlyph; if (x < mid_x) max = mid - 1; @@ -698,20 +697,21 @@ struct PairSet { TRACE_SANITIZE (this); if (!(c->check_struct (this) - && c->check_array (arrayZ, len, HBUINT16::static_size * closure->stride))) return_trace (false); + && c->check_array (&firstPairValueRecord, len, HBUINT16::static_size * closure->stride))) return_trace (false); unsigned int count = len; - const PairValueRecord *record = CastP (arrayZ); + const PairValueRecord *record = &firstPairValueRecord; return_trace (closure->valueFormats[0].sanitize_values_stride_unsafe (c, closure->base, &record->values[0], count, closure->stride) && closure->valueFormats[1].sanitize_values_stride_unsafe (c, closure->base, &record->values[closure->len1], count, closure->stride)); } protected: - HBUINT16 len; /* Number of PairValueRecords */ - HBUINT16 arrayZ[VAR]; /* Array of PairValueRecords--ordered - * by GlyphID of the second glyph */ + HBUINT16 len; /* Number of PairValueRecords */ + PairValueRecord firstPairValueRecord; + /* Array of PairValueRecords--ordered + * by GlyphID of the second glyph */ public: - DEFINE_SIZE_ARRAY (2, arrayZ); + DEFINE_SIZE_MIN (2); }; struct PairPosFormat1 diff --git a/src/hb-ot-math-table.hh b/src/hb-ot-math-table.hh index 1b2d550a7..87ebdc7d7 100644 --- a/src/hb-ot-math-table.hh +++ b/src/hb-ot-math-table.hh @@ -234,7 +234,7 @@ struct MathKern TRACE_SANITIZE (this); unsigned int count = 2 * heightCount + 1; for (unsigned int i = 0; i < count; i++) - if (!mathValueRecords[i].sanitize (c, this)) return_trace (false); + if (!mathValueRecordsZ.arrayZ[i].sanitize (c, this)) return_trace (false); return_trace (true); } @@ -242,14 +242,14 @@ struct MathKern { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - c->check_array (mathValueRecords, 2 * heightCount + 1) && + c->check_array (mathValueRecordsZ.arrayZ, 2 * heightCount + 1) && sanitize_math_value_records (c)); } inline hb_position_t get_value (hb_position_t correction_height, hb_font_t *font) const { - const MathValueRecord* correctionHeight = mathValueRecords; - const MathValueRecord* kernValue = mathValueRecords + heightCount; + const MathValueRecord* correctionHeight = mathValueRecordsZ.arrayZ; + const MathValueRecord* kernValue = mathValueRecordsZ.arrayZ + heightCount; int sign = font->y_scale < 0 ? -1 : +1; /* The description of the MathKern table is a ambiguous, but interpreting @@ -277,18 +277,19 @@ struct MathKern } protected: - HBUINT16 heightCount; - MathValueRecord mathValueRecords[VAR]; /* Array of correction heights at - * which the kern value changes. - * Sorted by the height value in - * design units (heightCount entries), - * Followed by: - * Array of kern values corresponding - * to heights. (heightCount+1 entries). - */ + HBUINT16 heightCount; + UnsizedArrayOf + mathValueRecordsZ; /* Array of correction heights at + * which the kern value changes. + * Sorted by the height value in + * design units (heightCount entries), + * Followed by: + * Array of kern values corresponding + * to heights. (heightCount+1 entries). + */ public: - DEFINE_SIZE_ARRAY (2, mathValueRecords); + DEFINE_SIZE_ARRAY (2, mathValueRecordsZ); }; struct MathKernInfoRecord @@ -586,7 +587,7 @@ struct MathVariants TRACE_SANITIZE (this); unsigned int count = vertGlyphCount + horizGlyphCount; for (unsigned int i = 0; i < count; i++) - if (!glyphConstruction[i].sanitize (c, this)) return_trace (false); + if (!glyphConstruction.arrayZ[i].sanitize (c, this)) return_trace (false); return_trace (true); } @@ -596,7 +597,7 @@ struct MathVariants return_trace (c->check_struct (this) && vertGlyphCoverage.sanitize (c, this) && horizGlyphCoverage.sanitize (c, this) && - c->check_array (glyphConstruction, vertGlyphCount + horizGlyphCount) && + c->check_array (glyphConstruction.arrayZ, vertGlyphCount + horizGlyphCount) && sanitize_offsets (c)); } @@ -666,7 +667,8 @@ struct MathVariants /* Array of offsets to MathGlyphConstruction tables - from the beginning of the MathVariants table, for shapes growing in vertical/horizontal direction. */ - OffsetTo glyphConstruction[VAR]; + UnsizedArrayOf > + glyphConstruction; public: DEFINE_SIZE_ARRAY (10, glyphConstruction); diff --git a/src/hb-ot-maxp-table.hh b/src/hb-ot-maxp-table.hh index efcf593e9..2572ad288 100644 --- a/src/hb-ot-maxp-table.hh +++ b/src/hb-ot-maxp-table.hh @@ -136,7 +136,7 @@ struct maxp FixedVersion<>version; /* Version of the maxp table (0.5 or 1.0), * 0x00005000u or 0x00010000u. */ HBUINT16 numGlyphs; /* The number of glyphs in the font. */ -/*maxpV1Tail v1Tail[VAR]; */ +/*maxpV1Tail v1Tail[VAR]; */ public: DEFINE_SIZE_STATIC (6); }; diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh index c1e7adbdd..bb49c2cb0 100644 --- a/src/hb-ot-name-table.hh +++ b/src/hb-ot-name-table.hh @@ -91,7 +91,7 @@ struct name key.encodingID.set (encoding_id); key.languageID.set (language_id); key.nameID.set (name_id); - NameRecord *match = (NameRecord *) bsearch (&key, nameRecord, count, sizeof (nameRecord[0]), NameRecord::cmp); + NameRecord *match = (NameRecord *) bsearch (&key, nameRecordZ.arrayZ, count, sizeof (nameRecordZ[0]), NameRecord::cmp); if (!match) return 0; @@ -102,14 +102,14 @@ struct name } inline unsigned int get_size (void) const - { return min_size + count * nameRecord[0].min_size; } + { return min_size + count * nameRecordZ[0].min_size; } inline bool sanitize_records (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); char *string_pool = (char *) this + stringOffset; unsigned int _count = count; for (unsigned int i = 0; i < _count; i++) - if (!nameRecord[i].sanitize (c, string_pool)) return_trace (false); + if (!nameRecordZ[i].sanitize (c, string_pool)) return_trace (false); return_trace (true); } @@ -118,7 +118,7 @@ struct name TRACE_SANITIZE (this); return_trace (c->check_struct (this) && likely (format == 0 || format == 1) && - c->check_array (nameRecord, count) && + c->check_array (nameRecordZ.arrayZ, count) && sanitize_records (c)); } @@ -126,9 +126,10 @@ struct name HBUINT16 format; /* Format selector (=0/1). */ HBUINT16 count; /* Number of name records. */ Offset16 stringOffset; /* Offset to start of string storage (from start of table). */ - NameRecord nameRecord[VAR]; /* The name records where count is the number of records. */ + UnsizedArrayOf + nameRecordZ; /* The name records where count is the number of records. */ public: - DEFINE_SIZE_ARRAY (6, nameRecord); + DEFINE_SIZE_ARRAY (6, nameRecordZ); }; diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh index d0265d056..29dc86fa8 100644 --- a/src/hb-ot-post-table.hh +++ b/src/hb-ot-post-table.hh @@ -55,10 +55,11 @@ struct postV2Tail return_trace (glyphNameIndex.sanitize (c)); } - ArrayOfglyphNameIndex; /* This is not an offset, but is the + ArrayOf glyphNameIndex; /* This is not an offset, but is the * ordinal number of the glyph in 'post' * string tables. */ - HBUINT8 namesX[VAR]; /* Glyph names with length bytes [variable] + UnsizedArrayOf + namesX; /* Glyph names with length bytes [variable] * (a Pascal string). */ DEFINE_SIZE_ARRAY2 (2, glyphNameIndex, namesX); From bccf3e1827eec07433340eea705597201b6d0a32 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 01:04:50 +0200 Subject: [PATCH 13/39] Minor --- src/hb-open-type.hh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 27ec77204..5d09c5208 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -299,7 +299,6 @@ static inline Type& operator + (Base &base, OffsetTo &offset) * Array Types */ -/* TODO Use it in ArrayOf, HeadlessArrayOf, and other places around the code base?? */ template struct UnsizedArrayOf { From 13a8786c7c580651d8a6db9345b9aa85ca8ed956 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 01:07:06 +0200 Subject: [PATCH 14/39] Add (unused) hb_array_t<> --- src/hb-dsalgs.hh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh index 7e06ff170..def968eb7 100644 --- a/src/hb-dsalgs.hh +++ b/src/hb-dsalgs.hh @@ -29,6 +29,8 @@ #include "hb.hh" +#include "hb-null.hh" + /* Void! For when we need a expression-type of void. */ typedef const struct _hb_void_t *hb_void_t; @@ -507,6 +509,24 @@ struct hb_auto_t : Type void fini (void) {} }; +template +struct hb_array_t +{ + inline hb_array_t (void) : arrayZ (nullptr), len (0) {} + inline hb_array_t (const T *array_, unsigned int len_) : arrayZ (array_), len (len_) {} + + inline const T& operator [] (unsigned int i) const + { + if (unlikely (i >= len)) return Null(T); + return arrayZ[i]; + } + + inline void free (void) { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; } + + const T *arrayZ; + unsigned int len; +}; + struct hb_bytes_t { inline hb_bytes_t (void) : bytes (nullptr), len (0) {} From becd84aa2f2902ea9d2d1677b28945e103a68816 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 01:26:18 +0200 Subject: [PATCH 15/39] Add HB_FEATURE_GLOBAL_START/END Fixes https://github.com/harfbuzz/harfbuzz/issues/1141 New API: HB_FEATURE_GLOBAL_START HB_FEATURE_GLOBAL_END --- docs/harfbuzz-sections.txt | 2 ++ src/hb-common.cc | 4 ++-- src/hb-common.h | 13 +++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/docs/harfbuzz-sections.txt b/docs/harfbuzz-sections.txt index ca0e908fe..b69c16860 100644 --- a/docs/harfbuzz-sections.txt +++ b/docs/harfbuzz-sections.txt @@ -582,6 +582,8 @@ hb_set_union
hb-shape +HB_FEATURE_GLOBAL_END +HB_FEATURE_GLOBAL_START hb_feature_t hb_feature_from_string hb_feature_to_string diff --git a/src/hb-common.cc b/src/hb-common.cc index ed3fed2a3..c1651232a 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -877,8 +877,8 @@ parse_feature_indices (const char **pp, const char *end, hb_feature_t *feature) bool has_start; - feature->start = 0; - feature->end = (unsigned int) -1; + feature->start = HB_FEATURE_GLOBAL_START; + feature->end = HB_FEATURE_GLOBAL_END; if (!parse_char (pp, end, '[')) return true; diff --git a/src/hb-common.h b/src/hb-common.h index 5dc1ebcd2..fdceff9dc 100644 --- a/src/hb-common.h +++ b/src/hb-common.h @@ -379,6 +379,19 @@ typedef void (*hb_destroy_func_t) (void *user_data); /* Font features and variations. */ +/** + * HB_FEATURE_GLOBAL_START + * + * Since: REPLACEME + */ +#define HB_FEATURE_GLOBAL_START 0 +/** + * HB_FEATURE_GLOBAL_END + * + * Since: REPLACEME + */ +#define HB_FEATURE_GLOBAL_END ((unsigned int) -1) + typedef struct hb_feature_t { hb_tag_t tag; uint32_t value; From 96471fe8593575deceb44d3757c227f65f10a25e Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 01:39:23 +0200 Subject: [PATCH 16/39] [uniscribe] Fix build --- src/hb-uniscribe.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-uniscribe.cc b/src/hb-uniscribe.cc index 4a77c8c1f..b77baa2fe 100644 --- a/src/hb-uniscribe.cc +++ b/src/hb-uniscribe.cc @@ -392,7 +392,7 @@ _hb_rename_font (hb_blob_t *blob, wchar_t *new_name) name.stringOffset.set (name.get_size ()); for (unsigned int i = 0; i < ARRAY_LENGTH (name_IDs); i++) { - OT::NameRecord &record = name.nameRecord[i]; + OT::NameRecord &record = name.nameRecordZ[i]; record.platformID.set (3); record.encodingID.set (1); record.languageID.set (0x0409u); /* English */ From c2a75e07e54314f6c611dda0f050ed5f09909e43 Mon Sep 17 00:00:00 2001 From: David Corbett Date: Thu, 25 Jan 2018 14:22:03 -0500 Subject: [PATCH 17/39] Implement 'rand' --- src/hb-ot-layout-gsub-table.hh | 19 ++++++++++++------- src/hb-ot-layout-gsubgpos.hh | 8 ++++++++ src/hb-ot-layout.cc | 8 ++++++++ src/hb-ot-map.cc | 7 +++++-- src/hb-ot-map.hh | 4 +++- src/hb-ot-shape.cc | 1 + 6 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 76a0ea6d3..db24a2841 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -534,16 +534,21 @@ struct AlternateSet if (unlikely (!count)) return_trace (false); - hb_mask_t glyph_mask = c->buffer->cur().mask; - hb_mask_t lookup_mask = c->lookup_mask; + if (c->random) { + c->random_state = (0x5DEECE66Dull * c->random_state + 11) & (((uint64_t) 1 << 48) - 1); + c->replace_glyph (alternates[(c->random_state >> 32) % count]); + } else { + hb_mask_t glyph_mask = c->buffer->cur().mask; + hb_mask_t lookup_mask = c->lookup_mask; - /* Note: This breaks badly if two features enabled this lookup together. */ - unsigned int shift = hb_ctz (lookup_mask); - unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift); + /* Note: This breaks badly if two features enabled this lookup together. */ + unsigned int shift = hb_ctz (lookup_mask); + unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift); - if (unlikely (alt_index > count || alt_index == 0)) return_trace (false); + if (unlikely (alt_index > count || alt_index == 0)) return_trace (false); - c->replace_glyph (alternates[alt_index - 1]); + c->replace_glyph (alternates[alt_index - 1]); + } return_trace (true); } diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 719a5050a..113433d96 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -480,6 +480,8 @@ struct hb_ot_apply_context_t : bool auto_zwnj; bool auto_zwj; + bool random; + uint64_t random_state; bool has_glyph_classes; @@ -500,11 +502,17 @@ struct hb_ot_apply_context_t : debug_depth (0), auto_zwnj (true), auto_zwj (true), + random (false), + random_state (0), has_glyph_classes (gdef.has_glyph_classes ()) {} inline void set_lookup_mask (hb_mask_t mask) { lookup_mask = mask; } inline void set_auto_zwj (bool auto_zwj_) { auto_zwj = auto_zwj_; } inline void set_auto_zwnj (bool auto_zwnj_) { auto_zwnj = auto_zwnj_; } + inline void set_random_state (uint64_t random_state_) { + random = true; + random_state = random_state_; + } inline void set_recurse_func (recurse_func_t func) { recurse_func = func; } inline void set_lookup_index (unsigned int lookup_index_) { lookup_index = lookup_index_; } inline void set_lookup_props (unsigned int lookup_props_) diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index a1220f4dd..b31dbbca9 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1268,6 +1268,14 @@ inline void hb_ot_map_t::apply (const Proxy &proxy, c.set_lookup_mask (lookups[table_index][i].mask); c.set_auto_zwj (lookups[table_index][i].auto_zwj); c.set_auto_zwnj (lookups[table_index][i].auto_zwnj); + if (lookups[table_index][i].random) + { + uint64_t random_state = 1; + for (unsigned int j = 0; j < buffer->len; j++) + random_state = 31 * random_state + buffer->info[j].codepoint; + c.set_random_state (random_state); + buffer->unsafe_to_break_all (); + } apply_string (&c, proxy.table.get_lookup (lookup_index), proxy.accels[lookup_index]); diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index 29f52dcc2..fb320e29c 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -95,7 +95,8 @@ hb_ot_map_builder_t::add_lookups (hb_ot_map_t &m, unsigned int variations_index, hb_mask_t mask, bool auto_zwnj, - bool auto_zwj) + bool auto_zwj, + bool random) { unsigned int lookup_indices[32]; unsigned int offset, len; @@ -122,6 +123,7 @@ hb_ot_map_builder_t::add_lookups (hb_ot_map_t &m, lookup->index = lookup_indices[i]; lookup->auto_zwnj = auto_zwnj; lookup->auto_zwj = auto_zwj; + lookup->random = random; } offset += len; @@ -301,7 +303,8 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, variations_index, m.features[i].mask, m.features[i].auto_zwnj, - m.features[i].auto_zwj); + m.features[i].auto_zwj, + m.features[i].tag == HB_TAG ('r','a','n','d')); /* Sort lookups and merge duplicates */ if (last_num_lookups < m.lookups[table_index].len) diff --git a/src/hb-ot-map.hh b/src/hb-ot-map.hh index 32a9e7e00..2518a4923 100644 --- a/src/hb-ot-map.hh +++ b/src/hb-ot-map.hh @@ -61,6 +61,7 @@ struct hb_ot_map_t unsigned short index; unsigned short auto_zwnj : 1; unsigned short auto_zwj : 1; + unsigned short random : 1; hb_mask_t mask; static int cmp (const void *pa, const void *pb) @@ -206,7 +207,8 @@ struct hb_ot_map_builder_t unsigned int variations_index, hb_mask_t mask, bool auto_zwnj = true, - bool auto_zwj = true); + bool auto_zwj = true, + bool random = false); struct feature_info_t { hb_tag_t tag; diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 63102f6b0..f5aeb0dfc 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -49,6 +49,7 @@ static hb_tag_t common_features[] = { HB_TAG('m','a','r','k'), HB_TAG('m','k','m','k'), HB_TAG('r','l','i','g'), + HB_TAG('r','a','n','d'), }; From f05df643b44d9bbfd742e93f02c235fc821190d0 Mon Sep 17 00:00:00 2001 From: David Corbett Date: Fri, 26 Jan 2018 21:36:15 -0500 Subject: [PATCH 18/39] Allow requesting a specific glyph for 'rand' Randomization only happens by default. If the user specifies a value for 'rand', that value is respected. --- src/hb-ot-map.cc | 3 ++- src/hb-ot-map.hh | 4 +++- src/hb-ot-shape.cc | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index fb320e29c..8617f054b 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -254,6 +254,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, map->stage[1] = info->stage[1]; map->auto_zwnj = !(info->flags & F_MANUAL_ZWNJ); map->auto_zwj = !(info->flags & F_MANUAL_ZWJ); + map->random = !!(info->flags & F_RANDOM); if ((info->flags & F_GLOBAL) && info->max_value == 1) { /* Uses the global bit */ map->shift = global_bit_shift; @@ -304,7 +305,7 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, m.features[i].mask, m.features[i].auto_zwnj, m.features[i].auto_zwj, - m.features[i].tag == HB_TAG ('r','a','n','d')); + m.features[i].random); /* Sort lookups and merge duplicates */ if (last_num_lookups < m.lookups[table_index].len) diff --git a/src/hb-ot-map.hh b/src/hb-ot-map.hh index 2518a4923..091cb3b66 100644 --- a/src/hb-ot-map.hh +++ b/src/hb-ot-map.hh @@ -52,6 +52,7 @@ struct hb_ot_map_t unsigned int needs_fallback : 1; unsigned int auto_zwnj : 1; unsigned int auto_zwj : 1; + unsigned int random : 1; inline int cmp (const hb_tag_t *tag_) const { return *tag_ < tag ? -1 : *tag_ > tag ? 1 : 0; } @@ -168,7 +169,8 @@ enum hb_ot_map_feature_flags_t { F_HAS_FALLBACK = 0x0002u, /* Has fallback implementation, so include mask bit even if feature not found. */ F_MANUAL_ZWNJ = 0x0004u, /* Don't skip over ZWNJ when matching **context**. */ F_MANUAL_ZWJ = 0x0008u, /* Don't skip over ZWJ when matching **input**. */ - F_GLOBAL_SEARCH = 0x0010u /* If feature not found in LangSys, look for it in global feature list and pick one. */ + F_GLOBAL_SEARCH = 0x0010u, /* If feature not found in LangSys, look for it in global feature list and pick one. */ + F_RANDOM = 0x0020u /* Randomly select a glyph from an AlternateSubstFormat1 subtable. */ }; HB_MARK_AS_FLAG_T (hb_ot_map_feature_flags_t); /* Macro version for where const is desired. */ diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index f5aeb0dfc..0007e0ab1 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -49,7 +49,6 @@ static hb_tag_t common_features[] = { HB_TAG('m','a','r','k'), HB_TAG('m','k','m','k'), HB_TAG('r','l','i','g'), - HB_TAG('r','a','n','d'), }; @@ -71,6 +70,7 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, unsigned int num_user_features) { hb_ot_map_builder_t *map = &planner->map; + bool default_rand = true; map->add_global_bool_feature (HB_TAG('r','v','r','n')); map->add_gsub_pause (nullptr); @@ -123,7 +123,12 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, map->add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1) ? F_GLOBAL : F_NONE); + if (feature->tag == HB_TAG ('r','a','n','d')) + default_rand = false; } + + if (default_rand) + map->add_feature (HB_TAG ('r','a','n','d'), 1, F_GLOBAL | F_RANDOM); } From 2de96e846844d21888af6893378b21a33fc19232 Mon Sep 17 00:00:00 2001 From: David Corbett Date: Sat, 27 Jan 2018 19:48:38 -0500 Subject: [PATCH 19/39] Test 'rand' --- test/shaping/data/in-house/Makefile.sources | 1 + .../5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf | Bin 0 -> 1352 bytes test/shaping/data/in-house/tests/rand.tests | 3 +++ 3 files changed, 4 insertions(+) create mode 100644 test/shaping/data/in-house/fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf create mode 100644 test/shaping/data/in-house/tests/rand.tests diff --git a/test/shaping/data/in-house/Makefile.sources b/test/shaping/data/in-house/Makefile.sources index ef16faed4..1bb8604ef 100644 --- a/test/shaping/data/in-house/Makefile.sources +++ b/test/shaping/data/in-house/Makefile.sources @@ -32,6 +32,7 @@ TESTS = \ tests/mongolian-variation-selector.tests \ tests/myanmar-syllable.tests \ tests/none-directional.tests \ + tests/rand.tests \ tests/spaces.tests \ tests/simple.tests \ tests/sinhala.tests \ diff --git a/test/shaping/data/in-house/fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf b/test/shaping/data/in-house/fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf new file mode 100644 index 0000000000000000000000000000000000000000..588ce3b9360622d5e936187bc0b233cc45ed8a19 GIT binary patch literal 1352 zcmZuxU1(cX9RHttZ`w3pb!$^Fz!uuPFv@IeF>gbuV1e!!^8?5j@157Y-A6e8}SiVtr0#-v<-=iYt@dJgCO|G(e= z>zs4Xxd~NGP=KBzkxoucPs{5E9{Gldz9VA4%*0Pk(>@9kNm+0MGs#3Me&Ng#umLR3 zq|%T6`1a>3z^?+opGb{IpLlIHP9&ZLo}I5~i*%PT4*V0x#k`gajV>XVa1A(C1R+Jl ze%ObBM~fAszCXo2fc;P4`zl&}k%CF6bOWPH*D87OfZq%MH-R5oT&NlLMT(;SB(O{b zU#ymqBoJfFo7PK4zGiU!pw&y(D6_@{YfQ8TrH=J%EA@B4V~+H$Si*jDY#;dW@#pP^O zDJM@YROj-Bu~Qc-c|c$~}ef z?Qw3Xy6xVa7TeX3W}X zHrl1F(nKHqb94kF>gXJAb94kf>U1Z+ShqLnoOlzt9u%%SRd-Tx z>BX+EvR4Q-g-gOGU@p6o{Y()ifF+N(8^G7R+mcV8%F$<}Qbv^RW2jLlyo8+!!iTue zGQxR^5xh<&^}rSac69-Ih|;7}i44k94f9#Z0xeOQG^#p-` z1rG?F^BLR5tlGByo`VVh2HyDlxC#~3sp_0?0G#09kWK+vS#R%tZ7SC z%GQ?43w*B5Q`XQbWz3Z_Ja_Bx3cN9-$vL-!Gx%}fT)6aN@G}bFn+!ur_`+R~-LUjP O`pEC>g`cJXO#c8Dqc-aR literal 0 HcmV?d00001 diff --git a/test/shaping/data/in-house/tests/rand.tests b/test/shaping/data/in-house/tests/rand.tests new file mode 100644 index 000000000..f1023e828 --- /dev/null +++ b/test/shaping/data/in-house/tests/rand.tests @@ -0,0 +1,3 @@ +../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=-rand:U+0054,U+0055,U+0056:[1=0+560|2=1+602|3=2+602] +../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=rand=2:U+0054,U+0055,U+0056:[5=0+560|8=1+602|11=2+602] +../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names:U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056:[4=0+560|7=1+602|11=2+602|6=3+560|8=4+602|10=5+602|5=6+560|9=7+602|10=8+602|5=9+560|7=10+602|12=11+602] From b545e27d8891f1e7f1fd034dd84abe44c839c380 Mon Sep 17 00:00:00 2001 From: David Corbett Date: Fri, 23 Feb 2018 12:22:32 -0500 Subject: [PATCH 20/39] Don't seed the RNG from the contents of the buffer --- src/hb-ot-layout-gsubgpos.hh | 7 ++----- src/hb-ot-layout.cc | 5 +---- test/shaping/data/in-house/tests/rand.tests | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 113433d96..3a028f346 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -503,16 +503,13 @@ struct hb_ot_apply_context_t : auto_zwnj (true), auto_zwj (true), random (false), - random_state (0), + random_state (1), has_glyph_classes (gdef.has_glyph_classes ()) {} inline void set_lookup_mask (hb_mask_t mask) { lookup_mask = mask; } inline void set_auto_zwj (bool auto_zwj_) { auto_zwj = auto_zwj_; } inline void set_auto_zwnj (bool auto_zwnj_) { auto_zwnj = auto_zwnj_; } - inline void set_random_state (uint64_t random_state_) { - random = true; - random_state = random_state_; - } + inline void set_random (bool random_) { random = random_; } inline void set_recurse_func (recurse_func_t func) { recurse_func = func; } inline void set_lookup_index (unsigned int lookup_index_) { lookup_index = lookup_index_; } inline void set_lookup_props (unsigned int lookup_props_) diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc index b31dbbca9..51c119858 100644 --- a/src/hb-ot-layout.cc +++ b/src/hb-ot-layout.cc @@ -1270,10 +1270,7 @@ inline void hb_ot_map_t::apply (const Proxy &proxy, c.set_auto_zwnj (lookups[table_index][i].auto_zwnj); if (lookups[table_index][i].random) { - uint64_t random_state = 1; - for (unsigned int j = 0; j < buffer->len; j++) - random_state = 31 * random_state + buffer->info[j].codepoint; - c.set_random_state (random_state); + c.set_random (true); buffer->unsafe_to_break_all (); } apply_string (&c, diff --git a/test/shaping/data/in-house/tests/rand.tests b/test/shaping/data/in-house/tests/rand.tests index f1023e828..781abf429 100644 --- a/test/shaping/data/in-house/tests/rand.tests +++ b/test/shaping/data/in-house/tests/rand.tests @@ -1,3 +1,3 @@ ../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=-rand:U+0054,U+0055,U+0056:[1=0+560|2=1+602|3=2+602] ../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=rand=2:U+0054,U+0055,U+0056:[5=0+560|8=1+602|11=2+602] -../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names:U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056:[4=0+560|7=1+602|11=2+602|6=3+560|8=4+602|10=5+602|5=6+560|9=7+602|10=8+602|5=9+560|7=10+602|12=11+602] +../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names:U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056:[6=0+560|9=1+602|10=2+602|6=3+560|9=4+602|12=5+602|5=6+560|8=7+602|11=8+602|6=9+560|8=10+602|10=11+602] From 80de4bcd2677bfb0907ea7059524f918b109ac37 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 16:24:52 +0200 Subject: [PATCH 21/39] Minor clean up of 'rand' patchset --- src/hb-ot-layout-gsub-table.hh | 7 +++++-- src/hb-ot-layout-gsubgpos.hh | 7 ++++--- src/hb-ot-shape.cc | 13 ++++++------- test/shaping/data/in-house/tests/rand.tests | 2 +- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index db24a2841..ae679441b 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -534,10 +534,13 @@ struct AlternateSet if (unlikely (!count)) return_trace (false); - if (c->random) { + if (c->random) + { c->random_state = (0x5DEECE66Dull * c->random_state + 11) & (((uint64_t) 1 << 48) - 1); c->replace_glyph (alternates[(c->random_state >> 32) % count]); - } else { + } + else + { hb_mask_t glyph_mask = c->buffer->cur().mask; hb_mask_t lookup_mask = c->lookup_mask; diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index 3a028f346..df0322646 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -478,11 +478,12 @@ struct hb_ot_apply_context_t : unsigned int nesting_level_left; unsigned int debug_depth; + bool has_glyph_classes; bool auto_zwnj; bool auto_zwj; bool random; + uint64_t random_state; - bool has_glyph_classes; hb_ot_apply_context_t (unsigned int table_index_, @@ -500,11 +501,11 @@ struct hb_ot_apply_context_t : lookup_props (0), nesting_level_left (HB_MAX_NESTING_LEVEL), debug_depth (0), + has_glyph_classes (gdef.has_glyph_classes ()), auto_zwnj (true), auto_zwj (true), random (false), - random_state (1), - has_glyph_classes (gdef.has_glyph_classes ()) {} + random_state (1) {} inline void set_lookup_mask (hb_mask_t mask) { lookup_mask = mask; } inline void set_auto_zwj (bool auto_zwj_) { auto_zwj = auto_zwj_; } diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 0007e0ab1..00a8a6472 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -70,7 +70,6 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, unsigned int num_user_features) { hb_ot_map_builder_t *map = &planner->map; - bool default_rand = true; map->add_global_bool_feature (HB_TAG('r','v','r','n')); map->add_gsub_pause (nullptr); @@ -91,10 +90,14 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, break; } + /* Automatic fractions. */ map->add_feature (HB_TAG ('f','r','a','c'), 1, F_NONE); map->add_feature (HB_TAG ('n','u','m','r'), 1, F_NONE); map->add_feature (HB_TAG ('d','n','o','m'), 1, F_NONE); + /* Random! */ + map->add_feature (HB_TAG ('r','a','n','d'), 1, F_GLOBAL | F_RANDOM); + if (planner->shaper->collect_features) planner->shaper->collect_features (planner); @@ -118,17 +121,13 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, if (planner->shaper->override_features) planner->shaper->override_features (planner); - for (unsigned int i = 0; i < num_user_features; i++) { + for (unsigned int i = 0; i < num_user_features; i++) + { const hb_feature_t *feature = &user_features[i]; map->add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1) ? F_GLOBAL : F_NONE); - if (feature->tag == HB_TAG ('r','a','n','d')) - default_rand = false; } - - if (default_rand) - map->add_feature (HB_TAG ('r','a','n','d'), 1, F_GLOBAL | F_RANDOM); } diff --git a/test/shaping/data/in-house/tests/rand.tests b/test/shaping/data/in-house/tests/rand.tests index 781abf429..5ea0fc046 100644 --- a/test/shaping/data/in-house/tests/rand.tests +++ b/test/shaping/data/in-house/tests/rand.tests @@ -1,3 +1,3 @@ ../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=-rand:U+0054,U+0055,U+0056:[1=0+560|2=1+602|3=2+602] -../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=rand=2:U+0054,U+0055,U+0056:[5=0+560|8=1+602|11=2+602] +#../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=rand=2:U+0054,U+0055,U+0056:[5=0+560|8=1+602|11=2+602] ../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names:U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056:[6=0+560|9=1+602|10=2+602|6=3+560|9=4+602|12=5+602|5=6+560|8=7+602|11=8+602|6=9+560|8=10+602|10=11+602] From cc1c4fdf88f6953dcd07fb42ee963404657cdef4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 16:36:05 +0200 Subject: [PATCH 22/39] Respect user's wish if they set rand feature manually Except if the set it to 1, which would mean "randomize"... Ugly. --- src/hb-ot-layout-gsub-table.hh | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index ae679441b..255a2827e 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -534,24 +534,26 @@ struct AlternateSet if (unlikely (!count)) return_trace (false); - if (c->random) + hb_mask_t glyph_mask = c->buffer->cur().mask; + hb_mask_t lookup_mask = c->lookup_mask; + + /* Note: This breaks badly if two features enabled this lookup together. */ + unsigned int shift = hb_ctz (lookup_mask); + unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift); + + if (unlikely (alt_index > count || alt_index == 0)) return_trace (false); + + /* This is ugly... If alt_index is 1, we take it as "on", and randomize + * feature if it is the rand feature. If it's > 1, it's a user-set value + * for sure, so respect it. So, user cannot set rand=1 and expect it to + * choose the first alternate... */ + if (alt_index == 1 && c->random) { c->random_state = (0x5DEECE66Dull * c->random_state + 11) & (((uint64_t) 1 << 48) - 1); - c->replace_glyph (alternates[(c->random_state >> 32) % count]); + alt_index = (c->random_state >> 32) % count + 1; } - else - { - hb_mask_t glyph_mask = c->buffer->cur().mask; - hb_mask_t lookup_mask = c->lookup_mask; - /* Note: This breaks badly if two features enabled this lookup together. */ - unsigned int shift = hb_ctz (lookup_mask); - unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift); - - if (unlikely (alt_index > count || alt_index == 0)) return_trace (false); - - c->replace_glyph (alternates[alt_index - 1]); - } + c->replace_glyph (alternates[alt_index - 1]); return_trace (true); } From 71c9f84e7c0afe41a8987b8a4ebc2b45a22fac56 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Mon, 10 Sep 2018 22:37:19 +0200 Subject: [PATCH 23/39] Make --features rand=1 available to the user Use rand=255 to mean "randomize". Part of https://github.com/harfbuzz/harfbuzz/pull/803 --- src/hb-ot-layout-gsub-table.hh | 11 ++++------- src/hb-ot-layout-gsubgpos.hh | 1 + src/hb-ot-map.cc | 4 ++-- src/hb-ot-map.hh | 3 +++ src/hb-ot-shape.cc | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index 255a2827e..dfa50979a 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -541,18 +541,15 @@ struct AlternateSet unsigned int shift = hb_ctz (lookup_mask); unsigned int alt_index = ((lookup_mask & glyph_mask) >> shift); - if (unlikely (alt_index > count || alt_index == 0)) return_trace (false); - - /* This is ugly... If alt_index is 1, we take it as "on", and randomize - * feature if it is the rand feature. If it's > 1, it's a user-set value - * for sure, so respect it. So, user cannot set rand=1 and expect it to - * choose the first alternate... */ - if (alt_index == 1 && c->random) + /* If alt_index is MAX, randomize feature if it is the rand feature. */ + if (alt_index == HB_OT_MAP_MAX_VALUE && c->random) { c->random_state = (0x5DEECE66Dull * c->random_state + 11) & (((uint64_t) 1 << 48) - 1); alt_index = (c->random_state >> 32) % count + 1; } + if (unlikely (alt_index > count || alt_index == 0)) return_trace (false); + c->replace_glyph (alternates[alt_index - 1]); return_trace (true); diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index df0322646..be1b449c8 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -33,6 +33,7 @@ #include "hb-buffer.hh" #include "hb-map.hh" #include "hb-set.hh" +#include "hb-ot-map.hh" #include "hb-ot-layout-common.hh" #include "hb-ot-layout-gdef-table.hh" diff --git a/src/hb-ot-map.cc b/src/hb-ot-map.cc index 8617f054b..cb70583f4 100644 --- a/src/hb-ot-map.cc +++ b/src/hb-ot-map.cc @@ -210,8 +210,8 @@ hb_ot_map_builder_t::compile (hb_ot_map_t &m, /* Uses the global bit */ bits_needed = 0; else - /* Limit to 8 bits per feature. */ - bits_needed = MIN(8u, hb_bit_storage (info->max_value)); + /* Limit bits per feature. */ + bits_needed = MIN(HB_OT_MAP_MAX_BITS, hb_bit_storage (info->max_value)); if (!info->max_value || next_bit + bits_needed > 8 * sizeof (hb_mask_t)) continue; /* Feature disabled, or not enough bits. */ diff --git a/src/hb-ot-map.hh b/src/hb-ot-map.hh index 091cb3b66..cc36fa277 100644 --- a/src/hb-ot-map.hh +++ b/src/hb-ot-map.hh @@ -32,6 +32,9 @@ #include "hb-buffer.hh" +#define HB_OT_MAP_MAX_BITS 8u +#define HB_OT_MAP_MAX_VALUE ((1u << HB_OT_MAP_MAX_BITS) - 1u) + struct hb_ot_shape_plan_t; static const hb_tag_t table_tags[2] = {HB_OT_TAG_GSUB, HB_OT_TAG_GPOS}; diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc index 00a8a6472..437b0feb4 100644 --- a/src/hb-ot-shape.cc +++ b/src/hb-ot-shape.cc @@ -96,7 +96,7 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner, map->add_feature (HB_TAG ('d','n','o','m'), 1, F_NONE); /* Random! */ - map->add_feature (HB_TAG ('r','a','n','d'), 1, F_GLOBAL | F_RANDOM); + map->add_feature (HB_TAG ('r','a','n','d'), HB_OT_MAP_MAX_VALUE, F_GLOBAL | F_RANDOM); if (planner->shaper->collect_features) planner->shaper->collect_features (planner); From 08260c708ae6adc4efa9bde5e9ede01b7e4d42cc Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 10:51:19 +0200 Subject: [PATCH 24/39] [random] Shuffle --- src/hb-ot-layout-gsub-table.hh | 5 +---- src/hb-ot-layout-gsubgpos.hh | 6 ++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh index dfa50979a..4d5db6aec 100644 --- a/src/hb-ot-layout-gsub-table.hh +++ b/src/hb-ot-layout-gsub-table.hh @@ -543,10 +543,7 @@ struct AlternateSet /* If alt_index is MAX, randomize feature if it is the rand feature. */ if (alt_index == HB_OT_MAP_MAX_VALUE && c->random) - { - c->random_state = (0x5DEECE66Dull * c->random_state + 11) & (((uint64_t) 1 << 48) - 1); - alt_index = (c->random_state >> 32) % count + 1; - } + alt_index = c->random_number () % count + 1; if (unlikely (alt_index > count || alt_index == 0)) return_trace (false); diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index be1b449c8..cb71759eb 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -521,6 +521,12 @@ struct hb_ot_apply_context_t : iter_context.init (this, true); } + inline uint32_t random_number (void) + { + random_state = (0x5DEECE66Dull * random_state + 11) & (((uint64_t) 1 << 48) - 1); + return random_state >> 32; + } + inline bool match_properties_mark (hb_codepoint_t glyph, unsigned int glyph_props, From cfdea884754ed40ffa5cc00cb1ecaa86cb46a394 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 10:57:48 +0200 Subject: [PATCH 25/39] [random] Switch to 32bit RNG --- src/hb-ot-layout-gsubgpos.hh | 7 ++++--- test/shaping/data/in-house/tests/rand.tests | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh index cb71759eb..eae73ce33 100644 --- a/src/hb-ot-layout-gsubgpos.hh +++ b/src/hb-ot-layout-gsubgpos.hh @@ -484,7 +484,7 @@ struct hb_ot_apply_context_t : bool auto_zwj; bool random; - uint64_t random_state; + uint32_t random_state; hb_ot_apply_context_t (unsigned int table_index_, @@ -523,8 +523,9 @@ struct hb_ot_apply_context_t : inline uint32_t random_number (void) { - random_state = (0x5DEECE66Dull * random_state + 11) & (((uint64_t) 1 << 48) - 1); - return random_state >> 32; + /* http://www.cplusplus.com/reference/random/minstd_rand/ */ + random_state = random_state * 48271 % 2147483647; + return random_state; } inline bool diff --git a/test/shaping/data/in-house/tests/rand.tests b/test/shaping/data/in-house/tests/rand.tests index 5ea0fc046..df324b921 100644 --- a/test/shaping/data/in-house/tests/rand.tests +++ b/test/shaping/data/in-house/tests/rand.tests @@ -1,3 +1,3 @@ ../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=-rand:U+0054,U+0055,U+0056:[1=0+560|2=1+602|3=2+602] -#../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=rand=2:U+0054,U+0055,U+0056:[5=0+560|8=1+602|11=2+602] -../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names:U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056:[6=0+560|9=1+602|10=2+602|6=3+560|9=4+602|12=5+602|5=6+560|8=7+602|11=8+602|6=9+560|8=10+602|10=11+602] +../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names --features=rand=2:U+0054,U+0055,U+0056:[5=0+560|8=1+602|11=2+602] +../fonts/5bb74492f5e0ffa1fbb72e4c881be035120b6513.ttf:--no-glyph-names:U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056,U+0054,U+0055,U+0056:[5=0+560|7=1+602|10=2+602|4=3+560|7=4+602|10=5+602|6=6+560|9=7+602|10=8+602|5=9+560|8=10+602|12=11+602] From 0f520adaacca3c7b6d8e84a7722343184105f612 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 12:02:34 +0200 Subject: [PATCH 26/39] Revert "Remove unused hb_cache_t" This reverts commit 473b17af4d421f4ce7ac18c769731bb2aa4088f8. Updates to recent changes. --- src/Makefile.sources | 1 + src/hb-cache.hh | 75 ++++++++++++++++++++++++++++++++++++++++++++ src/hb-ft.cc | 1 + 3 files changed, 77 insertions(+) create mode 100644 src/hb-cache.hh diff --git a/src/Makefile.sources b/src/Makefile.sources index 654255e20..46af3ae57 100644 --- a/src/Makefile.sources +++ b/src/Makefile.sources @@ -7,6 +7,7 @@ HB_BASE_sources = \ hb-buffer.hh \ hb-buffer-serialize.cc \ hb-buffer.cc \ + hb-cache.hh \ hb-common.cc \ hb-debug.hh \ hb-dsalgs.hh \ diff --git a/src/hb-cache.hh b/src/hb-cache.hh new file mode 100644 index 000000000..fd6a01e50 --- /dev/null +++ b/src/hb-cache.hh @@ -0,0 +1,75 @@ +/* + * Copyright © 2012 Google, Inc. + * + * 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. + * + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_CACHE_HH +#define HB_CACHE_HH + +#include "hb.hh" + + +/* Implements a lock-free cache for int->int functions. */ + +template +struct hb_cache_t +{ + static_assert ((key_bits >= cache_bits), ""); + static_assert ((key_bits + value_bits - cache_bits < 8 * sizeof (unsigned int)), ""); + + inline void init (void) { clear (); } + inline void fini (void) {} + + inline void clear (void) + { memset (values, 255, sizeof (values)); } + + inline bool get (unsigned int key, unsigned int *value) + { + unsigned int k = key & ((1u<> value_bits) != (key >> cache_bits)) + return false; + *value = v & ((1u<> key_bits) || (value >> value_bits))) + return false; /* Overflows */ + unsigned int k = key & ((1u<>cache_bits)< hb_cmap_cache_t; +typedef hb_cache_t<16, 24, 8> hb_advance_cache_t; + + +#endif /* HB_CACHE_HH */ diff --git a/src/hb-ft.cc b/src/hb-ft.cc index 5d6abb29d..ef38c7439 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -33,6 +33,7 @@ #include "hb-font.hh" #include "hb-machinery.hh" +#include "hb-cache.hh" #include FT_ADVANCES_H #include FT_MULTIPLE_MASTERS_H From 0ea42e117ba2c76e118974fe114ae5d9ceef5743 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 12:22:42 +0200 Subject: [PATCH 27/39] [cache] Minor --- src/hb-cache.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-cache.hh b/src/hb-cache.hh index fd6a01e50..0858e11bf 100644 --- a/src/hb-cache.hh +++ b/src/hb-cache.hh @@ -44,7 +44,7 @@ struct hb_cache_t inline void clear (void) { memset (values, 255, sizeof (values)); } - inline bool get (unsigned int key, unsigned int *value) + inline bool get (unsigned int key, unsigned int *value) const { unsigned int k = key & ((1u< Date: Tue, 11 Sep 2018 12:55:54 +0200 Subject: [PATCH 28/39] [ot-font] Add advances() callbacks --- src/hb-ot-font.cc | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index a4c5584fb..86aeb411c 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -46,7 +46,6 @@ hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED, hb_codepoint_t unicode, hb_codepoint_t *glyph, void *user_data HB_UNUSED) - { const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; return ot_font->cmap.get_relaxed()->get_nominal_glyph (unicode, glyph); @@ -74,6 +73,26 @@ hb_ot_get_glyph_h_advance (hb_font_t *font, return font->em_scale_x (ot_font->hmtx.get_relaxed ()->get_advance (glyph, font)); } +static void +hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride, + void *user_data HB_UNUSED) +{ + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; + const OT::hmtx_accelerator_t &hmtx = *ot_font->hmtx.get_relaxed (); + + for (unsigned int i = 0; i < count; i++) + { + *first_advance = font->em_scale_x (hmtx.get_advance (*first_glyph, font)); + first_glyph = &StructAtOffset (first_glyph, glyph_stride); + first_advance = &StructAtOffset (first_advance, advance_stride); + } +} + static hb_position_t hb_ot_get_glyph_v_advance (hb_font_t *font, void *font_data, @@ -84,6 +103,26 @@ hb_ot_get_glyph_v_advance (hb_font_t *font, return font->em_scale_y (-(int) ot_font->vmtx.get_relaxed ()->get_advance (glyph, font)); } +static void +hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride, + void *user_data HB_UNUSED) +{ + const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; + const OT::vmtx_accelerator_t &vmtx = *ot_font->vmtx.get_relaxed (); + + for (unsigned int i = 0; i < count; i++) + { + *first_advance = font->em_scale_y (-(int) vmtx.get_advance (*first_glyph, font)); + first_glyph = &StructAtOffset (first_glyph, glyph_stride); + first_advance = &StructAtOffset (first_advance, advance_stride); + } +} + static hb_position_t hb_ot_get_glyph_h_kerning (hb_font_t *font, void *font_data, @@ -179,7 +218,9 @@ static struct hb_ot_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t Date: Tue, 11 Sep 2018 12:56:17 +0200 Subject: [PATCH 29/39] [ot-font] Rename --- src/hb-ot-font.cc | 74 +++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc index 86aeb411c..faacecb91 100644 --- a/src/hb-ot-font.cc +++ b/src/hb-ot-font.cc @@ -47,8 +47,8 @@ hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED, hb_codepoint_t *glyph, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - return ot_font->cmap.get_relaxed()->get_nominal_glyph (unicode, glyph); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + return ot_face->cmap.get_relaxed()->get_nominal_glyph (unicode, glyph); } static hb_bool_t @@ -59,8 +59,8 @@ hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED, hb_codepoint_t *glyph, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - return ot_font->cmap.get_relaxed ()->get_variation_glyph (unicode, variation_selector, glyph); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + return ot_face->cmap.get_relaxed ()->get_variation_glyph (unicode, variation_selector, glyph); } static hb_position_t @@ -69,8 +69,8 @@ hb_ot_get_glyph_h_advance (hb_font_t *font, hb_codepoint_t glyph, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - return font->em_scale_x (ot_font->hmtx.get_relaxed ()->get_advance (glyph, font)); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + return font->em_scale_x (ot_face->hmtx.get_relaxed ()->get_advance (glyph, font)); } static void @@ -82,8 +82,8 @@ hb_ot_get_glyph_h_advances (hb_font_t* font, void* font_data, unsigned advance_stride, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - const OT::hmtx_accelerator_t &hmtx = *ot_font->hmtx.get_relaxed (); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + const OT::hmtx_accelerator_t &hmtx = *ot_face->hmtx.get_relaxed (); for (unsigned int i = 0; i < count; i++) { @@ -99,8 +99,8 @@ hb_ot_get_glyph_v_advance (hb_font_t *font, hb_codepoint_t glyph, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - return font->em_scale_y (-(int) ot_font->vmtx.get_relaxed ()->get_advance (glyph, font)); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + return font->em_scale_y (-(int) ot_face->vmtx.get_relaxed ()->get_advance (glyph, font)); } static void @@ -112,8 +112,8 @@ hb_ot_get_glyph_v_advances (hb_font_t* font, void* font_data, unsigned advance_stride, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - const OT::vmtx_accelerator_t &vmtx = *ot_font->vmtx.get_relaxed (); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + const OT::vmtx_accelerator_t &vmtx = *ot_face->vmtx.get_relaxed (); for (unsigned int i = 0; i < count; i++) { @@ -130,8 +130,8 @@ hb_ot_get_glyph_h_kerning (hb_font_t *font, hb_codepoint_t right_glyph, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - return font->em_scale_x (ot_font->kern->get_h_kerning (left_glyph, right_glyph)); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + return font->em_scale_x (ot_face->kern->get_h_kerning (left_glyph, right_glyph)); } static hb_bool_t @@ -141,10 +141,10 @@ hb_ot_get_glyph_extents (hb_font_t *font, hb_glyph_extents_t *extents, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - bool ret = ot_font->glyf->get_extents (glyph, extents); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + bool ret = ot_face->glyf->get_extents (glyph, extents); if (!ret) - ret = ot_font->CBDT->get_extents (glyph, extents); + ret = ot_face->CBDT->get_extents (glyph, extents); // TODO Hook up side-bearings variations. extents->x_bearing = font->em_scale_x (extents->x_bearing); extents->y_bearing = font->em_scale_y (extents->y_bearing); @@ -160,8 +160,8 @@ hb_ot_get_glyph_name (hb_font_t *font HB_UNUSED, char *name, unsigned int size, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - return ot_font->post->get_glyph_name (glyph, name, size); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + return ot_face->post->get_glyph_name (glyph, name, size); } static hb_bool_t @@ -171,8 +171,8 @@ hb_ot_get_glyph_from_name (hb_font_t *font HB_UNUSED, hb_codepoint_t *glyph, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - return ot_font->post->get_glyph_from_name (name, len, glyph); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + return ot_face->post->get_glyph_from_name (name, len, glyph); } static hb_bool_t @@ -181,12 +181,12 @@ hb_ot_get_font_h_extents (hb_font_t *font, hb_font_extents_t *metrics, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - metrics->ascender = font->em_scale_y (ot_font->hmtx.get_relaxed ()->ascender); - metrics->descender = font->em_scale_y (ot_font->hmtx.get_relaxed ()->descender); - metrics->line_gap = font->em_scale_y (ot_font->hmtx.get_relaxed ()->line_gap); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + metrics->ascender = font->em_scale_y (ot_face->hmtx.get_relaxed ()->ascender); + metrics->descender = font->em_scale_y (ot_face->hmtx.get_relaxed ()->descender); + metrics->line_gap = font->em_scale_y (ot_face->hmtx.get_relaxed ()->line_gap); // TODO Hook up variations. - return ot_font->hmtx.get_relaxed ()->has_font_extents; + return ot_face->hmtx.get_relaxed ()->has_font_extents; } static hb_bool_t @@ -195,19 +195,19 @@ hb_ot_get_font_v_extents (hb_font_t *font, hb_font_extents_t *metrics, void *user_data HB_UNUSED) { - const hb_ot_face_data_t *ot_font = (const hb_ot_face_data_t *) font_data; - metrics->ascender = font->em_scale_x (ot_font->vmtx.get_relaxed ()->ascender); - metrics->descender = font->em_scale_x (ot_font->vmtx.get_relaxed ()->descender); - metrics->line_gap = font->em_scale_x (ot_font->vmtx.get_relaxed ()->line_gap); + const hb_ot_face_data_t *ot_face = (const hb_ot_face_data_t *) font_data; + metrics->ascender = font->em_scale_x (ot_face->vmtx.get_relaxed ()->ascender); + metrics->descender = font->em_scale_x (ot_face->vmtx.get_relaxed ()->descender); + metrics->line_gap = font->em_scale_x (ot_face->vmtx.get_relaxed ()->line_gap); // TODO Hook up variations. - return ot_font->vmtx.get_relaxed ()->has_font_extents; + return ot_face->vmtx.get_relaxed ()->has_font_extents; } #ifdef HB_USE_ATEXIT static void free_static_ot_funcs (void); #endif -static struct hb_ot_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t +static struct hb_ot_face_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t { static inline hb_font_funcs_t *create (void) { @@ -264,15 +264,15 @@ void hb_ot_font_set_funcs (hb_font_t *font) { if (unlikely (!hb_ot_shaper_face_data_ensure (font->face))) return; - hb_ot_face_data_t *ot_font = hb_ot_face_data (font->face); + hb_ot_face_data_t *ot_face = hb_ot_face_data (font->face); /* Load them lazies. We access them with get_relaxed() for performance. */ - ot_font->cmap.get (); - ot_font->hmtx.get (); - ot_font->vmtx.get (); + ot_face->cmap.get (); + ot_face->hmtx.get (); + ot_face->vmtx.get (); hb_font_set_funcs (font, _hb_ot_get_font_funcs (), - ot_font, + ot_face, nullptr); } From 237f21537842e6b471cdd6c86b98edfc0da0756c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 13:05:47 +0200 Subject: [PATCH 30/39] [ft] Add advances() callback --- src/hb-ft.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/hb-ft.cc b/src/hb-ft.cc index ef38c7439..5d78cdfbb 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -228,6 +228,32 @@ hb_ft_get_glyph_h_advance (hb_font_t *font, return (v + (1<<9)) >> 10; } +static void +hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride, + void *user_data HB_UNUSED) +{ + const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; + FT_Face ft_face = ft_font->ft_face; + int load_flags = ft_font->load_flags; + + int mult = font->x_scale < 0 ? -1 : +1; + FT_Fixed v; + + for (unsigned int i = 0; i < count; i++) + { + v = 0; + FT_Get_Advance (ft_face, *first_glyph, load_flags, &v); + *first_advance = (v * mult + (1<<9)) >> 10; + first_glyph = &StructAtOffset (first_glyph, glyph_stride); + first_advance = &StructAtOffset (first_advance, advance_stride); + } +} + static hb_position_t hb_ft_get_glyph_v_advance (hb_font_t *font, void *font_data, @@ -433,6 +459,7 @@ static struct hb_ft_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t Date: Tue, 11 Sep 2018 14:05:16 +0200 Subject: [PATCH 31/39] [ft] Towards caching slow get_h_advance results Related to https://github.com/harfbuzz/harfbuzz/pull/1082 --- src/hb-ft.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/src/hb-ft.cc b/src/hb-ft.cc index 5d78cdfbb..856a9f79b 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -239,14 +239,30 @@ hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data, { const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; FT_Face ft_face = ft_font->ft_face; - int load_flags = ft_font->load_flags; + int load_flags; int mult = font->x_scale < 0 ? -1 : +1; - FT_Fixed v; - for (unsigned int i = 0; i < count; i++) + unsigned int i = 0; + + load_flags = ft_font->load_flags | FT_ADVANCE_FLAG_FAST_ONLY; + for (; i < count; i++) { - v = 0; + FT_Fixed v = 0; + if (unlikely (FT_Get_Advance (ft_face, *first_glyph, load_flags, &v))) + goto slow; + *first_advance = (v * mult + (1<<9)) >> 10; + first_glyph = &StructAtOffset (first_glyph, glyph_stride); + first_advance = &StructAtOffset (first_advance, advance_stride); + } + return; + +slow: + /* TODO Prepare and use cache. */ + load_flags = ft_font->load_flags;// & ~FT_ADVANCE_FLAG_FAST_ONLY; + for (; i < count; i++) + { + FT_Fixed v = 0; FT_Get_Advance (ft_face, *first_glyph, load_flags, &v); *first_advance = (v * mult + (1<<9)) >> 10; first_glyph = &StructAtOffset (first_glyph, glyph_stride); From 93f7596254808d567b9e1e01fb4855efcd34677c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 14:11:10 +0200 Subject: [PATCH 32/39] [util] Add -n shorthand for --num-iterations Meh. --- util/options.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/options.cc b/util/options.cc index 57cc4aa8d..29028070e 100644 --- a/util/options.cc +++ b/util/options.cc @@ -419,7 +419,7 @@ shape_options_t::add_options (option_parser_t *parser) {"cluster-level", 0, 0, G_OPTION_ARG_INT, &this->cluster_level, "Cluster merging level (default: 0)", "0/1/2"}, {"normalize-glyphs",0, 0, G_OPTION_ARG_NONE, &this->normalize_glyphs, "Rearrange glyph clusters in nominal order", nullptr}, {"verify", 0, 0, G_OPTION_ARG_NONE, &this->verify, "Perform sanity checks on shaping results", nullptr}, - {"num-iterations", 0, 0, G_OPTION_ARG_INT, &this->num_iterations, "Run shaper N times (default: 1)", "N"}, + {"num-iterations", 'n', 0, G_OPTION_ARG_INT, &this->num_iterations, "Run shaper N times (default: 1)", "N"}, {nullptr} }; parser->add_group (entries, From f90bab8560816b60b4b3f2379b36c08756b21e6c Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 14:21:15 +0200 Subject: [PATCH 33/39] [util] Add --ft-load-flags Useful for performance testing. Not hooked to cairo yet. Just changes shaping, not rasterization. --- util/helper-cairo.cc | 2 +- util/options.cc | 4 ++++ util/options.hh | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/util/helper-cairo.cc b/util/helper-cairo.cc index 3eaf90a74..5914ab746 100644 --- a/util/helper-cairo.cc +++ b/util/helper-cairo.cc @@ -125,7 +125,7 @@ helper_cairo_create_scaled_font (const font_options_t *font_opts) } #endif - cairo_face = cairo_ft_font_face_create_for_ft_face (ft_face, 0); + cairo_face = cairo_ft_font_face_create_for_ft_face (ft_face, font_opts->ft_load_flags); } cairo_matrix_t ctm, font_matrix; cairo_font_options_t *font_options; diff --git a/util/options.cc b/util/options.cc index 29028070e..0ab16d628 100644 --- a/util/options.cc +++ b/util/options.cc @@ -556,6 +556,7 @@ font_options_t::add_options (option_parser_t *parser) {"font-ppem", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) &parse_font_ppem, "Set x,y pixels per EM (default: 0; disabled)", "1/2 integers"}, {"font-ptem", 0, 0, G_OPTION_ARG_DOUBLE, &this->ptem, "Set font point-size (default: 0; disabled)", "point-size"}, {"font-funcs", 0, 0, G_OPTION_ARG_STRING, &this->font_funcs, text, "impl"}, + {"ft-load-flags", 0, 0, G_OPTION_ARG_INT, &this->ft_load_flags, "Set FreeType load-flags (default: 2)", "integer"}, {nullptr} }; parser->add_group (entries, @@ -717,6 +718,9 @@ font_options_t::get_font (void) const } } set_font_funcs (font); +#ifdef HAVE_FREETYPE + hb_ft_font_set_load_flags (font, ft_load_flags); +#endif return font; } diff --git a/util/options.hh b/util/options.hh index 345790943..456e0a0fc 100644 --- a/util/options.hh +++ b/util/options.hh @@ -454,6 +454,7 @@ struct font_options_t : option_group_t face_index = 0; font_size_x = font_size_y = default_font_size; font_funcs = nullptr; + ft_load_flags = 2; blob = nullptr; font = nullptr; @@ -484,6 +485,7 @@ struct font_options_t : option_group_t mutable double font_size_x; mutable double font_size_y; char *font_funcs; + int ft_load_flags; private: mutable hb_font_t *font; From 54998befc43ef38e47b74b3153380adbcf6279d4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 14:35:26 +0200 Subject: [PATCH 34/39] [ft] Cache advances I decided to always use the cache, instead of my previous sketch direction that was to only allocate and use cache if fast advances are not available. The cache is a mere 1kb, so just use it... TODO: Invalidate cache on font size change. Fixes https://github.com/harfbuzz/harfbuzz/issues/651 Fixes https://github.com/harfbuzz/harfbuzz/pull/1082 --- src/hb-cache.hh | 2 +- src/hb-ft.cc | 37 +++++++++++++++++-------------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/hb-cache.hh b/src/hb-cache.hh index 0858e11bf..f8581b4de 100644 --- a/src/hb-cache.hh +++ b/src/hb-cache.hh @@ -36,7 +36,7 @@ template = cache_bits), ""); - static_assert ((key_bits + value_bits - cache_bits < 8 * sizeof (unsigned int)), ""); + static_assert ((key_bits + value_bits - cache_bits <= 8 * sizeof (unsigned int)), ""); inline void init (void) { clear (); } inline void fini (void) {} diff --git a/src/hb-ft.cc b/src/hb-ft.cc index 856a9f79b..121b7159f 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -69,6 +69,7 @@ struct hb_ft_font_t int load_flags; bool symbol; /* Whether selected cmap is symbol cmap. */ bool unref; /* Whether to destroy ft_face when done. */ + mutable hb_advance_cache_t advance_cache; }; static hb_ft_font_t * @@ -85,6 +86,8 @@ _hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref) ft_font->load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING; + ft_font->advance_cache.init (); + return ft_font; } @@ -99,6 +102,8 @@ _hb_ft_font_destroy (void *data) { hb_ft_font_t *ft_font = (hb_ft_font_t *) data; + ft_font->advance_cache.fini (); + if (ft_font->unref) _hb_ft_face_destroy (ft_font->ft_face); @@ -239,31 +244,23 @@ hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data, { const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; FT_Face ft_face = ft_font->ft_face; - int load_flags; - + int load_flags = ft_font->load_flags; int mult = font->x_scale < 0 ? -1 : +1; - unsigned int i = 0; - - load_flags = ft_font->load_flags | FT_ADVANCE_FLAG_FAST_ONLY; - for (; i < count; i++) + for (unsigned int i = 0; i < count; i++) { FT_Fixed v = 0; - if (unlikely (FT_Get_Advance (ft_face, *first_glyph, load_flags, &v))) - goto slow; - *first_advance = (v * mult + (1<<9)) >> 10; - first_glyph = &StructAtOffset (first_glyph, glyph_stride); - first_advance = &StructAtOffset (first_advance, advance_stride); - } - return; + hb_codepoint_t glyph = *first_glyph; + + unsigned int cv; + if (ft_font->advance_cache.get (glyph, &cv)) + v = cv; + else + { + FT_Get_Advance (ft_face, glyph, load_flags, &v); + ft_font->advance_cache.set (glyph, v); + } -slow: - /* TODO Prepare and use cache. */ - load_flags = ft_font->load_flags;// & ~FT_ADVANCE_FLAG_FAST_ONLY; - for (; i < count; i++) - { - FT_Fixed v = 0; - FT_Get_Advance (ft_face, *first_glyph, load_flags, &v); *first_advance = (v * mult + (1<<9)) >> 10; first_glyph = &StructAtOffset (first_glyph, glyph_stride); first_advance = &StructAtOffset (first_advance, advance_stride); From 383060cc3354e12611dec3082a6fe08fdb25f652 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 14:41:19 +0200 Subject: [PATCH 35/39] [ft] Invalidate advance cache if font size changed --- src/hb-ft.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/hb-ft.cc b/src/hb-ft.cc index 121b7159f..3aed71883 100644 --- a/src/hb-ft.cc +++ b/src/hb-ft.cc @@ -69,6 +69,8 @@ struct hb_ft_font_t int load_flags; bool symbol; /* Whether selected cmap is symbol cmap. */ bool unref; /* Whether to destroy ft_face when done. */ + + mutable int cached_x_scale; mutable hb_advance_cache_t advance_cache; }; @@ -86,6 +88,7 @@ _hb_ft_font_create (FT_Face ft_face, bool symbol, bool unref) ft_font->load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING; + ft_font->cached_x_scale = 0; ft_font->advance_cache.init (); return ft_font; @@ -247,6 +250,12 @@ hb_ft_get_glyph_h_advances (hb_font_t* font, void* font_data, int load_flags = ft_font->load_flags; int mult = font->x_scale < 0 ? -1 : +1; + if (font->x_scale != ft_font->cached_x_scale) + { + ft_font->advance_cache.clear (); + ft_font->cached_x_scale = font->x_scale; + } + for (unsigned int i = 0; i < count; i++) { FT_Fixed v = 0; From a1814e2bec3a43b9eeb4d50a67daae3fc52fd0a5 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 14:45:23 +0200 Subject: [PATCH 36/39] Whitespace --- src/hb-open-file.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh index d3b748602..b17320579 100644 --- a/src/hb-open-file.hh +++ b/src/hb-open-file.hh @@ -485,7 +485,7 @@ struct OpenTypeFontFile { enum { CFFTag = HB_TAG ('O','T','T','O'), /* OpenType with Postscript outlines */ - TrueTypeTag = HB_TAG ( 0 , 1 , 0 , 0 ), /* OpenType with TrueType outlines */ + TrueTypeTag = HB_TAG ( 0 , 1 , 0 , 0 ), /* OpenType with TrueType outlines */ TTCTag = HB_TAG ('t','t','c','f'), /* TrueType Collection */ DFontTag = HB_TAG ( 0 , 0 , 1 , 0 ), /* DFont Mac Resource Fork */ TrueTag = HB_TAG ('t','r','u','e'), /* Obsolete Apple TrueType */ From 9479ffefbfa3ea4ee39747e34177d26ab1ebbec9 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 16:41:26 +0200 Subject: [PATCH 37/39] [dfont] Re-enable and fix offset handling Fixes https://github.com/harfbuzz/harfbuzz/pull/1085 --- src/hb-face.cc | 5 +++-- src/hb-open-file.hh | 19 +++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/hb-face.cc b/src/hb-face.cc index 92c341523..922fd8fd0 100644 --- a/src/hb-face.cc +++ b/src/hb-face.cc @@ -163,11 +163,12 @@ _hb_face_for_data_reference_table (hb_face_t *face HB_UNUSED, hb_tag_t tag, void return hb_blob_reference (data->blob); const OT::OpenTypeFontFile &ot_file = *data->blob->as (); - const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index); + unsigned int base_offset; + const OT::OpenTypeFontFace &ot_face = ot_file.get_face (data->index, &base_offset); const OT::OpenTypeTable &table = ot_face.get_table_by_tag (tag); - hb_blob_t *blob = hb_blob_create_sub_blob (data->blob, table.offset, table.length); + hb_blob_t *blob = hb_blob_create_sub_blob (data->blob, base_offset + table.offset, table.length); return blob; } diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh index b17320579..608de0a9a 100644 --- a/src/hb-open-file.hh +++ b/src/hb-open-file.hh @@ -428,14 +428,19 @@ struct ResourceForkHeader return StructAtOffset > (this, offset); } - inline const OpenTypeFontFace& get_face (unsigned int idx) const + inline const OpenTypeFontFace& get_face (unsigned int idx, unsigned int *base_offset = nullptr) const { const ResourceMap &resource_map = this+map; for (unsigned int i = 0; i < resource_map.get_types_count (); ++i) { const ResourceTypeItem& type = resource_map.get_type (i); if (type.is_sfnt () && idx < type.get_resource_count ()) - return (OpenTypeFontFace&) get_data (type, idx).arrayZ; + { + const OpenTypeFontFace &face = (OpenTypeFontFace&) get_data (type, idx).arrayZ; + if (base_offset) + *base_offset = (const char *) &face - (const char *) this; + return face; + } } return Null (OpenTypeFontFace); } @@ -502,12 +507,14 @@ struct OpenTypeFontFile case Typ1Tag: case TrueTypeTag: return 1; case TTCTag: return u.ttcHeader.get_face_count (); -// case DFontTag: return u.rfHeader.get_face_count (); + case DFontTag: return u.rfHeader.get_face_count (); default: return 0; } } - inline const OpenTypeFontFace& get_face (unsigned int i) const + inline const OpenTypeFontFace& get_face (unsigned int i, unsigned int *base_offset = nullptr) const { + if (base_offset) + *base_offset = 0; switch (u.tag) { /* Note: for non-collection SFNT data we ignore index. This is because * Apple dfont container is a container of SFNT's. So each SFNT is a @@ -517,7 +524,7 @@ struct OpenTypeFontFile case Typ1Tag: case TrueTypeTag: return u.fontFace; case TTCTag: return u.ttcHeader.get_face (i); -// case DFontTag: return u.rfHeader.get_face (i); + case DFontTag: return u.rfHeader.get_face (i, base_offset); default: return Null(OpenTypeFontFace); } } @@ -544,7 +551,7 @@ struct OpenTypeFontFile case Typ1Tag: case TrueTypeTag: return_trace (u.fontFace.sanitize (c)); case TTCTag: return_trace (u.ttcHeader.sanitize (c)); -// case DFontTag: return_trace (u.rfHeader.sanitize (c)); + case DFontTag: return_trace (u.rfHeader.sanitize (c)); default: return_trace (true); } } From 2b2ed1e536061cfd3a0f29522118f42b451678bd Mon Sep 17 00:00:00 2001 From: Ebrahim Byagowi Date: Mon, 2 Jul 2018 17:26:43 +0430 Subject: [PATCH 38/39] [dfont] Add test --- test/shaping/data/in-house/Makefile.sources | 1 + test/shaping/data/in-house/fonts/TestDFONT.dfont | Bin 0 -> 3505 bytes test/shaping/data/in-house/fonts/TestTTC.ttc | Bin 0 -> 2608 bytes .../data/in-house/tests/collections.tests | 6 ++++++ 4 files changed, 7 insertions(+) create mode 100644 test/shaping/data/in-house/fonts/TestDFONT.dfont create mode 100644 test/shaping/data/in-house/fonts/TestTTC.ttc create mode 100644 test/shaping/data/in-house/tests/collections.tests diff --git a/test/shaping/data/in-house/Makefile.sources b/test/shaping/data/in-house/Makefile.sources index 1bb8604ef..c0b85f2f1 100644 --- a/test/shaping/data/in-house/Makefile.sources +++ b/test/shaping/data/in-house/Makefile.sources @@ -6,6 +6,7 @@ TESTS = \ tests/arabic-stch.tests \ tests/automatic-fractions.tests \ tests/cluster.tests \ + tests/collections.tests \ tests/color-fonts.tests \ tests/context-matching.tests \ tests/cursive-positioning.tests \ diff --git a/test/shaping/data/in-house/fonts/TestDFONT.dfont b/test/shaping/data/in-house/fonts/TestDFONT.dfont new file mode 100644 index 0000000000000000000000000000000000000000..a6ea7009be3ed3c1083254effaf54bc6fbfed685 GIT binary patch literal 3505 zcmeHJPiS0482`<@O?J24G@FRUKT91=Xj-tl$<{WI_8=r#DYP3+mUt=Dx7nB7*xh~0 zzL$_h4?-(QQRu19*R`_1A4GptU`~ zLH=p-TgE0*>0*E91wcGU{)wrIU28kIZ66>xTjZzad__6Qstn_8!t@J2y?284N6D8i$XN3P&i^52qA zl-(&Ck7Azlee&^&Jzql{cTunXsj6LZp2908-dhP66aV)uP;&asb=NL zU?mM(6b>ZeU``CyO?nydAyE~_(Z<G5hr%8l)zkPJse=$XJ@YhfTe zmL0`8bf~TJVxt`&SVzT!)G{V^m*rUw3PN1gkyCPj-Br^rVUQ8)y;-IuOk@X5j0x7o z!_>us$a%`F28E>B+Gr53(`6jtRtR{c%M~eAxuu}?7F|Jk1Z{Zr>`%`i`Tl-^4PUG?OFuqbq0&HrRCtx zJ9`F?99dkXif6*JWc4k^x9UoY_p!eObcN9-SoPYTeL_qwAIL*^(qO?8e%oNlC_XgU z!reT<<^hHf5ov?l&>I7&Qf@J95=mko}g$7R~6F*uBIal+sT zy5$`PM~Mdv-iVAGGdM>4uECoyXZ0D}jkt9l!*Ef<0_vDSk4yAMK3$(+qTU)5l6idF^Hnm-)`v-QZ{DR83 zRX^vtWiP3+t_t*?sym)jpK}VFmE&|T2r5UMp}_HcmCF&0Q&q$)nmINb-UnH?D}ElPOmtJwGwzEL4Tyx1?01!JPaYlUy+gfEUQ_TP?BZkGTIceLs=n+ zKgF1vW#w~hmK93AU-O1isp5=Zn$0Jt+)66%lnQnsHO+$Yb;0PX^>6c~cV6Zm^UQ%h zHC@^IlBBR7`*;;cd6_2ICn=w2TTdQR`Ldf&Rcz09>Z$$vhDWm#qe*|BlW(n}iM zX+Vu5`u$#m!juU}{_9!j!W(jUJmC4#Zs1$p8N77*OJ_5iewzjKORN73&B}oVmL5Bu zpzP-F5Xjf!80@9E5yP(>g8$I0w&V0%b6nM%b%S}JH%%V_8{X1kXo~;Nk5B44ez&u- z&aY>M|84%>4CwC$UL%tDlLXPZ>IK&8tVszzufm(I@_wN^GnO6UxMi@{d{vTZR%ldz Ky&}?jb$%|VJtPM(UW;6(*J=tX-d;z5KS#30xrEqd`FkwOY3kgmU(osCPXsNhY%WoCZg z-}&a7?+q(usX~ktag0Za*j~+N=n};!IJGeM66CPpX{^@S1t(V>&D;kMTe?tcx&fOw zbPK$M*;Z*u3dlk6028kS)uv`C4n47|8wF(1e(2la)78du<={Mf7W^vsTFrCIR{PY) z;C})CoDw7p><&@lF!;l@rfjD^q_@Gp4F2(kUvlXcIs^U!_@SoT4k$y9fmi#BmfQ3` z|Hyg){2F2w13!}C(_h{p8rXz>G6+3o2io%tCZsLrvu#2vCh5DPo3{>-!>7n8dH+JrQz4R}QqFH*XHBsIw78_eifPEfq+k!;1gSYunx_)(C4s=>eYTqvQ6a) z+A`xVO~P8m-DiG>2(O&>OzQ4Vo1TZzQ1=_y&ra{e?|CRc3;x}GIjVHh;21qY(+0=; zY!di#&Kr3WHLe?+qNCI{*uoj#F?gU457H>TZ{+DdJVeja4I>}Xdm-ca0J5(!OPvOo z(Owo9%xQ?JmsH7Plw)rg9PhJ9(39-CktgXOyJ>KW=GlFNEgIpc4Ib#jgEY(a%Ypdm zK0HKA{M~6kSPtveniS)uqav4`I3bG5V%BfTg6}sXTjYJA^^pj@$P1UevR&{ZDGG(z zd9S+IaKjzrDbdqR=}70iFsl14F=1!3S*3!{G2_&;6!l27d?{QZL$~ZT-SDFDD}4#< zM6XF1L{pAat;^bC(JuK-r|8wnZrQ0ITdA`B8zxS%;TN5z8%Zy8&dg2E=Xh-^snz@pDT(wqma2k8># zGVBUiBOSc}JWKQ7tF(wHF03AoJcTH`eUz-1(>WbILe?rLfjn(wtA0JN?mowM?bOq% z=qe9^2rA)K2CkN5HwUt=Awf%RZsC^oUSj3L%H0lo2y*T(+G>6-t!Tl{@wjpn0sJBp4 g=Tq}$b=lwNB%T}2V)){Q>4SvbT5L4<^t{&p28YOce*gdg literal 0 HcmV?d00001 diff --git a/test/shaping/data/in-house/tests/collections.tests b/test/shaping/data/in-house/tests/collections.tests new file mode 100644 index 000000000..d9ecdabb9 --- /dev/null +++ b/test/shaping/data/in-house/tests/collections.tests @@ -0,0 +1,6 @@ +../fonts/TestDFONT.dfont:--face-index=0 --font-funcs=ot:U+2026,U+0020,U+002E:[ellipsis=0+723|space=1+250|period=2+241] +../fonts/TestDFONT.dfont:--face-index=1 --font-funcs=ot:U+2026,U+0020,U+002E:[ellipsis=0+723|space=1+250|period=2+241] +../fonts/TestDFONT.dfont:--face-index=2 --font-funcs=ot:U+2026,U+0020,U+002E:[gid0=0+1000|gid0=1+1000|gid0=2+1000] +../fonts/TestTTC.ttc:--face-index=0 --font-funcs=ot:U+2026,U+0020,U+002E:[ellipsis=0+723|space=1+250|period=2+241] +../fonts/TestTTC.ttc:--face-index=1 --font-funcs=ot:U+2026,U+0020,U+002E:[ellipsis=0+723|space=1+250|period=2+241] +../fonts/TestTTC.ttc:--face-index=2 --font-funcs=ot:U+2026,U+0020,U+002E:[gid0=0+1000|gid0=1+1000|gid0=2+1000] From d5c509272f2fbd1b4c56e3b530da7e42e7f03901 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Tue, 11 Sep 2018 17:18:21 +0200 Subject: [PATCH 39/39] [dfont] Fix test expecatation and minor touch up I have no way to authoritatively know, but looks like test font only has one face. So, adjust test expectation instead. --- src/hb-open-file.hh | 18 ++++++------------ .../data/in-house/tests/collections.tests | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh index 608de0a9a..39c6aeb89 100644 --- a/src/hb-open-file.hh +++ b/src/hb-open-file.hh @@ -300,7 +300,7 @@ struct ResourceRefItem HBINT16 id; /* Resource ID, is really should be signed? */ HBINT16 nameOffset; /* Offset from beginning of resource name list - * to resource name, minus means there is no */ + * to resource name, minus means there is none. */ HBUINT8 attr; /* Resource attributes */ HBUINT24 dataOffset; /* Offset from beginning of resource data to * data for this resource */ @@ -318,15 +318,9 @@ struct ResourceTypeItem return_trace (likely (c->check_struct (this))); } - inline unsigned int get_resource_count () const - { - return numRes + 1; - } + inline unsigned int get_resource_count () const { return numRes + 1; } - inline bool is_sfnt () const - { - return type == HB_TAG ('s','f','n','t'); - } + inline bool is_sfnt () const { return type == HB_TAG ('s','f','n','t'); } inline const ResourceRefItem& get_ref_item (const void *base, unsigned int i) const @@ -335,11 +329,11 @@ struct ResourceTypeItem } protected: - Tag type; /* Resource type */ - HBUINT16 numRes; /* Number of resource this type in map minus 1 */ + Tag type; /* Resource type. */ + HBUINT16 numRes; /* Number of resources minus 1. */ OffsetTo > refList; /* Offset from beginning of resource type list - * to reference list for this type */ + * to reference item list for this type. */ public: DEFINE_SIZE_STATIC (8); }; diff --git a/test/shaping/data/in-house/tests/collections.tests b/test/shaping/data/in-house/tests/collections.tests index d9ecdabb9..85653c543 100644 --- a/test/shaping/data/in-house/tests/collections.tests +++ b/test/shaping/data/in-house/tests/collections.tests @@ -1,5 +1,5 @@ ../fonts/TestDFONT.dfont:--face-index=0 --font-funcs=ot:U+2026,U+0020,U+002E:[ellipsis=0+723|space=1+250|period=2+241] -../fonts/TestDFONT.dfont:--face-index=1 --font-funcs=ot:U+2026,U+0020,U+002E:[ellipsis=0+723|space=1+250|period=2+241] +../fonts/TestDFONT.dfont:--face-index=1 --font-funcs=ot:U+2026,U+0020,U+002E:[gid0=0+1000|gid0=1+1000|gid0=2+1000] ../fonts/TestDFONT.dfont:--face-index=2 --font-funcs=ot:U+2026,U+0020,U+002E:[gid0=0+1000|gid0=1+1000|gid0=2+1000] ../fonts/TestTTC.ttc:--face-index=0 --font-funcs=ot:U+2026,U+0020,U+002E:[ellipsis=0+723|space=1+250|period=2+241] ../fonts/TestTTC.ttc:--face-index=1 --font-funcs=ot:U+2026,U+0020,U+002E:[ellipsis=0+723|space=1+250|period=2+241]