diff -Nru harfbuzz-1.8.5/ChangeLog harfbuzz-1.8.8/ChangeLog --- harfbuzz-1.8.5/ChangeLog 2018-08-01 21:51:24.000000000 +0000 +++ harfbuzz-1.8.8/ChangeLog 2018-08-14 17:57:55.000000000 +0000 @@ -1,3 +1,1041 @@ +commit c9a22fa124310c98c73b8d7b495ed354542a75de +Author: Behdad Esfahbod +Date: Mon Aug 13 17:02:21 2018 -0700 + + [icu] Pass normalizer instance down as user_data + + src/hb-icu.cc | 23 +++++++++-------------- + 1 file changed, 9 insertions(+), 14 deletions(-) + +commit f0ef096b8cab33aa9e26edba9b15696bf907e268 +Author: Behdad Esfahbod +Date: Mon Aug 13 10:30:41 2018 -0700 + + Don't add reference in get_unicode_funcs() functions + + Users don't expect a new reference returned from a get() function. + Indeed, all users of that API I foud where NOT destroying the + reference. + Just change the implementations to NOT return a reference. + + This applies to the following APIs: + hb_unicode_funcs_get_default() + hb_glib_get_unicode_funcs() + hb_icu_get_unicode_funcs() + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1134 + + src/hb-buffer.cc | 3 +-- + src/hb-glib.cc | 2 +- + src/hb-icu.cc | 2 +- + src/hb-ucdn.cc | 2 +- + 4 files changed, 4 insertions(+), 5 deletions(-) + +commit 9bbd1cdf068635f4a737f1fc9ab54ba075601a5d +Author: Behdad Esfahbod +Date: Sun Aug 12 18:20:53 2018 -0700 + + [uniscribe] Use lazy loader + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1129 + + src/hb-uniscribe.cc | 56 + +++++++++++++++++++++++++++-------------------------- + 1 file changed, 29 insertions(+), 27 deletions(-) + +commit 266368993625e0cfb6eef9188f8b9aa29fb97391 +Author: Behdad Esfahbod +Date: Sun Aug 12 18:10:59 2018 -0700 + + Another clang bot fix + + src/hb-shape.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 989e71a982658145f28f83f2111bdab9561f3db0 +Author: Behdad Esfahbod +Date: Sun Aug 12 17:47:59 2018 -0700 + + Silence clang + + src/hb-machinery-private.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 6750ec692cdd682bd33cb1c37b137cf3bb641d43 +Author: Behdad Esfahbod +Date: Sun Aug 12 17:42:16 2018 -0700 + + [lazy] Use for C_locale + + src/hb-common.cc | 60 + ++++++++++++++++++++++++++++---------------------------- + 1 file changed, 30 insertions(+), 30 deletions(-) + +commit 747d2564e6bdcc15cf6a197e543fb732924159c5 +Author: Behdad Esfahbod +Date: Sun Aug 12 17:32:10 2018 -0700 + + [lazy] Port more + + src/hb-machinery-private.hh | 1 - + src/hb-shaper.cc | 78 + ++++++++++++++++++++------------------------- + src/hb-uniscribe.cc | 3 +- + 3 files changed, 37 insertions(+), 45 deletions(-) + +commit 7bd508a0c4ce426f474bfcc729cb39207dd1f7b4 +Author: Behdad Esfahbod +Date: Sun Aug 12 17:19:55 2018 -0700 + + [lazy] Rename free() + + src/hb-ft.cc | 4 ++-- + src/hb-glib.cc | 2 +- + src/hb-icu.cc | 2 +- + src/hb-machinery-private.hh | 4 ++-- + src/hb-ot-font.cc | 2 +- + src/hb-shape.cc | 6 +++--- + src/hb-ucdn.cc | 2 +- + 7 files changed, 11 insertions(+), 11 deletions(-) + +commit a3b97db910662e26bafe6e6bc1c36b437f4ed931 +Author: Behdad Esfahbod +Date: Sun Aug 12 17:14:32 2018 -0700 + + [lazy] Port more to it + + src/hb-shape.cc | 75 + +++++++++++++++++++++++++++++---------------------------- + 1 file changed, 38 insertions(+), 37 deletions(-) + +commit 6901090945d7e16102f3a2b168465434032b9a09 +Author: Behdad Esfahbod +Date: Sun Aug 12 16:57:06 2018 -0700 + + [lazy] Make hb_lazy_loader_t<> more usable + + src/hb-ft.cc | 7 +++--- + src/hb-machinery-private.hh | 57 + +++++++++++++++++++++++++++------------------ + 2 files changed, 37 insertions(+), 27 deletions(-) + +commit bb905e9afcc3eb28a22ba78c09e661a814d04c1f +Author: Behdad Esfahbod +Date: Sun Aug 12 16:40:08 2018 -0700 + + [lazy] Minor + + src/hb-machinery-private.hh | 36 ++++++++++++++++++------------------ + src/hb-ot-font.cc | 8 ++++---- + 2 files changed, 22 insertions(+), 22 deletions(-) + +commit 3945cd78a96bdd287e203a0261bac490df1314b0 +Author: Behdad Esfahbod +Date: Sun Aug 12 16:33:48 2018 -0700 + + Minor + + src/hb-machinery-private.hh | 4 ---- + 1 file changed, 4 deletions(-) + +commit c21a1b95dffedb6ed66b384f4adf07e6d05d4b9f +Author: Behdad Esfahbod +Date: Sun Aug 12 16:30:39 2018 -0700 + + [icu] Use get_relaxed for normalizer access + + We've had the proper barriers already. No need for more with + every access. + + src/hb-icu.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 125fefa2a6b23cf7eb4559904b23aff3731d5dba +Author: Behdad Esfahbod +Date: Sun Aug 12 16:29:41 2018 -0700 + + [icu] Fix for breakage after recent change + + src/hb-icu.cc | 10 ++++++++++ + 1 file changed, 10 insertions(+) + +commit 53442be1edc73993bdcaffc4b895c07f1ea03ba0 +Author: Behdad Esfahbod +Date: Sun Aug 12 16:20:11 2018 -0700 + + [lazy] Use for ft_library + + src/hb-ft.cc | 61 + ++++++++++++++++++++++----------------------- + src/hb-glib.cc | 2 +- + src/hb-icu.cc | 2 +- + src/hb-machinery-private.hh | 2 +- + src/hb-ot-font.cc | 2 +- + src/hb-ucdn.cc | 2 +- + 6 files changed, 35 insertions(+), 36 deletions(-) + +commit 7a8d480378af4094645dfb1527a61a94b4786b54 +Author: Behdad Esfahbod +Date: Sun Aug 12 16:00:13 2018 -0700 + + [lazy] Add .free() + + src/hb-ft.cc | 2 +- + src/hb-glib.cc | 2 +- + src/hb-icu.cc | 2 +- + src/hb-machinery-private.hh | 4 ++++ + src/hb-ot-font.cc | 2 +- + src/hb-ucdn.cc | 2 +- + 6 files changed, 9 insertions(+), 5 deletions(-) + +commit c7ca30a5337cb660e650d51ddd17d389909357c2 +Author: Behdad Esfahbod +Date: Sun Aug 12 13:46:53 2018 -0700 + + [ot/ft] Port font_funcs statis to lazy-loader + + src/hb-ft.cc | 56 + ++++++++++++++++++++++----------------------- + src/hb-machinery-private.hh | 14 ++++++++++++ + src/hb-ot-font.cc | 49 +++++++++++++++++---------------------- + 3 files changed, 62 insertions(+), 57 deletions(-) + +commit cb3fc3685c03c8ed07bcf05188f5d6c582fd5aaa +Author: Behdad Esfahbod +Date: Sun Aug 12 13:39:01 2018 -0700 + + [ucdn/glib/icu] Port unicode_funcs statics to lazy-loader + + src/hb-glib.cc | 50 ++++++++++++++++++-------------------- + src/hb-icu.cc | 59 + ++++++++++++++++----------------------------- + src/hb-machinery-private.hh | 28 ++++++++++++++++----- + src/hb-ucdn.cc | 51 +++++++++++++++++---------------------- + 4 files changed, 88 insertions(+), 100 deletions(-) + +commit 1b6b481262465ae1865c66c4d499b4b2c8d297fb +Author: Behdad Esfahbod +Date: Sun Aug 12 13:16:40 2018 -0700 + + [lazy] Allow calling fini() multiple times + + src/hb-machinery-private.hh | 9 ++++++++- + 1 file changed, 8 insertions(+), 1 deletion(-) + +commit 918ad9f5d9b85384f24157523272a4ffc1927d16 +Author: Behdad Esfahbod +Date: Sun Aug 12 13:12:29 2018 -0700 + + [lazy] More + + src/hb-machinery-private.hh | 45 + +++++++++++++++++++++++++++++++++++++-------- + 1 file changed, 37 insertions(+), 8 deletions(-) + +commit 5abdf5eebadf9a4fbd50c1a893c9654de74d22ac +Author: Behdad Esfahbod +Date: Sun Aug 12 12:40:24 2018 -0700 + + [lazy] More shuffle + + src/hb-machinery-private.hh | 80 + +++++++++++++++++++-------------------------- + 1 file changed, 34 insertions(+), 46 deletions(-) + +commit 5d9863be6ecf873033cbab732207dd420f3866e7 +Author: Behdad Esfahbod +Date: Sun Aug 12 12:27:47 2018 -0700 + + Minor + + src/hb-machinery-private.hh | 6 ++++-- + src/hb-ot-layout-private.hh | 2 +- + 2 files changed, 5 insertions(+), 3 deletions(-) + +commit f9a3eab81008c01a458d16f274b1a0eaaae00e7c +Author: Behdad Esfahbod +Date: Sun Aug 12 12:21:56 2018 -0700 + + Add explicit_operator + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1127 + + src/hb-iter-private.hh | 2 +- + src/hb-private.hh | 15 ++++++++++++++- + 2 files changed, 15 insertions(+), 2 deletions(-) + +commit 470acb6c322fc64556d59847d829d95caa2d51e6 +Author: Behdad Esfahbod +Date: Sun Aug 12 12:09:20 2018 -0700 + + Rename + + src/hb-machinery-private.hh | 19 ++++++++++++------- + 1 file changed, 12 insertions(+), 7 deletions(-) + +commit 39607dc98e433ef577c1de0f309ce40fc40529be +Author: Martin Hosken +Date: Thu Aug 9 15:16:32 2018 +0700 + + Support _ in feature ids + + src/hb-common.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 652cd45c650b1cdce2585dcee614e5a9cdda530c +Author: Behdad Esfahbod +Date: Thu Aug 9 01:02:02 2018 -0700 + + [coretext] Another try + + src/hb-coretext.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 3f3585ca1406edd74138f78739612c167ab57913 +Author: Behdad Esfahbod +Date: Thu Aug 9 00:58:17 2018 -0700 + + Fix coretext build (hopefully) + + src/hb-coretext.cc | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit aa3b6017ed71fc251522ff1bedcdae965b4c1c1c +Author: Behdad Esfahbod +Date: Thu Aug 9 00:56:28 2018 -0700 + + Revert "[iter] Make operator bool explicit" + + This reverts commit 66920a6bace7c54c8166c4ed938b6ffc5fabcf2b. + + Some of our bots (Oracle Studio and Apple gcc 4.2) do not allow + explicit except for constructors. + + https://github.com/harfbuzz/harfbuzz/issues/1127 + + src/hb-iter-private.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e1a2354220c369bd5a62d255acc42c60cd14c473 +Author: Behdad Esfahbod +Date: Thu Aug 9 00:53:25 2018 -0700 + + [atomic] More + + src/hb-atomic-private.hh | 2 -- + src/hb-object-private.hh | 7 +++++-- + 2 files changed, 5 insertions(+), 4 deletions(-) + +commit f1f4b45ac3d228a6b11e33357725de065e2ba2be +Author: Behdad Esfahbod +Date: Thu Aug 9 00:28:40 2018 -0700 + + Fix lazy_loader fini() + + Was creating object even if wasn't there. + + src/hb-machinery-private.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 1f7380944df9aa81cd48a4764c763d692533c4a6 +Author: Behdad Esfahbod +Date: Thu Aug 9 00:22:37 2018 -0700 + + [atomic] Add hb_atomic_ptr_t<> and port all uses + + Found and fixed a couple bugs. + + Found a couple multithreading issues. Marked them with "XXX-MT-bug". + + src/hb-atomic-private.hh | 34 +++++++++++++++++++++++++++++++--- + src/hb-common.cc | 34 ++++++++++++++++++---------------- + src/hb-face-private.hh | 3 ++- + src/hb-face.cc | 6 +++--- + src/hb-font.cc | 2 +- + src/hb-ft.cc | 22 ++++++++++++---------- + src/hb-glib.cc | 11 ++++++----- + src/hb-graphite2.cc | 16 +++++++++------- + src/hb-icu.cc | 22 ++++++++++++---------- + src/hb-machinery-private.hh | 17 +++++++++-------- + src/hb-object-private.hh | 29 +++++++++++++++-------------- + src/hb-ot-font.cc | 11 ++++++----- + src/hb-ot-layout-private.hh | 2 +- + src/hb-ot-post-table.hh | 9 +++++---- + src/hb-ot-shape-complex-arabic.cc | 9 +++++---- + src/hb-shape-plan.cc | 19 +++++++++++-------- + src/hb-shape.cc | 11 ++++++----- + src/hb-shaper-impl-private.hh | 2 +- + src/hb-shaper-private.hh | 16 +++++++++------- + src/hb-shaper.cc | 18 ++++++++++-------- + src/hb-ucdn.cc | 11 ++++++----- + src/hb-uniscribe.cc | 14 +++++++------- + 22 files changed, 185 insertions(+), 133 deletions(-) + +commit 6e42f4c53ff52cc242051e80600e19513136f6d1 +Author: Behdad Esfahbod +Date: Wed Aug 8 22:51:35 2018 -0700 + + [atomic] Remove hb_atomic_int_impl_t now that it's always int + + src/hb-atomic-private.hh | 14 +++++--------- + 1 file changed, 5 insertions(+), 9 deletions(-) + +commit 1227a9e5a5befffa688c1cce141533fd80144d14 +Author: Behdad Esfahbod +Date: Wed Aug 8 22:45:49 2018 -0700 + + [atomic] Unify typedef + + Removes volatile from fallback implementation. That was handwavy + anyway. + + src/hb-atomic-private.hh | 22 ++++++++-------------- + 1 file changed, 8 insertions(+), 14 deletions(-) + +commit 5cd1888c9dcb8b32bcfe08be38bdd13fd8a09b5e +Author: Behdad Esfahbod +Date: Wed Aug 8 22:43:53 2018 -0700 + + [atomic] Change Mac atomic int type to int + + If ever int is not 32bit, we'll fix this... + + src/hb-atomic-private.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e1de86eac188e804c6737fcad66ae09cf25ef221 +Author: Behdad Esfahbod +Date: Wed Aug 8 22:42:33 2018 -0700 + + [atomic] Change Windows atomic int type to int + + src/hb-atomic-private.hh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit aee2d10b2bf09814b32bccdecd4c3fbebafc542e +Author: Behdad Esfahbod +Date: Wed Aug 8 22:40:10 2018 -0700 + + [atomic] Change Solaris atomic int to signed + + src/hb-atomic-private.hh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit b6fdcf4f8bd09e065c767939125861c9dc8ff18f +Author: Behdad Esfahbod +Date: Wed Aug 8 21:54:08 2018 -0700 + + 1.8.7 + + NEWS | 6 ++++++ + RELEASING.md | 3 +++ + configure.ac | 2 +- + src/hb-version.h | 4 ++-- + 4 files changed, 12 insertions(+), 3 deletions(-) + +commit 51ffc3e65aacbece63995be99e2bc20538e3eb75 +Author: Behdad Esfahbod +Date: Wed Aug 8 22:01:04 2018 -0700 + + Fix previous commit to use atomic operations + + src/hb-machinery-private.hh | 13 ++++++++++--- + 1 file changed, 10 insertions(+), 3 deletions(-) + +commit 883957688cc4aa4335e5131a60b3ac3b53290726 +Author: Behdad Esfahbod +Date: Wed Aug 8 21:42:18 2018 -0700 + + Fix assertion failure + + https://bugzilla.mozilla.org/show_bug.cgi?id=1476334 + + src/hb-machinery-private.hh | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit e49a38b20e82e50bca96751470e945cbe0524880 +Author: Behdad Esfahbod +Date: Tue Aug 7 09:55:42 2018 -0700 + + 1.8.6 + + NEWS | 15 +++++++++++++++ + configure.ac | 2 +- + src/hb-font.cc | 6 +++--- + src/hb-font.h | 4 ++-- + src/hb-version.h | 4 ++-- + 5 files changed, 23 insertions(+), 8 deletions(-) + +commit b0ff79acd804e47a2a3db73746cf9c6dc986950a +Author: Behdad Esfahbod +Date: Tue Aug 7 09:52:06 2018 -0700 + + Add +hb_font_get_glyph_advances_for_direction + + New API: + +hb_font_get_glyph_advances_for_direction + + docs/harfbuzz-sections.txt | 1 + + src/hb-font-private.hh | 12 ++++++++++++ + src/hb-font.cc | 20 ++++++++++++++++++++ + src/hb-font.h | 8 ++++++++ + 4 files changed, 41 insertions(+) + +commit 28e2f467e1c7dd5e82d105efa8c4580dbfc93960 +Author: Behdad Esfahbod +Date: Tue Aug 7 09:47:00 2018 -0700 + + Actually add hb_font_get_glyph_[hv]_advances + + New API: + +hb_font_get_glyph_h_advances + +hb_font_get_glyph_v_advances + + src/hb-font.cc | 37 +++++++++++++++++++++++++++++++++++++ + src/hb-font.h | 15 +++++++++++++++ + 2 files changed, 52 insertions(+) + +commit 996775191a3fdeeeaee80e3123ef2240e6390b3d +Author: Behdad Esfahbod +Date: Tue Aug 7 09:44:01 2018 -0700 + + Minor + + src/hb-font-private.hh | 8 +++----- + 1 file changed, 3 insertions(+), 5 deletions(-) + +commit 3d7c555a19ca0725c386aa6da648ecf2ae50fc19 +Author: Behdad Esfahbod +Date: Tue Aug 7 09:37:52 2018 -0700 + + Remove get_advances_nil and alias it to get_advances_default + + src/hb-font.cc | 36 ++---------------------------------- + 1 file changed, 2 insertions(+), 34 deletions(-) + +commit 66920a6bace7c54c8166c4ed938b6ffc5fabcf2b +Author: Behdad Esfahbod +Date: Mon Aug 6 15:32:13 2018 -0700 + + [iter] Make operator bool explicit + + We would need to write: + + for (Iter it (...); bool (t); t++) + + instead of: + + for (Iter it (...); t; t++) + + But I think it's an improvement in code readability in the long term. + + Fixes https://github.com/harfbuzz/harfbuzz/issues/1127 + + src/hb-iter-private.hh | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 79e21984b13bdb879f3007ba9a97fde47df340d3 +Author: Behdad Esfahbod +Date: Mon Aug 6 09:45:17 2018 -0700 + + Add batch advance width callback function + + New API: + +hb_font_funcs_set_glyph_h_advances_func + +hb_font_funcs_set_glyph_v_advances_func + +hb_font_get_glyph_h_advances + +hb_font_get_glyph_h_advances_func_t + +hb_font_get_glyph_v_advances + +hb_font_get_glyph_v_advances_func_t + + docs/harfbuzz-sections.txt | 6 + + src/hb-font-private.hh | 41 +++++-- + src/hb-font.cc | 299 + +++++++++++++++++++++++++++------------------ + src/hb-font.h | 53 ++++++-- + src/hb-ot-shape.cc | 3 +- + 5 files changed, 255 insertions(+), 147 deletions(-) + +commit 9533364cc3a8cccbae793de1873a727de73f64d5 +Author: Koji Ishii +Date: Wed Aug 1 13:01:08 2018 +0900 + + batchwidth + + src/hb-font-private.hh | 13 +++++++++++++ + src/hb-font.cc | 37 +++++++++++++++++++++++++++++++++++++ + src/hb-font.h | 15 +++++++++++++++ + src/hb-ot-shape.cc | 4 ++-- + 4 files changed, 67 insertions(+), 2 deletions(-) + +commit b912fbea17c50e229977345012227810ed7641e9 +Author: Behdad Esfahbod +Date: Mon Aug 6 06:30:12 2018 -0700 + + Remove most uses of direct comparison to Null objects + + src/hb-ot-glyf-table.hh | 6 +++--- + src/hb-ot-head-table.hh | 4 ++-- + src/hb-ot-layout-gdef-table.hh | 1 + + src/hb-ot-layout-gsubgpos-private.hh | 1 + + src/hb-ot-layout.cc | 6 +++--- + src/hb-ot-math-table.hh | 2 ++ + src/hb-ot-math.cc | 2 +- + src/hb-ot-shape-complex-arabic-fallback.hh | 3 ++- + src/hb-ot-var-fvar-table.hh | 2 ++ + src/hb-ot-var.cc | 2 +- + src/hb-subset.cc | 2 +- + src/main.cc | 2 +- + 12 files changed, 20 insertions(+), 13 deletions(-) + +commit 3506672ce9d8685ce4e113716b0d06adbc7981b7 +Author: Behdad Esfahbod +Date: Mon Aug 6 06:17:48 2018 -0700 + + Port _nil objects to Null() machinery + + Finally, unified! + + src/hb-blob-private.hh | 1 + + src/hb-blob.cc | 29 ++++++------- + src/hb-buffer-private.hh | 4 +- + src/hb-buffer.cc | 44 ++++++++++---------- + src/hb-face-private.hh | 6 +-- + src/hb-face.cc | 5 ++- + src/hb-font-private.hh | 10 +++-- + src/hb-font.cc | 66 + ++++++++++++++++-------------- + src/hb-null.hh | 11 ++++- + src/hb-ot-shape-complex-arabic-fallback.hh | 11 +++-- + src/hb-shape-plan-private.hh | 1 + + src/hb-shape-plan.cc | 50 +++++++++++----------- + src/hb-unicode-private.hh | 7 ++-- + src/hb-unicode.cc | 5 ++- + 14 files changed, 137 insertions(+), 113 deletions(-) + +commit 1abd427acfb7229b8607646bdde59f29306b86e1 +Author: Behdad Esfahbod +Date: Mon Aug 6 05:53:35 2018 -0700 + + [BASE] Rename horzi/vert to h/v + + src/hb-ot-layout-base-table.hh | 68 + +++++++++++++++++++++--------------------- + 1 file changed, 34 insertions(+), 34 deletions(-) + +commit da48aca1be89efbb8b3ca4471f542aa54aff17c4 +Author: Behdad Esfahbod +Date: Mon Aug 6 05:52:12 2018 -0700 + + [BASE] Misc fixes + + The code was badly broken. In better shape now, but still, needs + a full review before ever working. + + src/hb-ot-layout-base-table.hh | 163 + +++++++++++++++++------------------------ + 1 file changed, 68 insertions(+), 95 deletions(-) + +commit f9cfa5cb0e70203279e74fb6adb0cd4570238ff8 +Author: Behdad Esfahbod +Date: Mon Aug 6 05:29:15 2018 -0700 + + Change null-pool specialization to min_size again + + src/hb-null.hh | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +commit 25147ff8086ab65995fe046cfdf8007604de6962 +Author: Behdad Esfahbod +Date: Mon Aug 6 05:01:52 2018 -0700 + + Move Null system to hb-null.hh + + src/Makefile.sources | 1 + + src/hb-null.hh | 97 + ++++++++++++++++++++++++++++++++++++++++++++++++++++ + src/hb-private.hh | 65 +---------------------------------- + 3 files changed, 99 insertions(+), 64 deletions(-) + +commit f800368df33e7ec15c3e77bdb9f4b464899322d3 +Author: Behdad Esfahbod +Date: Mon Aug 6 04:58:34 2018 -0700 + + Remove unused macros + + src/hb-object-private.hh | 1 - + src/hb-vector-private.hh | 1 - + 2 files changed, 2 deletions(-) + +commit 19e0091299f06856002c702792b448b06da637a8 +Author: Behdad Esfahbod +Date: Mon Aug 6 04:54:31 2018 -0700 + + Minor + + src/hb-private.hh | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +commit 37be774af921812018f723521b90f2ab54f661c5 +Author: Behdad Esfahbod +Date: Mon Aug 6 04:51:38 2018 -0700 + + Minor + + src/hb-private.hh | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +commit e1acff806b469e58f568bf5ad6ba578207821e87 +Author: Behdad Esfahbod +Date: Mon Aug 6 04:42:46 2018 -0700 + + Move hb_vector_t to hb-vector-private.hh + + src/Makefile.sources | 1 + + src/hb-dsalgs.hh | 297 + ----------------------------------------------- + src/hb-object-private.hh | 109 ++++++++++++++++- + src/hb-vector-private.hh | 239 ++++++++++++++++++++++++++++++++++++++ + 4 files changed, 346 insertions(+), 300 deletions(-) + +commit be336dadc07460a53de51be32dd5d1f218b398b6 +Author: Behdad Esfahbod +Date: Mon Aug 6 04:32:51 2018 -0700 + + Move some more code around + + src/hb-dsalgs.hh | 43 +++++++++++++++++++++++++++++++++++++++++++ + src/hb-private.hh | 51 + +-------------------------------------------------- + 2 files changed, 44 insertions(+), 50 deletions(-) + +commit 92806ee055c8efb68fcbe9e1750ce2532a1f8ab3 +Author: Behdad Esfahbod +Date: Sun Aug 5 21:41:52 2018 -0700 + + Move null data definitions to hb-static.cc + + Also remove " " null data for Tag. Just use zeroes. + + src/hb-open-type-private.hh | 3 +-- + src/hb-ot-layout-common-private.hh | 5 ++--- + src/hb-private.hh | 12 +++++++----- + src/hb-static.cc | 10 +++++++++- + 4 files changed, 19 insertions(+), 11 deletions(-) + +commit 1b4d5a2402302e90867c178b6b2ad07541091a74 +Author: Behdad Esfahbod +Date: Fri Aug 3 19:55:09 2018 -0700 + + Minor + + src/hb-ot-layout-private.hh | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 7df7963b46223f47e89a5a38c597c874aaa93141 +Author: Behdad Esfahbod +Date: Fri Aug 3 19:54:33 2018 -0700 + + Make lazy loader deal with OOM + + src/hb-machinery-private.hh | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +commit 30ff8ac865a266c8dca11eeac155c2cd3d1aa159 +Author: Behdad Esfahbod +Date: Fri Aug 3 17:32:00 2018 -0700 + + Rename + + src/hb-machinery-private.hh | 6 +++--- + src/hb-ot-font.cc | 8 ++++---- + 2 files changed, 7 insertions(+), 7 deletions(-) + +commit 85ba4a190f30da5147d3b2ddac4d58dda31181f1 +Author: Behdad Esfahbod +Date: Fri Aug 3 17:06:42 2018 -0700 + + [ot] Comment + + src/hb-ot-layout-private.hh | 2 ++ + 1 file changed, 2 insertions(+) + +commit 07afc1a213bde91fdfc44dd613f2e82ac1617c9f +Author: Behdad Esfahbod +Date: Fri Aug 3 17:03:32 2018 -0700 + + [ot] Add misc tables to tables_t + + Most unused. + + src/hb-ot-layout-private.hh | 36 ++++++++++++++++++++++-------------- + 1 file changed, 22 insertions(+), 14 deletions(-) + +commit 74b4df2cdef68b74536d9c29426b242199a63a6f +Author: Behdad Esfahbod +Date: Fri Aug 3 16:57:40 2018 -0700 + + [ot] Move GDEF into tables_t + + src/hb-machinery-private.hh | 6 ++++++ + src/hb-ot-layout-gsub-table.hh | 2 +- + src/hb-ot-layout-gsubgpos-private.hh | 2 +- + src/hb-ot-layout-private.hh | 7 +------ + src/hb-ot-layout.cc | 15 +++++---------- + 5 files changed, 14 insertions(+), 18 deletions(-) + +commit 0271c7ab3b76dbf8a4e3e92eaf67d9d61b7a63dc +Author: Behdad Esfahbod +Date: Fri Aug 3 16:45:57 2018 -0700 + + [ot] Move GSUB/GPOS into tables_t + + src/hb-machinery-private.hh | 6 ++---- + src/hb-ot-layout-gpos-table.hh | 4 ++-- + src/hb-ot-layout-gsub-table.hh | 4 ++-- + src/hb-ot-layout-private.hh | 7 ++---- + src/hb-ot-layout.cc | 49 + +++++++++++++++++++----------------------- + 5 files changed, 30 insertions(+), 40 deletions(-) + +commit f73d2775cf649d148ace7c2593da9666d60fc1be +Author: Behdad Esfahbod +Date: Fri Aug 3 16:34:25 2018 -0700 + + [ot] More shuffling + + Misc. table loading now properly automated. + + src/hb-ot-layout-private.hh | 67 + +++++++++++++++++++++++++++++---------------- + src/hb-ot-layout.cc | 25 +++++++++++------ + src/hb-ot-math.cc | 2 +- + 3 files changed, 61 insertions(+), 33 deletions(-) + +commit 52fbd23d868a989d51b7df5be40be582890d13e5 +Author: Behdad Esfahbod +Date: Fri Aug 3 16:22:16 2018 -0700 + + [ot] Minor + + src/hb-aat-layout.cc | 4 ++-- + src/hb-face-private.hh | 7 ++----- + src/hb-machinery-private.hh | 1 + + src/hb-ot-layout-private.hh | 15 +++++++++------ + src/hb-ot-layout.cc | 20 ++++++++++---------- + src/hb-ot-math.cc | 2 +- + src/hb-ot-var.cc | 4 ++-- + 7 files changed, 27 insertions(+), 26 deletions(-) + +commit 6a0a298aabe777e2c1ed443f100fe6142c83e3b3 +Author: Behdad Esfahbod +Date: Thu Aug 2 23:13:19 2018 -0700 + + [ot] Move code around + + src/hb-ot-layout.cc | 211 + ++++++++++++++++++++++++++-------------------------- + 1 file changed, 106 insertions(+), 105 deletions(-) + +commit 5e718a751efdda89511c9f30238b500125193499 +Author: Behdad Esfahbod +Date: Thu Aug 2 23:04:42 2018 -0700 + + [ot] Use switch for checking for blacklisted GDEF tables + + Faster / more compact code. + + src/hb-ot-layout.cc | 107 + +++++++++++++++++++++++++++++----------------------- + 1 file changed, 59 insertions(+), 48 deletions(-) + +commit b5cdf5280d5b00df5356cc5c3236844ca0576bd0 +Author: Behdad Esfahbod +Date: Thu Aug 2 22:56:42 2018 -0700 + + [ot] In GDEF blacklisting logic, remove the glyph index check + for Times + + Just blacklist based on table sizes like we do for other fonts. + + src/hb-ot-layout.cc | 12 ------------ + 1 file changed, 12 deletions(-) + +commit c988b119994ef78d400bc7d3139785312da0be75 +Author: Behdad Esfahbod +Date: Thu Aug 2 20:04:37 2018 -0700 + + Move code around + + src/hb-ot-font.cc | 41 ++++++++++++++++++++++++++--------------- + 1 file changed, 26 insertions(+), 15 deletions(-) + +commit 574b37e933f98e35c2bdae04458a95522bbfbb82 +Author: Behdad Esfahbod +Date: Thu Aug 2 02:22:38 2018 -0700 + + Minor + + src/hb-ot-font.cc | 2 +- + src/hb-ot-layout-private.hh | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +commit d4d1bf8177b127caa57b146c932f553dca1ad933 +Author: Behdad Esfahbod +Date: Thu Aug 2 02:04:02 2018 -0700 + + Fix for recent rename + + src/hb-graphite2.cc | 2 +- + src/hb-uniscribe.cc | 4 ++-- + 2 files changed, 3 insertions(+), 3 deletions(-) + +commit 91126aa11a5fa2bff72137df4768ad13fc9b7803 +Author: Behdad Esfahbod +Date: Thu Aug 2 02:03:13 2018 -0700 + + [uniscribe] Update for recent changes + + src/hb-uniscribe.cc | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +commit 66952ec47b5f09d88b83fb6a71b1cdb26c53668d +Author: Behdad Esfahbod +Date: Thu Aug 2 01:44:20 2018 -0700 + + Remove unused table reference + + src/hb-ot-layout-private.hh | 9 ++++----- + 1 file changed, 4 insertions(+), 5 deletions(-) + +commit 443de26fa56dd1ef149d3ce4206f4495eceec2eb +Author: Behdad Esfahbod +Date: Thu Aug 2 01:41:19 2018 -0700 + + Minor + + src/hb-face.cc | 1 - + src/hb-ot-layout-private.hh | 12 ++++++------ + 2 files changed, 6 insertions(+), 7 deletions(-) + +commit ee35af738b5c802ca62eb1c39b77f0bd992329df +Author: Behdad Esfahbod +Date: Thu Aug 2 01:37:57 2018 -0700 + + Make lazy-loader safe for nil objectification + + src/hb-machinery-private.hh | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 6404c49d0735d92779089ddef5c1d34aad1542d7 +Author: Behdad Esfahbod +Date: Thu Aug 2 01:36:08 2018 -0700 + + Minor + + src/hb-machinery-private.hh | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +commit ff7826e90bce46985651015059872d1d8559b6ce +Author: Behdad Esfahbod +Date: Thu Aug 2 01:27:40 2018 -0700 + + Reduce storage by sharing face amongst lazy_loaders + + src/hb-machinery-private.hh | 113 + ++++++++++++++++++++++++-------------------- + src/hb-ot-font.cc | 19 ++++---- + src/hb-ot-layout-private.hh | 11 +++-- + src/hb-ot-layout.cc | 9 ++-- + 4 files changed, 85 insertions(+), 67 deletions(-) + +commit bdd3c11a19d87999eeaff2c82f21c6938d1d9342 +Author: Behdad Esfahbod +Date: Thu Aug 2 00:38:46 2018 -0700 + + Internal templatization of lazy-loaders + + src/hb-machinery-private.hh | 74 + ++++++++++++++++++++------------------------- + 1 file changed, 32 insertions(+), 42 deletions(-) + +commit ed7b2e58fc9afb547656cf28eb4a253d989de43c +Author: Behdad Esfahbod +Date: Wed Aug 1 23:59:09 2018 -0700 + + Remove OT namespace from hb-machinery-private.hh + + src/dump-emoji.cc | 4 ++-- + src/hb-aat-layout.cc | 2 +- + src/hb-face.cc | 4 ++-- + src/hb-machinery-private.hh | 14 +++++--------- + src/hb-ot-font.cc | 8 ++++---- + src/hb-ot-layout-private.hh | 10 +++++----- + src/hb-ot-layout.cc | 8 ++++---- + src/hb-ot-shape-complex-arabic-fallback.hh | 18 +++++++++--------- + src/hb-static.cc | 4 ++-- + src/hb-subset-glyf.cc | 2 +- + src/hb-subset.cc | 8 ++++---- + src/hb-uniscribe.cc | 2 +- + 12 files changed, 40 insertions(+), 44 deletions(-) + +commit cb1491f92e24649433988ff81a89347dccf07c8b +Author: Behdad Esfahbod +Date: Wed Aug 1 22:50:45 2018 -0700 + + Minor + + src/hb-blob-private.hh | 5 ----- + src/hb-machinery-private.hh | 10 ++++++---- + 2 files changed, 6 insertions(+), 9 deletions(-) + +commit 16ccfafbbd48c7a9737ce1d12e75406a050b71a9 +Author: Behdad Esfahbod +Date: Wed Aug 1 22:50:06 2018 -0700 + + [face] Sprinkle const in the API + + src/hb-face.cc | 17 +++++++++-------- + src/hb-face.h | 16 ++++++++-------- + 2 files changed, 17 insertions(+), 16 deletions(-) + +commit 3d22aefedebb5277c5d79011e48e7be1a26a53c1 +Author: Behdad Esfahbod +Date: Wed Aug 1 18:03:32 2018 -0700 + + Rename + + src/hb-coretext.cc | 46 + +++++++++++++++++++++++----------------------- + src/hb-directwrite.cc | 28 ++++++++++++++-------------- + src/hb-fallback-shape.cc | 24 ++++++++++++------------ + src/hb-graphite2.cc | 26 +++++++++++++------------- + src/hb-ot-shape.cc | 20 ++++++++++---------- + src/hb-shaper-private.hh | 2 +- + src/hb-uniscribe.cc | 34 +++++++++++++++++----------------- + 7 files changed, 90 insertions(+), 90 deletions(-) + +commit 1a624c6e06763a8a61bc686d2d44272d4ef50d4a +Author: Behdad Esfahbod +Date: Wed Aug 1 17:53:30 2018 -0700 + + Add comment re (our only) race condition + + src/hb-shaper-private.hh | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +commit 44d1fb37efa20852cc466c0f0bba95dbd24ce288 +Author: Behdad Esfahbod +Date: Wed Aug 1 14:51:51 2018 -0700 + + 1.8.5 + + NEWS | 8 ++++++++ + configure.ac | 2 +- + src/hb-ot-layout.cc | 2 +- + src/hb-version.h | 4 ++-- + 4 files changed, 12 insertions(+), 4 deletions(-) + commit 13f4c137c686aed5c2888b5c47d9f16892be0d5e Author: Behdad Esfahbod Date: Wed Aug 1 14:13:59 2018 -0700 diff -Nru harfbuzz-1.8.5/configure harfbuzz-1.8.8/configure --- harfbuzz-1.8.5/configure 2018-08-01 21:47:10.000000000 +0000 +++ harfbuzz-1.8.8/configure 2018-08-14 17:57:46.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for HarfBuzz 1.8.5. +# Generated by GNU Autoconf 2.69 for HarfBuzz 1.8.8. # # Report bugs to . # @@ -590,8 +590,8 @@ # Identity of this package. PACKAGE_NAME='HarfBuzz' PACKAGE_TARNAME='harfbuzz' -PACKAGE_VERSION='1.8.5' -PACKAGE_STRING='HarfBuzz 1.8.5' +PACKAGE_VERSION='1.8.8' +PACKAGE_STRING='HarfBuzz 1.8.8' PACKAGE_BUGREPORT='https://github.com/harfbuzz/harfbuzz/issues/new' PACKAGE_URL='http://harfbuzz.org/' @@ -1493,7 +1493,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures HarfBuzz 1.8.5 to adapt to many kinds of systems. +\`configure' configures HarfBuzz 1.8.8 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1564,7 +1564,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of HarfBuzz 1.8.5:";; + short | recursive ) echo "Configuration of HarfBuzz 1.8.8:";; esac cat <<\_ACEOF @@ -1743,7 +1743,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -HarfBuzz configure 1.8.5 +HarfBuzz configure 1.8.8 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -2607,7 +2607,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by HarfBuzz $as_me 1.8.5, which was +It was created by HarfBuzz $as_me 1.8.8, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3476,7 +3476,7 @@ # Define the identity of the package. PACKAGE='harfbuzz' - VERSION='1.8.5' + VERSION='1.8.8' # Some tools Automake needs. @@ -18463,8 +18463,8 @@ HB_VERSION_MAJOR=1 HB_VERSION_MINOR=8 -HB_VERSION_MICRO=5 -HB_VERSION=1.8.5 +HB_VERSION_MICRO=8 +HB_VERSION=1.8.8 @@ -18475,7 +18475,7 @@ -HB_LIBTOOL_VERSION_INFO=10800:5:10800 +HB_LIBTOOL_VERSION_INFO=10800:8:10800 @@ -21823,7 +21823,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by HarfBuzz $as_me 1.8.5, which was +This file was extended by HarfBuzz $as_me 1.8.8, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -21890,7 +21890,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -HarfBuzz config.status 1.8.5 +HarfBuzz config.status 1.8.8 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff -Nru harfbuzz-1.8.5/configure.ac harfbuzz-1.8.8/configure.ac --- harfbuzz-1.8.5/configure.ac 2018-08-01 21:46:23.000000000 +0000 +++ harfbuzz-1.8.8/configure.ac 2018-08-14 17:54:00.000000000 +0000 @@ -1,6 +1,6 @@ AC_PREREQ([2.64]) AC_INIT([HarfBuzz], - [1.8.5], + [1.8.8], [https://github.com/harfbuzz/harfbuzz/issues/new], [harfbuzz], [http://harfbuzz.org/]) diff -Nru harfbuzz-1.8.5/debian/changelog harfbuzz-1.8.8/debian/changelog --- harfbuzz-1.8.5/debian/changelog 2018-08-02 21:27:27.000000000 +0000 +++ harfbuzz-1.8.8/debian/changelog 2018-08-15 12:45:51.000000000 +0000 @@ -1,14 +1,30 @@ -harfbuzz (1.8.5-0ppa2) bionic; urgency=medium +harfbuzz (1.8.8-0ppa1) bionic; urgency=medium - * Oops... forgot new symbols + * New upstream release + + -- Olivier Berten (selapa.net) Wed, 15 Aug 2018 14:45:51 +0200 + +harfbuzz (1.8.7-1) unstable; urgency=medium + + * New upstream release + * Remove no-op testsuite + + -- أحمد المحمودي (Ahmed El-Mahmoudy) Sun, 12 Aug 2018 07:19:35 +0200 + +harfbuzz (1.8.6-1) unstable; urgency=medium + + * New upstream release + * Update symbols - -- Olivier Berten (selapa.net) Thu, 02 Aug 2018 23:27:27 +0200 + -- أحمد المحمودي (Ahmed El-Mahmoudy) Wed, 08 Aug 2018 04:05:56 +0200 -harfbuzz (1.8.5-0ppa1) bionic; urgency=medium +harfbuzz (1.8.5-1) unstable; urgency=medium * New upstream release + * Updated standards version to 4.2.0 + * Update symbols - -- Olivier Berten (selapa.net) Thu, 02 Aug 2018 23:16:56 +0200 + -- أحمد المحمودي (Ahmed El-Mahmoudy) Sat, 04 Aug 2018 08:29:33 +0200 harfbuzz (1.8.4-2) unstable; urgency=medium diff -Nru harfbuzz-1.8.5/debian/control harfbuzz-1.8.8/debian/control --- harfbuzz-1.8.5/debian/control 2018-08-02 21:14:42.000000000 +0000 +++ harfbuzz-1.8.8/debian/control 2018-08-15 12:44:43.000000000 +0000 @@ -3,7 +3,7 @@ Priority: optional Maintainer: أحمد المحمودي (Ahmed El-Mahmoudy) Uploaders: Emilio Pozuelo Monfort -Standards-Version: 4.1.5 +Standards-Version: 4.2.0 Build-Depends: debhelper (>= 11), pkg-config, diff -Nru harfbuzz-1.8.5/debian/libharfbuzz0b.symbols harfbuzz-1.8.8/debian/libharfbuzz0b.symbols --- harfbuzz-1.8.5/debian/libharfbuzz0b.symbols 2018-08-02 21:27:27.000000000 +0000 +++ harfbuzz-1.8.8/debian/libharfbuzz0b.symbols 2018-08-15 12:44:43.000000000 +0000 @@ -106,10 +106,12 @@ hb_font_funcs_set_glyph_from_name_func@Base 0.9.4 hb_font_funcs_set_glyph_func@Base 0.6.0 hb_font_funcs_set_glyph_h_advance_func@Base 0.6.0 + hb_font_funcs_set_glyph_h_advances_func@Base 1.8.6 hb_font_funcs_set_glyph_h_kerning_func@Base 0.6.0 hb_font_funcs_set_glyph_h_origin_func@Base 0.6.0 hb_font_funcs_set_glyph_name_func@Base 0.9.4 hb_font_funcs_set_glyph_v_advance_func@Base 0.6.0 + hb_font_funcs_set_glyph_v_advances_func@Base 1.8.6 hb_font_funcs_set_glyph_v_kerning_func@Base 0.6.0 hb_font_funcs_set_glyph_v_origin_func@Base 0.6.0 hb_font_funcs_set_nominal_glyph_func@Base 1.2.6 @@ -120,18 +122,21 @@ hb_font_get_face@Base 0.6.0 hb_font_get_glyph@Base 0.6.0 hb_font_get_glyph_advance_for_direction@Base 0.6.0 + hb_font_get_glyph_advances_for_direction@Base 1.8.6 hb_font_get_glyph_contour_point@Base 0.6.0 hb_font_get_glyph_contour_point_for_origin@Base 0.6.0 hb_font_get_glyph_extents@Base 0.6.0 hb_font_get_glyph_extents_for_origin@Base 0.6.0 hb_font_get_glyph_from_name@Base 0.9.4 hb_font_get_glyph_h_advance@Base 0.6.0 + hb_font_get_glyph_h_advances@Base 1.8.6 hb_font_get_glyph_h_kerning@Base 0.6.0 hb_font_get_glyph_h_origin@Base 0.6.0 hb_font_get_glyph_kerning_for_direction@Base 0.6.0 hb_font_get_glyph_name@Base 0.9.4 hb_font_get_glyph_origin_for_direction@Base 0.6.0 hb_font_get_glyph_v_advance@Base 0.6.0 + hb_font_get_glyph_v_advances@Base 1.8.6 hb_font_get_glyph_v_kerning@Base 0.6.0 hb_font_get_glyph_v_origin@Base 0.6.0 hb_font_get_h_extents@Base 1.2.6 diff -Nru harfbuzz-1.8.5/debian/tests/control harfbuzz-1.8.8/debian/tests/control --- harfbuzz-1.8.5/debian/tests/control 2018-08-02 21:14:42.000000000 +0000 +++ harfbuzz-1.8.8/debian/tests/control 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -Test-Command: true -Depends: @, @builddeps@ -Restrictions: build-needed diff -Nru harfbuzz-1.8.5/docs/html/harfbuzz-hb-face.html harfbuzz-1.8.8/docs/html/harfbuzz-hb-face.html --- harfbuzz-1.8.5/docs/html/harfbuzz-hb-face.html 2018-08-01 21:51:26.000000000 +0000 +++ harfbuzz-1.8.8/docs/html/harfbuzz-hb-face.html 2018-08-14 17:58:10.000000000 +0000 @@ -299,7 +299,7 @@

hb_face_get_table_tags ()

unsigned int
-hb_face_get_table_tags (hb_face_t *face,
+hb_face_get_table_tags (const hb_face_t *face,
                         unsigned int start_offset,
                         unsigned int *table_count,
                         hb_tag_t *table_tags);
@@ -329,7 +329,7 @@

hb_face_get_glyph_count ()

unsigned int
-hb_face_get_glyph_count (hb_face_t *face);
+hb_face_get_glyph_count (const hb_face_t *face);

Parameters

@@ -351,7 +351,7 @@

hb_face_get_index ()

unsigned int
-hb_face_get_index (hb_face_t *face);
+hb_face_get_index (const hb_face_t *face);

Parameters

@@ -373,7 +373,7 @@

hb_face_get_upem ()

unsigned int
-hb_face_get_upem (hb_face_t *face);
+hb_face_get_upem (const hb_face_t *face);

Parameters

@@ -395,7 +395,7 @@

hb_face_get_user_data ()

void *
-hb_face_get_user_data (hb_face_t *face,
+hb_face_get_user_data (const hb_face_t *face,
                        hb_user_data_key_t *key);

[skip]

@@ -424,7 +424,7 @@

hb_face_is_immutable ()

hb_bool_t
-hb_face_is_immutable (hb_face_t *face);
+hb_face_is_immutable (const hb_face_t *face);

Parameters

@@ -518,7 +518,7 @@

hb_face_reference_table ()

hb_blob_t *
-hb_face_reference_table (hb_face_t *face,
+hb_face_reference_table (const hb_face_t *face,
                          hb_tag_t tag);

Parameters

diff -Nru harfbuzz-1.8.5/docs/html/harfbuzz-hb-version.html harfbuzz-1.8.8/docs/html/harfbuzz-hb-version.html --- harfbuzz-1.8.5/docs/html/harfbuzz-hb-version.html 2018-08-01 21:51:26.000000000 +0000 +++ harfbuzz-1.8.8/docs/html/harfbuzz-hb-version.html 2018-08-14 17:58:10.000000000 +0000 @@ -170,22 +170,26 @@

Types and Values

HB_VERSION_MAJOR

-
#define             HB_VERSION_MAJOR
+
#define HB_VERSION_MAJOR 1
+

HB_VERSION_MICRO

-
#define             HB_VERSION_MICRO
+
#define HB_VERSION_MICRO 8
+

HB_VERSION_MINOR

-
#define             HB_VERSION_MINOR
+
#define HB_VERSION_MINOR 8
+

HB_VERSION_STRING

-
#define             HB_VERSION_STRING
+
#define HB_VERSION_STRING "1.8.8"
+
diff -Nru harfbuzz-1.8.5/docs/html/pt02.html harfbuzz-1.8.8/docs/html/pt02.html --- harfbuzz-1.8.5/docs/html/pt02.html 2018-08-01 21:51:26.000000000 +0000 +++ harfbuzz-1.8.8/docs/html/pt02.html 2018-08-14 17:58:10.000000000 +0000 @@ -24,7 +24,7 @@

Part II. Reference manual

- This document is for HarfBuzz 1.8.5 + This document is for HarfBuzz 1.8.8 .

diff -Nru harfbuzz-1.8.5/docs/version.xml harfbuzz-1.8.8/docs/version.xml --- harfbuzz-1.8.5/docs/version.xml 2018-08-01 21:47:16.000000000 +0000 +++ harfbuzz-1.8.8/docs/version.xml 2018-08-14 17:57:52.000000000 +0000 @@ -1 +1 @@ -1.8.5 +1.8.8 diff -Nru harfbuzz-1.8.5/NEWS harfbuzz-1.8.8/NEWS --- harfbuzz-1.8.5/NEWS 2018-08-01 21:46:53.000000000 +0000 +++ harfbuzz-1.8.8/NEWS 2018-08-14 17:57:29.000000000 +0000 @@ -1,3 +1,42 @@ +Overview of changes leading to 1.8.8 +Tuesday, August 14, 2018 +==================================== +- Fix hb-icu crash on architectures where compare_exchange_weak() can + fail falsely. This bug was introduced in 1.8.4. + https://bugs.chromium.org/p/chromium/issues/detail?id=873568 +- More internal refactoring of atomic operations and singletons. +- API changes: + The following functions do NOT reference their return value before + returning: + * hb_unicode_funcs_get_default() + * hb_glib_get_unicode_funcs() + * hb_icu_get_unicode_funcs() + This is consistent with their naming ("get", instead of "reference") + as well as how they are used in the wild (ie. no one calls destroy() + on their return value.) + + +Overview of changes leading to 1.8.7 +Wednesday, August 8, 2018 +==================================== +- Fix assertion failure with GDEF-blacklisted fonts. + + +Overview of changes leading to 1.8.6 +Tuesday, August 7, 2018 +==================================== +- Internal code shuffling. +- New API to speed up getting advance widths for implementations + that have heavy overhead in get_h_advance callback: ++hb_font_funcs_set_glyph_h_advances_func ++hb_font_funcs_set_glyph_v_advances_func ++hb_font_get_glyph_advances_for_direction ++hb_font_get_glyph_h_advances ++hb_font_get_glyph_h_advances_func_t ++hb_font_get_glyph_v_advances ++hb_font_get_glyph_v_advances_func_t + + Overview of changes leading to 1.8.5 Wednesday, August 1, 2018 ==================================== diff -Nru harfbuzz-1.8.5/RELEASING.md harfbuzz-1.8.8/RELEASING.md --- harfbuzz-1.8.5/RELEASING.md 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/RELEASING.md 2018-08-14 16:48:02.000000000 +0000 @@ -25,6 +25,9 @@ 6. Do "make distcheck", if it passes, you get a tarball. Otherwise, fix things and commit them separately before making release, + Note: Check src/hb-version.h and make sure the new version number is + there. Sometimes, it does not get updated. If that's the case, + "touch configure.ac" and rebuild. TODO: debug. 7. "make release-files". Enter your GPG password. This creates a sha256 hash and signs it. diff -Nru harfbuzz-1.8.5/src/dump-emoji.cc harfbuzz-1.8.8/src/dump-emoji.cc --- harfbuzz-1.8.5/src/dump-emoji.cc 2018-07-23 05:46:33.000000000 +0000 +++ harfbuzz-1.8.8/src/dump-emoji.cc 2018-08-14 16:48:02.000000000 +0000 @@ -233,10 +233,10 @@ svg.dump (svg_callback); svg.fini (); - hb_blob_t* colr_blob = OT::hb_sanitize_context_t().reference_table (face); + hb_blob_t* colr_blob = hb_sanitize_context_t ().reference_table (face); const OT::COLR *colr = colr_blob->as (); - hb_blob_t* cpal_blob = OT::hb_sanitize_context_t().reference_table (face); + hb_blob_t* cpal_blob = hb_sanitize_context_t ().reference_table (face); const OT::CPAL *cpal = cpal_blob->as (); cairo_font_face_t *cairo_face; diff -Nru harfbuzz-1.8.5/src/hb-aat-layout.cc harfbuzz-1.8.8/src/hb-aat-layout.cc --- harfbuzz-1.8.5/src/hb-aat-layout.cc 2018-07-23 05:45:19.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-aat-layout.cc 2018-08-14 16:48:02.000000000 +0000 @@ -52,16 +52,16 @@ return Null(AAT::morx); } hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - const AAT::morx& morx = *(layout->morx.get ()); + const AAT::morx& morx = *(layout->table.morx.get ()); if (blob) - *blob = layout->morx.get_blob (); + *blob = layout->table.morx.get_blob (); return morx; } // static inline void // _hb_aat_layout_create (hb_face_t *face) // { -// hb_blob_t *morx_blob = OT::hb_sanitize_context_t().reference_table (face); +// hb_blob_t *morx_blob = hb_sanitize_context_t ().reference_table (face); // morx_blob->as (); // if (0) diff -Nru harfbuzz-1.8.5/src/hb-atomic-private.hh harfbuzz-1.8.8/src/hb-atomic-private.hh --- harfbuzz-1.8.5/src/hb-atomic-private.hh 2018-08-01 21:15:00.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-atomic-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -35,7 +35,10 @@ #include "hb-private.hh" -/* atomic_int */ +/* + * Atomic integers and pointers. + */ + /* We need external help for these */ @@ -43,18 +46,19 @@ && defined(hb_atomic_ptr_impl_get) \ && defined(hb_atomic_ptr_impl_cmpexch) -/* Defined externally, i.e. in config.h; must have typedef'ed hb_atomic_int_impl_t as well. */ +/* Defined externally, i.e. in config.h. */ #elif !defined(HB_NO_MT) && defined(__ATOMIC_CONSUME) /* C++11-style GCC primitives. */ -typedef int hb_atomic_int_impl_t; #define hb_atomic_int_impl_add(AI, V) __atomic_fetch_add ((AI), (V), __ATOMIC_ACQ_REL) #define hb_atomic_int_impl_set_relaxed(AI, V) __atomic_store_n ((AI), (V), __ATOMIC_RELAXED) #define hb_atomic_int_impl_get_relaxed(AI) __atomic_load_n ((AI), __ATOMIC_RELAXED) +#define hb_atomic_ptr_impl_set_relaxed(P, V) __atomic_store_n ((P), (V), __ATOMIC_RELAXED) +#define hb_atomic_ptr_impl_get_relaxed(P) __atomic_load_n ((P), __ATOMIC_RELAXED) #define hb_atomic_ptr_impl_get(P) __atomic_load_n ((P), __ATOMIC_CONSUME) static inline bool _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) @@ -70,11 +74,12 @@ #include -typedef int hb_atomic_int_impl_t; #define hb_atomic_int_impl_add(AI, V) (reinterpret_cast *> (AI)->fetch_add ((V), std::memory_order_acq_rel)) #define hb_atomic_int_impl_set_relaxed(AI, V) (reinterpret_cast *> (AI)->store ((V), std::memory_order_relaxed)) #define hb_atomic_int_impl_get_relaxed(AI) (reinterpret_cast *> (AI)->load (std::memory_order_relaxed)) +#define hb_atomic_ptr_impl_set_relaxed(P, V) (reinterpret_cast *> (P)->store ((V), std::memory_order_relaxed)) +#define hb_atomic_ptr_impl_get_relaxed(P) (reinterpret_cast *> (P)->load (std::memory_order_relaxed)) #define hb_atomic_ptr_impl_get(P) (reinterpret_cast *> (P)->load (std::memory_order_consume)) static inline bool _hb_atomic_ptr_impl_cmplexch (const void **P, const void *O_, const void *N) @@ -101,8 +106,7 @@ } #define _hb_memory_barrier() _hb_memory_barrier () -typedef LONG hb_atomic_int_impl_t; -#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd ((AI), (V)) +#define hb_atomic_int_impl_add(AI, V) InterlockedExchangeAdd ((unsigned *) (AI), (V)) #define hb_atomic_ptr_impl_cmpexch(P,O,N) (InterlockedCompareExchangePointer ((void **) (P), (void *) (N), (void *) (O)) == (void *) (O)) @@ -111,7 +115,6 @@ #define _hb_memory_barrier() __sync_synchronize () -typedef int hb_atomic_int_impl_t; #define hb_atomic_int_impl_add(AI, V) __sync_fetch_and_add ((AI), (V)) #define hb_atomic_ptr_impl_cmpexch(P,O,N) __sync_bool_compare_and_swap ((P), (O), (N)) @@ -126,12 +129,10 @@ #define _hb_memory_w_barrier() __machine_w_barrier () #define _hb_memory_barrier() __machine_rw_barrier () -typedef unsigned int hb_atomic_int_impl_t; - -static inline int _hb_fetch_and_add (hb_atomic_int_impl_t *AI, int V) +static inline int _hb_fetch_and_add (int *AI, int V) { _hb_memory_w_barrier (); - int result = atomic_add_int_nv (AI, V); + int result = atomic_add_int_nv ((uint_t *) AI, V); _hb_memory_r_barrier (); return result; } @@ -159,7 +160,6 @@ #define _hb_memory_barrier() OSMemoryBarrier () -typedef int32_t hb_atomic_int_impl_t; #define hb_atomic_int_impl_add(AI, V) (OSAtomicAdd32Barrier ((V), (AI)) - (V)) #if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_4 || __IPHONE_VERSION_MIN_REQUIRED >= 20100) @@ -179,9 +179,7 @@ #define _hb_memory_barrier() __lwsync () -typedef int hb_atomic_int_impl_t; - -static inline int _hb_fetch_and_add (hb_atomic_int_impl_t *AI, int V) +static inline int _hb_fetch_and_add (int *AI, int V) { _hb_memory_barrier (); int result = __fetch_and_add (AI, V); @@ -208,15 +206,13 @@ #define _hb_memory_barrier() -typedef volatile int hb_atomic_int_impl_t; #define hb_atomic_int_impl_add(AI, V) ((*(AI) += (V)) - (V)) -#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void * volatile *) (P) == (void *) (O) ? (* (void * volatile *) (P) = (void *) (N), true) : false) +#define hb_atomic_ptr_impl_cmpexch(P,O,N) (* (void **) (P) == (void *) (O) ? (* (void **) (P) = (void *) (N), true) : false) #else /* HB_NO_MT */ -typedef int hb_atomic_int_impl_t; #define hb_atomic_int_impl_add(AI, V) ((*(AI) += (V)) - (V)) #define _hb_memory_barrier() @@ -233,33 +229,53 @@ #ifndef _hb_memory_w_barrier #define _hb_memory_w_barrier() _hb_memory_barrier () #endif -#ifndef HB_ATOMIC_INT_INIT -#define HB_ATOMIC_INT_INIT(V) {V} -#endif #ifndef hb_atomic_int_impl_set_relaxed #define hb_atomic_int_impl_set_relaxed(AI, V) (*(AI) = (V)) #endif #ifndef hb_atomic_int_impl_get_relaxed #define hb_atomic_int_impl_get_relaxed(AI) (*(AI)) #endif + +#ifndef hb_atomic_ptr_impl_set_relaxed +#define hb_atomic_ptr_impl_set_relaxed(P, V) (*(P) = (V)) +#endif +#ifndef hb_atomic_ptr_impl_get_relaxed +#define hb_atomic_ptr_impl_get_relaxed(P) (*(P)) +#endif #ifndef hb_atomic_ptr_impl_get inline void *hb_atomic_ptr_impl_get (void **P) { void *v = *P; _hb_memory_r_barrier (); return v; } #endif +#define HB_ATOMIC_INT_INIT(V) {V} struct hb_atomic_int_t { - mutable hb_atomic_int_impl_t v; - - inline void set_relaxed (int v_) { hb_atomic_int_impl_set_relaxed (&v, v_); } + inline void set_relaxed (int v_) const { hb_atomic_int_impl_set_relaxed (&v, v_); } inline int get_relaxed (void) const { return hb_atomic_int_impl_get_relaxed (&v); } inline int inc (void) { return hb_atomic_int_impl_add (&v, 1); } inline int dec (void) { return hb_atomic_int_impl_add (&v, -1); } + + mutable int v; }; -#define hb_atomic_ptr_get(P) hb_atomic_ptr_impl_get((void **) P) -#define hb_atomic_ptr_cmpexch(P,O,N) hb_atomic_ptr_impl_cmpexch((P),(O),(N)) +template struct hb_remove_ptr_t { typedef T value; }; +template struct hb_remove_ptr_t { typedef T value; }; + +#define HB_ATOMIC_PTR_INIT(V) {V} +template +struct hb_atomic_ptr_t +{ + typedef typename hb_remove_ptr_t

::value T; + + inline void init (T* v_ = nullptr) { set_relaxed (v_); } + inline void set_relaxed (T* v_) const { hb_atomic_ptr_impl_set_relaxed (&v, v_); } + inline T *get_relaxed (void) const { return hb_atomic_ptr_impl_get_relaxed (&v); } + inline T *get (void) const { return (T *) hb_atomic_ptr_impl_get ((void **) &v); } + inline bool cmpexch (const T *old, T *new_) const{ return hb_atomic_ptr_impl_cmpexch (&v, old, new_); } + + mutable T *v; +}; #endif /* HB_ATOMIC_PRIVATE_HH */ diff -Nru harfbuzz-1.8.5/src/hb-blob.cc harfbuzz-1.8.8/src/hb-blob.cc --- harfbuzz-1.8.5/src/hb-blob.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-blob.cc 2018-08-14 16:48:02.000000000 +0000 @@ -45,6 +45,20 @@ #include +DEFINE_NULL_INSTANCE (hb_blob_t) = +{ + HB_OBJECT_HEADER_STATIC, + + true, /* immutable */ + + nullptr, /* data */ + 0, /* length */ + HB_MEMORY_MODE_READONLY, /* mode */ + + nullptr, /* user_data */ + nullptr /* destroy */ +}; + /** * hb_blob_create: (skip) * @data: Pointer to blob data. @@ -182,20 +196,7 @@ hb_blob_t * hb_blob_get_empty (void) { - static const hb_blob_t _hb_blob_nil = { - HB_OBJECT_HEADER_STATIC, - - true, /* immutable */ - - nullptr, /* data */ - 0, /* length */ - HB_MEMORY_MODE_READONLY, /* mode */ - - nullptr, /* user_data */ - nullptr /* destroy */ - }; - - return const_cast (&_hb_blob_nil); + return const_cast (&Null(hb_blob_t)); } /** diff -Nru harfbuzz-1.8.5/src/hb-blob-private.hh harfbuzz-1.8.8/src/hb-blob-private.hh --- harfbuzz-1.8.5/src/hb-blob-private.hh 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-blob-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -57,11 +57,6 @@ HB_INTERNAL bool try_make_writable_inplace (void); HB_INTERNAL bool try_make_writable_inplace_unix (void); - inline void lock (void) - { - hb_blob_make_immutable (this); - } - template inline const Type* as (void) const { @@ -81,6 +76,7 @@ void *user_data; hb_destroy_func_t destroy; }; +DECLARE_NULL_INSTANCE (hb_blob_t); #endif /* HB_BLOB_PRIVATE_HH */ diff -Nru harfbuzz-1.8.5/src/hb-buffer.cc harfbuzz-1.8.8/src/hb-buffer.cc --- harfbuzz-1.8.5/src/hb-buffer.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-buffer.cc 2018-08-14 16:48:02.000000000 +0000 @@ -216,7 +216,7 @@ return; hb_unicode_funcs_destroy (unicode); - unicode = hb_unicode_funcs_get_default (); + unicode = hb_unicode_funcs_reference (hb_unicode_funcs_get_default ()); flags = HB_BUFFER_FLAG_DEFAULT; replacement = HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT; @@ -701,6 +701,28 @@ /* Public API */ +DEFINE_NULL_INSTANCE (hb_buffer_t) = +{ + HB_OBJECT_HEADER_STATIC, + + const_cast (&_hb_Null_hb_unicode_funcs_t), + HB_BUFFER_FLAG_DEFAULT, + HB_BUFFER_CLUSTER_LEVEL_DEFAULT, + HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT, + HB_BUFFER_SCRATCH_FLAG_DEFAULT, + HB_BUFFER_MAX_LEN_DEFAULT, + HB_BUFFER_MAX_OPS_DEFAULT, + + HB_BUFFER_CONTENT_TYPE_INVALID, + HB_SEGMENT_PROPERTIES_DEFAULT, + false, /* successful */ + true, /* have_output */ + true /* have_positions */ + + /* Zero is good enough for everything else. */ +}; + + /** * hb_buffer_create: (Xconstructor) * @@ -743,27 +765,7 @@ hb_buffer_t * hb_buffer_get_empty (void) { - static const hb_buffer_t _hb_buffer_nil = { - HB_OBJECT_HEADER_STATIC, - - const_cast (&_hb_unicode_funcs_nil), - HB_BUFFER_FLAG_DEFAULT, - HB_BUFFER_CLUSTER_LEVEL_DEFAULT, - HB_BUFFER_REPLACEMENT_CODEPOINT_DEFAULT, - HB_BUFFER_SCRATCH_FLAG_DEFAULT, - HB_BUFFER_MAX_LEN_DEFAULT, - HB_BUFFER_MAX_OPS_DEFAULT, - - HB_BUFFER_CONTENT_TYPE_INVALID, - HB_SEGMENT_PROPERTIES_DEFAULT, - false, /* successful */ - true, /* have_output */ - true /* have_positions */ - - /* Zero is good enough for everything else. */ - }; - - return const_cast (&_hb_buffer_nil); + return const_cast (&Null(hb_buffer_t)); } /** @@ -906,7 +908,6 @@ if (!unicode_funcs) unicode_funcs = hb_unicode_funcs_get_default (); - hb_unicode_funcs_reference (unicode_funcs); hb_unicode_funcs_destroy (buffer->unicode); buffer->unicode = unicode_funcs; diff -Nru harfbuzz-1.8.5/src/hb-buffer-private.hh harfbuzz-1.8.8/src/hb-buffer-private.hh --- harfbuzz-1.8.5/src/hb-buffer-private.hh 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-buffer-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -83,7 +83,8 @@ * hb_buffer_t */ -struct hb_buffer_t { +struct hb_buffer_t +{ hb_object_header_t header; ASSERT_POD (); @@ -352,6 +353,7 @@ info[i].mask &= ~HB_GLYPH_FLAG_UNSAFE_TO_BREAK; } }; +DECLARE_NULL_INSTANCE (hb_buffer_t); /* Loop over clusters. Duplicated in foreach_syllable(). */ diff -Nru harfbuzz-1.8.5/src/hb-common.cc harfbuzz-1.8.8/src/hb-common.cc --- harfbuzz-1.8.5/src/hb-common.cc 2018-08-01 04:28:32.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-common.cc 2018-08-14 16:48:02.000000000 +0000 @@ -28,6 +28,7 @@ #include "hb-private.hh" +#include "hb-machinery-private.hh" #include #ifdef HAVE_XLOCALE_H @@ -244,15 +245,15 @@ /* Thread-safe lock-free language list */ -static hb_language_item_t *langs; +static hb_atomic_ptr_t langs; #ifdef HB_USE_ATEXIT static void free_langs (void) { retry: - hb_language_item_t *first_lang = (hb_language_item_t *) hb_atomic_ptr_get (&langs); - if (!hb_atomic_ptr_cmpexch (&langs, first_lang, nullptr)) + hb_language_item_t *first_lang = langs.get (); + if (unlikely (!langs.cmpexch (first_lang, nullptr))) goto retry; while (first_lang) { @@ -268,7 +269,7 @@ lang_find_or_insert (const char *key) { retry: - hb_language_item_t *first_lang = (hb_language_item_t *) hb_atomic_ptr_get (&langs); + hb_language_item_t *first_lang = langs.get (); for (hb_language_item_t *lang = first_lang; lang; lang = lang->next) if (*lang == key) @@ -286,7 +287,8 @@ return nullptr; } - if (!hb_atomic_ptr_cmpexch (&langs, first_lang, lang)) { + if (unlikely (!langs.cmpexch (first_lang, lang))) + { lang->fini (); free (lang); goto retry; @@ -368,15 +370,16 @@ hb_language_t hb_language_get_default (void) { - static hb_language_t default_language = HB_LANGUAGE_INVALID; + static hb_atomic_ptr_t default_language; - hb_language_t language = (hb_language_t) hb_atomic_ptr_get (&default_language); - if (unlikely (language == HB_LANGUAGE_INVALID)) { + hb_language_t language = default_language.get (); + if (unlikely (language == HB_LANGUAGE_INVALID)) + { language = hb_language_from_string (setlocale (LC_CTYPE, nullptr), -1); - (void) hb_atomic_ptr_cmpexch (&default_language, HB_LANGUAGE_INVALID, language); + (void) default_language.cmpexch (HB_LANGUAGE_INVALID, language); } - return default_language; + return language; } @@ -728,48 +731,47 @@ #ifdef USE_XLOCALE -static HB_LOCALE_T C_locale; - -#ifdef HB_USE_ATEXIT -static void -free_C_locale (void) -{ -retry: - HB_LOCALE_T locale = (HB_LOCALE_T) hb_atomic_ptr_get (&C_locale); - - if (!hb_atomic_ptr_cmpexch (&C_locale, locale, nullptr)) - goto retry; - if (locale) - HB_FREE_LOCALE (locale); -} -#endif +static void free_static_C_locale (void); -static HB_LOCALE_T -get_C_locale (void) +static struct hb_C_locale_lazy_loader_t : hb_lazy_loader_t::value, + hb_C_locale_lazy_loader_t> { -retry: - HB_LOCALE_T C = (HB_LOCALE_T) hb_atomic_ptr_get (&C_locale); - - if (unlikely (!C)) + static inline HB_LOCALE_T create (void) { - C = HB_CREATE_LOCALE ("C"); - - if (!hb_atomic_ptr_cmpexch (&C_locale, nullptr, C)) - { - HB_FREE_LOCALE (C_locale); - goto retry; - } + HB_LOCALE_T C_locale = HB_CREATE_LOCALE ("C"); #ifdef HB_USE_ATEXIT - atexit (free_C_locale); /* First person registers atexit() callback. */ + atexit (free_static_C_locale); #endif + + return C_locale; + } + static inline void destroy (HB_LOCALE_T p) + { + HB_FREE_LOCALE (p); + } + static inline HB_LOCALE_T get_null (void) + { + return nullptr; } +} static_C_locale; - return C; +#ifdef HB_USE_ATEXIT +static +void free_static_C_locale (void) +{ + static_C_locale.free_instance (); } #endif +static HB_LOCALE_T +get_C_locale (void) +{ + return static_C_locale.get_unconst (); +} +#endif /* USE_XLOCALE */ + static bool parse_float (const char **pp, const char *end, float *pv) { @@ -845,7 +847,7 @@ } const char *p = *pp; - while (*pp < end && ISALNUM(**pp)) + while (*pp < end && (ISALNUM(**pp) || **pp == '_')) (*pp)++; if (p == *pp || *pp - p > 4) diff -Nru harfbuzz-1.8.5/src/hb-coretext.cc harfbuzz-1.8.8/src/hb-coretext.cc --- harfbuzz-1.8.5/src/hb-coretext.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-coretext.cc 2018-08-14 16:48:02.000000000 +0000 @@ -269,7 +269,7 @@ return ct_font; } -hb_coretext_shaper_face_data_t * +hb_coretext_face_data_t * _hb_coretext_shaper_face_data_create (hb_face_t *face) { CGFontRef cg_font = create_cg_font (face); @@ -280,11 +280,11 @@ return nullptr; } - return (hb_coretext_shaper_face_data_t *) cg_font; + return (hb_coretext_face_data_t *) cg_font; } void -_hb_coretext_shaper_face_data_destroy (hb_coretext_shaper_face_data_t *data) +_hb_coretext_shaper_face_data_destroy (hb_coretext_face_data_t *data) { CFRelease ((CGFontRef) data); } @@ -306,7 +306,7 @@ } -hb_coretext_shaper_font_data_t * +hb_coretext_font_data_t * _hb_coretext_shaper_font_data_create (hb_font_t *font) { hb_face_t *face = font->face; @@ -321,11 +321,11 @@ return nullptr; } - return (hb_coretext_shaper_font_data_t *) ct_font; + return (hb_coretext_font_data_t *) ct_font; } void -_hb_coretext_shaper_font_data_destroy (hb_coretext_shaper_font_data_t *data) +_hb_coretext_shaper_font_data_destroy (hb_coretext_font_data_t *data) { CFRelease ((CTFontRef) data); } @@ -348,7 +348,7 @@ hb_font_set_ptem (font, coretext_font_size_to_ptem (CTFontGetSize(ct_font))); /* Let there be dragons here... */ - HB_SHAPER_DATA_GET (font) = (hb_coretext_shaper_font_data_t *) CFRetain (ct_font); + HB_SHAPER_DATA (HB_SHAPER, font).set_relaxed ((hb_coretext_font_data_t *) CFRetain (ct_font)); return font; } @@ -366,20 +366,20 @@ * shaper shape_plan data */ -struct hb_coretext_shaper_shape_plan_data_t {}; +struct hb_coretext_shape_plan_data_t {}; -hb_coretext_shaper_shape_plan_data_t * +hb_coretext_shape_plan_data_t * _hb_coretext_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_coretext_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_coretext_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_coretext_shaper_shape_plan_data_destroy (hb_coretext_shape_plan_data_t *data HB_UNUSED) { } @@ -1329,9 +1329,9 @@ * shaper face data */ -struct hb_coretext_aat_shaper_face_data_t {}; +struct hb_coretext_aat_face_data_t {}; -hb_coretext_aat_shaper_face_data_t * +hb_coretext_aat_face_data_t * _hb_coretext_aat_shaper_face_data_create (hb_face_t *face) { static const hb_tag_t tags[] = {HB_CORETEXT_TAG_MORX, HB_CORETEXT_TAG_MORT, HB_CORETEXT_TAG_KERX}; @@ -1342,7 +1342,7 @@ if (hb_blob_get_length (blob)) { hb_blob_destroy (blob); - return hb_coretext_shaper_face_data_ensure (face) ? (hb_coretext_aat_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; + return hb_coretext_shaper_face_data_ensure (face) ? (hb_coretext_aat_face_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; } hb_blob_destroy (blob); } @@ -1351,7 +1351,7 @@ } void -_hb_coretext_aat_shaper_face_data_destroy (hb_coretext_aat_shaper_face_data_t *data HB_UNUSED) +_hb_coretext_aat_shaper_face_data_destroy (hb_coretext_aat_face_data_t *data HB_UNUSED) { } @@ -1360,16 +1360,16 @@ * shaper font data */ -struct hb_coretext_aat_shaper_font_data_t {}; +struct hb_coretext_aat_font_data_t {}; -hb_coretext_aat_shaper_font_data_t * +hb_coretext_aat_font_data_t * _hb_coretext_aat_shaper_font_data_create (hb_font_t *font) { - return hb_coretext_shaper_font_data_ensure (font) ? (hb_coretext_aat_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; + return hb_coretext_shaper_font_data_ensure (font) ? (hb_coretext_aat_font_data_t *) HB_SHAPER_DATA_SUCCEEDED : nullptr; } void -_hb_coretext_aat_shaper_font_data_destroy (hb_coretext_aat_shaper_font_data_t *data HB_UNUSED) +_hb_coretext_aat_shaper_font_data_destroy (hb_coretext_aat_font_data_t *data HB_UNUSED) { } @@ -1378,20 +1378,20 @@ * shaper shape_plan data */ -struct hb_coretext_aat_shaper_shape_plan_data_t {}; +struct hb_coretext_aat_shape_plan_data_t {}; -hb_coretext_aat_shaper_shape_plan_data_t * +hb_coretext_aat_shape_plan_data_t * _hb_coretext_aat_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_coretext_aat_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_coretext_aat_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_coretext_aat_shaper_shape_plan_data_destroy (hb_coretext_aat_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_coretext_aat_shaper_shape_plan_data_destroy (hb_coretext_aat_shape_plan_data_t *data HB_UNUSED) { } diff -Nru harfbuzz-1.8.5/src/hb-directwrite.cc harfbuzz-1.8.8/src/hb-directwrite.cc --- harfbuzz-1.8.5/src/hb-directwrite.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-directwrite.cc 2018-08-14 16:48:02.000000000 +0000 @@ -133,7 +133,7 @@ * shaper face data */ -struct hb_directwrite_shaper_face_data_t +struct hb_directwrite_face_data_t { IDWriteFactory *dwriteFactory; IDWriteFontFile *fontFile; @@ -143,10 +143,10 @@ hb_blob_t *faceBlob; }; -hb_directwrite_shaper_face_data_t * +hb_directwrite_face_data_t * _hb_directwrite_shaper_face_data_create (hb_face_t *face) { - hb_directwrite_shaper_face_data_t *data = new hb_directwrite_shaper_face_data_t; + hb_directwrite_face_data_t *data = new hb_directwrite_face_data_t; if (unlikely (!data)) return nullptr; @@ -206,7 +206,7 @@ } void -_hb_directwrite_shaper_face_data_destroy (hb_directwrite_shaper_face_data_t *data) +_hb_directwrite_shaper_face_data_destroy (hb_directwrite_face_data_t *data) { if (data->fontFace) data->fontFace->Release (); @@ -233,16 +233,16 @@ * shaper font data */ -struct hb_directwrite_shaper_font_data_t +struct hb_directwrite_font_data_t { }; -hb_directwrite_shaper_font_data_t * +hb_directwrite_font_data_t * _hb_directwrite_shaper_font_data_create (hb_font_t *font) { if (unlikely (!hb_directwrite_shaper_face_data_ensure (font->face))) return nullptr; - hb_directwrite_shaper_font_data_t *data = new hb_directwrite_shaper_font_data_t; + hb_directwrite_font_data_t *data = new hb_directwrite_font_data_t; if (unlikely (!data)) return nullptr; @@ -250,7 +250,7 @@ } void -_hb_directwrite_shaper_font_data_destroy (hb_directwrite_shaper_font_data_t *data) +_hb_directwrite_shaper_font_data_destroy (hb_directwrite_font_data_t *data) { delete data; } @@ -260,20 +260,20 @@ * shaper shape_plan data */ -struct hb_directwrite_shaper_shape_plan_data_t {}; +struct hb_directwrite_shape_plan_data_t {}; -hb_directwrite_shaper_shape_plan_data_t * +hb_directwrite_shape_plan_data_t * _hb_directwrite_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_directwrite_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_directwrite_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_directwrite_shaper_shape_plan_data_destroy (hb_directwrite_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_directwrite_shaper_shape_plan_data_destroy (hb_directwrite_shape_plan_data_t *data HB_UNUSED) { } @@ -555,8 +555,8 @@ float lineWidth) { hb_face_t *face = font->face; - hb_directwrite_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); - hb_directwrite_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); + hb_directwrite_face_data_t *face_data = HB_SHAPER_DATA_GET (face); + hb_directwrite_font_data_t *font_data = HB_SHAPER_DATA_GET (font); IDWriteFactory *dwriteFactory = face_data->dwriteFactory; IDWriteFontFace *fontFace = face_data->fontFace; diff -Nru harfbuzz-1.8.5/src/hb-dsalgs.hh harfbuzz-1.8.8/src/hb-dsalgs.hh --- harfbuzz-1.8.5/src/hb-dsalgs.hh 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-dsalgs.hh 2018-08-14 16:48:02.000000000 +0000 @@ -232,6 +232,18 @@ * Tiny stuff. */ +/* ASCII tag/character handling */ +static inline bool ISALPHA (unsigned char c) +{ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } +static inline bool ISALNUM (unsigned char c) +{ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); } +static inline bool ISSPACE (unsigned char c) +{ return c == ' ' || c =='\f'|| c =='\n'|| c =='\r'|| c =='\t'|| c =='\v'; } +static inline unsigned char TOUPPER (unsigned char c) +{ return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c; } +static inline unsigned char TOLOWER (unsigned char c) +{ return (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c; } + #undef MIN template static inline Type MIN (const Type &a, const Type &b) { return a < b ? a : b; } @@ -262,6 +274,37 @@ return ((v - 1) | 3) + 1; } +template class hb_assert_unsigned_t; +template <> class hb_assert_unsigned_t {}; +template <> class hb_assert_unsigned_t {}; +template <> class hb_assert_unsigned_t {}; +template <> class hb_assert_unsigned_t {}; + +template static inline bool +hb_in_range (T u, T lo, T hi) +{ + /* The sizeof() is here to force template instantiation. + * I'm sure there are better ways to do this but can't think of + * one right now. Declaring a variable won't work as HB_UNUSED + * is unusable on some platforms and unused types are less likely + * to generate a warning than unused variables. */ + static_assert ((sizeof (hb_assert_unsigned_t) >= 0), ""); + + /* The casts below are important as if T is smaller than int, + * the subtract results will become a signed int! */ + return (T)(u - lo) <= (T)(hi - lo); +} +template static inline bool +hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2) +{ + return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2); +} +template static inline bool +hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3) +{ + return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2) || hb_in_range (u, lo3, hi3); +} + /* * Sort and search. @@ -445,303 +488,6 @@ } -#define HB_VECTOR_INIT {0, 0, false, nullptr} -template -struct hb_vector_t -{ - unsigned int len; - unsigned int allocated; /* == 0 means allocation failed. */ - Type *arrayZ; - Type static_array[StaticSize]; - - void init (void) - { - len = 0; - allocated = ARRAY_LENGTH (static_array); - arrayZ = static_array; - } - - inline Type& operator [] (unsigned int i) - { - if (unlikely (i >= len)) - return Crap (Type); - return arrayZ[i]; - } - inline const Type& operator [] (unsigned int i) const - { - if (unlikely (i >= len)) - return Null(Type); - return arrayZ[i]; - } - - inline Type *push (void) - { - if (unlikely (!resize (len + 1))) - return &Crap(Type); - return &arrayZ[len - 1]; - } - inline Type *push (const Type& v) - { - Type *p = push (); - *p = v; - return p; - } - - /* Allocate for size but don't adjust len. */ - inline bool alloc (unsigned int size) - { - if (unlikely (!allocated)) - return false; - - if (likely (size <= allocated)) - return true; - - /* Reallocate */ - - unsigned int new_allocated = allocated; - while (size >= new_allocated) - new_allocated += (new_allocated >> 1) + 8; - - Type *new_array = nullptr; - - if (arrayZ == static_array) - { - new_array = (Type *) calloc (new_allocated, sizeof (Type)); - if (new_array) - memcpy (new_array, arrayZ, len * sizeof (Type)); - } - else - { - bool overflows = (new_allocated < allocated) || hb_unsigned_mul_overflows (new_allocated, sizeof (Type)); - if (likely (!overflows)) - new_array = (Type *) realloc (arrayZ, new_allocated * sizeof (Type)); - } - - if (unlikely (!new_array)) - { - allocated = 0; - return false; - } - - arrayZ = new_array; - allocated = new_allocated; - - return true; - } - - inline bool resize (int size_) - { - unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; - if (!alloc (size)) - return false; - - if (size > len) - memset (arrayZ + len, 0, (size - len) * sizeof (*arrayZ)); - - len = size; - return true; - } - - inline void pop (void) - { - if (!len) return; - len--; - } - - inline void remove (unsigned int i) - { - if (unlikely (i >= len)) - return; - memmove (static_cast (&arrayZ[i]), - static_cast (&arrayZ[i + 1]), - (len - i - 1) * sizeof (Type)); - len--; - } - - inline void shrink (int size_) - { - unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; - if (size < len) - len = size; - } - - template - inline Type *find (T v) { - for (unsigned int i = 0; i < len; i++) - if (arrayZ[i] == v) - return &arrayZ[i]; - return nullptr; - } - template - inline const Type *find (T v) const { - for (unsigned int i = 0; i < len; i++) - if (arrayZ[i] == v) - return &arrayZ[i]; - return nullptr; - } - - inline void qsort (int (*cmp)(const void*, const void*)) - { - ::qsort (arrayZ, len, sizeof (Type), cmp); - } - - inline void qsort (void) - { - ::qsort (arrayZ, len, sizeof (Type), Type::cmp); - } - - inline void qsort (unsigned int start, unsigned int end) - { - ::qsort (arrayZ + start, end - start, sizeof (Type), Type::cmp); - } - - template - inline Type *lsearch (const T &x) - { - for (unsigned int i = 0; i < len; i++) - if (0 == this->arrayZ[i].cmp (&x)) - return &arrayZ[i]; - return nullptr; - } - - template - inline Type *bsearch (const T &x) - { - unsigned int i; - return bfind (x, &i) ? &arrayZ[i] : nullptr; - } - template - inline const Type *bsearch (const T &x) const - { - unsigned int i; - return bfind (x, &i) ? &arrayZ[i] : nullptr; - } - template - inline bool bfind (const T &x, unsigned int *i) const - { - int min = 0, max = (int) this->len - 1; - while (min <= max) - { - int mid = (min + max) / 2; - int c = this->arrayZ[mid].cmp (&x); - if (c < 0) - max = mid - 1; - else if (c > 0) - min = mid + 1; - else - { - *i = mid; - return true; - } - } - if (max < 0 || (max < (int) this->len && this->arrayZ[max].cmp (&x) > 0)) - max++; - *i = max; - return false; - } - - inline void fini (void) - { - if (arrayZ != static_array) - free (arrayZ); - arrayZ = nullptr; - allocated = len = 0; - } -}; - - -#define HB_LOCKABLE_SET_INIT {HB_VECTOR_INIT} -template -struct hb_lockable_set_t -{ - hb_vector_t items; - - inline void init (void) { items.init (); } - - template - inline item_t *replace_or_insert (T v, lock_t &l, bool replace) - { - l.lock (); - item_t *item = items.find (v); - if (item) { - if (replace) { - item_t old = *item; - *item = v; - l.unlock (); - old.fini (); - } - else { - item = nullptr; - l.unlock (); - } - } else { - item = items.push (v); - l.unlock (); - } - return item; - } - - template - inline void remove (T v, lock_t &l) - { - l.lock (); - item_t *item = items.find (v); - if (item) { - item_t old = *item; - *item = items[items.len - 1]; - items.pop (); - l.unlock (); - old.fini (); - } else { - l.unlock (); - } - } - - template - inline bool find (T v, item_t *i, lock_t &l) - { - l.lock (); - item_t *item = items.find (v); - if (item) - *i = *item; - l.unlock (); - return !!item; - } - - template - inline item_t *find_or_insert (T v, lock_t &l) - { - l.lock (); - item_t *item = items.find (v); - if (!item) { - item = items.push (v); - } - l.unlock (); - return item; - } - - inline void fini (lock_t &l) - { - if (!items.len) { - /* No need for locking. */ - items.fini (); - return; - } - l.lock (); - while (items.len) { - item_t old = items[items.len - 1]; - items.pop (); - l.unlock (); - old.fini (); - l.lock (); - } - items.fini (); - l.unlock (); - } - -}; - - template struct hb_auto_t : Type { diff -Nru harfbuzz-1.8.5/src/hb-face.cc harfbuzz-1.8.8/src/hb-face.cc --- harfbuzz-1.8.5/src/hb-face.cc 2018-07-23 21:36:27.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-face.cc 2018-08-14 16:48:02.000000000 +0000 @@ -33,7 +33,6 @@ #include "hb-open-file-private.hh" - /** * hb_face_count: Get number of faces on the blob * @blob: @@ -51,7 +50,8 @@ return 0; /* TODO We shouldn't be sanitizing blob. Port to run sanitizer and return if not sane. */ - hb_blob_t *sanitized = OT::hb_sanitize_context_t().sanitize_blob (hb_blob_reference (blob)); + /* Make API signature const after. */ + hb_blob_t *sanitized = hb_sanitize_context_t ().sanitize_blob (hb_blob_reference (blob)); const OT::OpenTypeFontFile& ot = *sanitized->as (); unsigned int ret = ot.get_face_count (); hb_blob_destroy (sanitized); @@ -63,7 +63,8 @@ * hb_face_t */ -const hb_face_t _hb_face_nil = { +DEFINE_NULL_INSTANCE (hb_face_t) = +{ HB_OBJECT_HEADER_STATIC, true, /* immutable */ @@ -77,12 +78,12 @@ 0, /* num_glyphs */ { -#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, +#define HB_SHAPER_IMPLEMENT(shaper) HB_ATOMIC_PTR_INIT (HB_SHAPER_DATA_INVALID), #include "hb-shaper-list.hh" #undef HB_SHAPER_IMPLEMENT }, - nullptr, /* shape_plans */ + HB_ATOMIC_PTR_INIT (nullptr), /* shape_plans */ }; @@ -189,7 +190,7 @@ if (unlikely (!blob)) blob = hb_blob_get_empty (); - hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (OT::hb_sanitize_context_t().sanitize_blob (hb_blob_reference (blob)), index); + hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (hb_sanitize_context_t ().sanitize_blob (hb_blob_reference (blob)), index); if (unlikely (!closure)) return hb_face_get_empty (); @@ -215,7 +216,7 @@ hb_face_t * hb_face_get_empty (void) { - return const_cast (&_hb_face_nil); + return const_cast (&Null(hb_face_t)); } @@ -248,7 +249,7 @@ { if (!hb_object_destroy (face)) return; - for (hb_face_t::plan_node_t *node = face->shape_plans; node; ) + for (hb_face_t::plan_node_t *node = face->shape_plans.get (); node; ) { hb_face_t::plan_node_t *next = node->next; hb_shape_plan_destroy (node->shape_plan); @@ -302,7 +303,7 @@ * Since: 0.9.2 **/ void * -hb_face_get_user_data (hb_face_t *face, +hb_face_get_user_data (const hb_face_t *face, hb_user_data_key_t *key) { return hb_object_get_user_data (face, key); @@ -336,7 +337,7 @@ * Since: 0.9.2 **/ hb_bool_t -hb_face_is_immutable (hb_face_t *face) +hb_face_is_immutable (const hb_face_t *face) { return face->immutable; } @@ -354,8 +355,8 @@ * Since: 0.9.2 **/ hb_blob_t * -hb_face_reference_table (hb_face_t *face, - hb_tag_t tag) +hb_face_reference_table (const hb_face_t *face, + hb_tag_t tag) { return face->reference_table (tag); } @@ -406,7 +407,7 @@ * Since: 0.9.2 **/ unsigned int -hb_face_get_index (hb_face_t *face) +hb_face_get_index (const hb_face_t *face) { return face->index; } @@ -441,7 +442,7 @@ * Since: 0.9.2 **/ unsigned int -hb_face_get_upem (hb_face_t *face) +hb_face_get_upem (const hb_face_t *face) { return face->get_upem (); } @@ -476,7 +477,7 @@ * Since: 0.9.7 **/ unsigned int -hb_face_get_glyph_count (hb_face_t *face) +hb_face_get_glyph_count (const hb_face_t *face) { return face->get_num_glyphs (); } @@ -492,7 +493,7 @@ * Since: 1.6.0 **/ unsigned int -hb_face_get_table_tags (hb_face_t *face, +hb_face_get_table_tags (const hb_face_t *face, unsigned int start_offset, unsigned int *table_count, /* IN/OUT */ hb_tag_t *table_tags /* OUT */) diff -Nru harfbuzz-1.8.5/src/hb-face.h harfbuzz-1.8.8/src/hb-face.h --- harfbuzz-1.8.5/src/hb-face.h 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-face.h 2018-08-14 16:48:02.000000000 +0000 @@ -76,19 +76,19 @@ hb_bool_t replace); HB_EXTERN void * -hb_face_get_user_data (hb_face_t *face, +hb_face_get_user_data (const hb_face_t *face, hb_user_data_key_t *key); HB_EXTERN void hb_face_make_immutable (hb_face_t *face); HB_EXTERN hb_bool_t -hb_face_is_immutable (hb_face_t *face); +hb_face_is_immutable (const hb_face_t *face); HB_EXTERN hb_blob_t * -hb_face_reference_table (hb_face_t *face, - hb_tag_t tag); +hb_face_reference_table (const hb_face_t *face, + hb_tag_t tag); HB_EXTERN hb_blob_t * hb_face_reference_blob (hb_face_t *face); @@ -98,24 +98,24 @@ unsigned int index); HB_EXTERN unsigned int -hb_face_get_index (hb_face_t *face); +hb_face_get_index (const hb_face_t *face); HB_EXTERN void hb_face_set_upem (hb_face_t *face, unsigned int upem); HB_EXTERN unsigned int -hb_face_get_upem (hb_face_t *face); +hb_face_get_upem (const hb_face_t *face); HB_EXTERN void hb_face_set_glyph_count (hb_face_t *face, unsigned int glyph_count); HB_EXTERN unsigned int -hb_face_get_glyph_count (hb_face_t *face); +hb_face_get_glyph_count (const hb_face_t *face); HB_EXTERN unsigned int -hb_face_get_table_tags (hb_face_t *face, +hb_face_get_table_tags (const hb_face_t *face, unsigned int start_offset, unsigned int *table_count, /* IN/OUT */ hb_tag_t *table_tags /* OUT */); diff -Nru harfbuzz-1.8.5/src/hb-face-private.hh harfbuzz-1.8.8/src/hb-face-private.hh --- harfbuzz-1.8.5/src/hb-face-private.hh 2018-07-17 16:50:00.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-face-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -39,7 +39,8 @@ * hb_face_t */ -struct hb_face_t { +struct hb_face_t +{ hb_object_header_t header; ASSERT_POD (); @@ -55,15 +56,13 @@ struct hb_shaper_data_t shaper_data; /* Various shaper data. */ - /* Various non-shaping data. */ - /* ... */ - /* Cache */ - struct plan_node_t { + struct plan_node_t + { hb_shape_plan_t *shape_plan; plan_node_t *next; - } *shape_plans; - + }; + hb_atomic_ptr_t shape_plans; inline hb_blob_t *reference_table (hb_tag_t tag) const { @@ -97,8 +96,7 @@ HB_INTERNAL void load_upem (void) const; HB_INTERNAL void load_num_glyphs (void) const; }; - -extern HB_INTERNAL const hb_face_t _hb_face_nil; +DECLARE_NULL_INSTANCE (hb_face_t); #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, face); diff -Nru harfbuzz-1.8.5/src/hb-fallback-shape.cc harfbuzz-1.8.8/src/hb-fallback-shape.cc --- harfbuzz-1.8.5/src/hb-fallback-shape.cc 2018-05-08 09:55:16.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-fallback-shape.cc 2018-08-14 16:48:02.000000000 +0000 @@ -36,16 +36,16 @@ * shaper face data */ -struct hb_fallback_shaper_face_data_t {}; +struct hb_fallback_face_data_t {}; -hb_fallback_shaper_face_data_t * +hb_fallback_face_data_t * _hb_fallback_shaper_face_data_create (hb_face_t *face HB_UNUSED) { - return (hb_fallback_shaper_face_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_fallback_face_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_fallback_shaper_face_data_destroy (hb_fallback_shaper_face_data_t *data HB_UNUSED) +_hb_fallback_shaper_face_data_destroy (hb_fallback_face_data_t *data HB_UNUSED) { } @@ -54,16 +54,16 @@ * shaper font data */ -struct hb_fallback_shaper_font_data_t {}; +struct hb_fallback_font_data_t {}; -hb_fallback_shaper_font_data_t * +hb_fallback_font_data_t * _hb_fallback_shaper_font_data_create (hb_font_t *font HB_UNUSED) { - return (hb_fallback_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_fallback_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_fallback_shaper_font_data_destroy (hb_fallback_shaper_font_data_t *data HB_UNUSED) +_hb_fallback_shaper_font_data_destroy (hb_fallback_font_data_t *data HB_UNUSED) { } @@ -72,20 +72,20 @@ * shaper shape_plan data */ -struct hb_fallback_shaper_shape_plan_data_t {}; +struct hb_fallback_shape_plan_data_t {}; -hb_fallback_shaper_shape_plan_data_t * +hb_fallback_shape_plan_data_t * _hb_fallback_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_fallback_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_fallback_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_fallback_shaper_shape_plan_data_destroy (hb_fallback_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_fallback_shaper_shape_plan_data_destroy (hb_fallback_shape_plan_data_t *data HB_UNUSED) { } diff -Nru harfbuzz-1.8.5/src/hb-font.cc harfbuzz-1.8.8/src/hb-font.cc --- harfbuzz-1.8.5/src/hb-font.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-font.cc 2018-08-14 16:48:02.000000000 +0000 @@ -29,6 +29,7 @@ #include "hb-private.hh" #include "hb-font-private.hh" +#include "hb-machinery-private.hh" /* @@ -45,10 +46,10 @@ return false; } static hb_bool_t -hb_font_get_font_h_extents_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_font_extents_t *metrics, - void *user_data HB_UNUSED) +hb_font_get_font_h_extents_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_font_extents_t *metrics, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_font_h_extents (metrics); if (ret) { @@ -69,10 +70,10 @@ return false; } static hb_bool_t -hb_font_get_font_v_extents_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_font_extents_t *metrics, - void *user_data HB_UNUSED) +hb_font_get_font_v_extents_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_font_extents_t *metrics, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_font_v_extents (metrics); if (ret) { @@ -94,11 +95,11 @@ return false; } static hb_bool_t -hb_font_get_nominal_glyph_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t unicode, - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) +hb_font_get_nominal_glyph_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t unicode, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) { return font->parent->get_nominal_glyph (unicode, glyph); } @@ -115,12 +116,12 @@ return false; } static hb_bool_t -hb_font_get_variation_glyph_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t unicode, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) +hb_font_get_variation_glyph_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t unicode, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) { return font->parent->get_variation_glyph (unicode, variation_selector, glyph); } @@ -129,16 +130,16 @@ static hb_position_t hb_font_get_glyph_h_advance_nil (hb_font_t *font, void *font_data HB_UNUSED, - hb_codepoint_t glyph, + hb_codepoint_t glyph HB_UNUSED, void *user_data HB_UNUSED) { return font->x_scale; } static hb_position_t -hb_font_get_glyph_h_advance_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) +hb_font_get_glyph_h_advance_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + void *user_data HB_UNUSED) { return font->parent_scale_x_distance (font->parent->get_glyph_h_advance (glyph)); } @@ -146,21 +147,85 @@ static hb_position_t hb_font_get_glyph_v_advance_nil (hb_font_t *font, void *font_data HB_UNUSED, - hb_codepoint_t glyph, + hb_codepoint_t glyph HB_UNUSED, void *user_data HB_UNUSED) { /* TODO use font_extents.ascender+descender */ return font->y_scale; } static hb_position_t -hb_font_get_glyph_v_advance_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - void *user_data HB_UNUSED) +hb_font_get_glyph_v_advance_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + void *user_data HB_UNUSED) { return font->parent_scale_y_distance (font->parent->get_glyph_v_advance (glyph)); } +#define hb_font_get_glyph_h_advances_nil hb_font_get_glyph_h_advances_default +static void +hb_font_get_glyph_h_advances_default (hb_font_t* font, + void* font_data HB_UNUSED, + unsigned int count, + hb_codepoint_t *first_glyph, + unsigned int glyph_stride, + hb_position_t *first_advance, + unsigned int advance_stride, + void *user_data HB_UNUSED) +{ + if (font->has_glyph_h_advance_func ()) + { + for (unsigned int i = 0; i < count; i++) + { + *first_advance = font->get_glyph_h_advance (*first_glyph); + first_glyph = &StructAtOffset (first_glyph, glyph_stride); + first_advance = &StructAtOffset (first_advance, advance_stride); + } + return; + } + + font->parent->get_glyph_h_advances (count, + first_glyph, glyph_stride, + first_advance, advance_stride); + for (unsigned int i = 0; i < count; i++) + { + *first_advance = font->parent_scale_x_distance (*first_advance); + first_advance = &StructAtOffset (first_advance, advance_stride); + } +} + +#define hb_font_get_glyph_v_advances_nil hb_font_get_glyph_v_advances_default +static void +hb_font_get_glyph_v_advances_default (hb_font_t* font, + void* font_data HB_UNUSED, + unsigned int count, + hb_codepoint_t *first_glyph, + unsigned int glyph_stride, + hb_position_t *first_advance, + unsigned int advance_stride, + void *user_data HB_UNUSED) +{ + if (font->has_glyph_v_advance_func ()) + { + for (unsigned int i = 0; i < count; i++) + { + *first_advance = font->get_glyph_v_advance (*first_glyph); + first_glyph = &StructAtOffset (first_glyph, glyph_stride); + first_advance = &StructAtOffset (first_advance, advance_stride); + } + return; + } + + font->parent->get_glyph_v_advances (count, + first_glyph, glyph_stride, + first_advance, advance_stride); + for (unsigned int i = 0; i < count; i++) + { + *first_advance = font->parent_scale_y_distance (*first_advance); + first_advance = &StructAtOffset (first_advance, advance_stride); + } +} + static hb_bool_t hb_font_get_glyph_h_origin_nil (hb_font_t *font HB_UNUSED, void *font_data HB_UNUSED, @@ -173,12 +238,12 @@ return true; } static hb_bool_t -hb_font_get_glyph_h_origin_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) +hb_font_get_glyph_h_origin_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_glyph_h_origin (glyph, x, y); if (ret) @@ -198,12 +263,12 @@ return false; } static hb_bool_t -hb_font_get_glyph_v_origin_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) +hb_font_get_glyph_v_origin_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_glyph_v_origin (glyph, x, y); if (ret) @@ -221,11 +286,11 @@ return 0; } static hb_position_t -hb_font_get_glyph_h_kerning_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t left_glyph, - hb_codepoint_t right_glyph, - void *user_data HB_UNUSED) +hb_font_get_glyph_h_kerning_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t left_glyph, + hb_codepoint_t right_glyph, + void *user_data HB_UNUSED) { return font->parent_scale_x_distance (font->parent->get_glyph_h_kerning (left_glyph, right_glyph)); } @@ -240,11 +305,11 @@ return 0; } static hb_position_t -hb_font_get_glyph_v_kerning_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t top_glyph, - hb_codepoint_t bottom_glyph, - void *user_data HB_UNUSED) +hb_font_get_glyph_v_kerning_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t top_glyph, + hb_codepoint_t bottom_glyph, + void *user_data HB_UNUSED) { return font->parent_scale_y_distance (font->parent->get_glyph_v_kerning (top_glyph, bottom_glyph)); } @@ -260,11 +325,11 @@ return false; } static hb_bool_t -hb_font_get_glyph_extents_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - hb_glyph_extents_t *extents, - void *user_data HB_UNUSED) +hb_font_get_glyph_extents_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + hb_glyph_extents_t *extents, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_glyph_extents (glyph, extents); if (ret) { @@ -287,13 +352,13 @@ return false; } static hb_bool_t -hb_font_get_glyph_contour_point_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - unsigned int point_index, - hb_position_t *x, - hb_position_t *y, - void *user_data HB_UNUSED) +hb_font_get_glyph_contour_point_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + unsigned int point_index, + hb_position_t *x, + hb_position_t *y, + void *user_data HB_UNUSED) { hb_bool_t ret = font->parent->get_glyph_contour_point (glyph, point_index, x, y); if (ret) @@ -312,11 +377,11 @@ return false; } static hb_bool_t -hb_font_get_glyph_name_parent (hb_font_t *font, - void *font_data HB_UNUSED, - hb_codepoint_t glyph, - char *name, unsigned int size, - void *user_data HB_UNUSED) +hb_font_get_glyph_name_default (hb_font_t *font, + void *font_data HB_UNUSED, + hb_codepoint_t glyph, + char *name, unsigned int size, + void *user_data HB_UNUSED) { return font->parent->get_glyph_name (glyph, name, size); } @@ -332,16 +397,17 @@ return false; } static hb_bool_t -hb_font_get_glyph_from_name_parent (hb_font_t *font, - void *font_data HB_UNUSED, - const char *name, int len, /* -1 means nul-terminated */ - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) +hb_font_get_glyph_from_name_default (hb_font_t *font, + void *font_data HB_UNUSED, + const char *name, int len, /* -1 means nul-terminated */ + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) { return font->parent->get_glyph_from_name (name, len, glyph); } -static const hb_font_funcs_t _hb_font_funcs_nil = { +DEFINE_NULL_INSTANCE (hb_font_funcs_t) = +{ HB_OBJECT_HEADER_STATIC, true, /* immutable */ @@ -364,7 +430,8 @@ } } }; -static const hb_font_funcs_t _hb_font_funcs_parent = { + +static const hb_font_funcs_t _hb_font_funcs_default = { HB_OBJECT_HEADER_STATIC, true, /* immutable */ @@ -381,7 +448,7 @@ }, { { -#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_parent, +#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_default, HB_FONT_FUNCS_IMPLEMENT_CALLBACKS #undef HB_FONT_FUNC_IMPLEMENT } @@ -406,7 +473,7 @@ if (!(ffuncs = hb_object_create ())) return hb_font_funcs_get_empty (); - ffuncs->get = _hb_font_funcs_parent.get; + ffuncs->get = _hb_font_funcs_default.get; return ffuncs; } @@ -423,7 +490,7 @@ hb_font_funcs_t * hb_font_funcs_get_empty (void) { - return const_cast (&_hb_font_funcs_parent); + return const_cast (&_hb_font_funcs_default); } /** @@ -562,9 +629,9 @@ ffuncs->user_data.name = user_data; \ ffuncs->destroy.name = destroy; \ } else { \ - ffuncs->get.f.name = hb_font_get_##name##_parent; \ - ffuncs->user_data.name = nullptr; \ - ffuncs->destroy.name = nullptr; \ + ffuncs->get.f.name = hb_font_get_##name##_default; \ + ffuncs->user_data.name = nullptr; \ + ffuncs->destroy.name = nullptr; \ } \ } @@ -574,9 +641,8 @@ bool hb_font_t::has_func (unsigned int i) { - if (parent && parent != hb_font_get_empty () && parent->has_func (i)) - return true; - return this->klass->get.array[i] != _hb_font_funcs_parent.get.array[i]; + return (this->klass->get.array[i] != _hb_font_funcs_default.get.array[i]) || + (parent && parent != &_hb_Null_hb_font_t && parent->has_func (i)); } /* Public getters */ @@ -718,6 +784,43 @@ } /** + * hb_font_get_glyph_h_advances: + * @font: a font. + * + * + * + * Since: 1.8.6 + **/ +void +hb_font_get_glyph_h_advances (hb_font_t* font, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride) +{ + font->get_glyph_h_advances (count, first_glyph, glyph_stride, first_advance, advance_stride); +} +/** + * hb_font_get_glyph_v_advances: + * @font: a font. + * + * + * + * Since: 1.8.6 + **/ +void +hb_font_get_glyph_v_advances (hb_font_t* font, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride) +{ + font->get_glyph_v_advances (count, first_glyph, glyph_stride, first_advance, advance_stride); +} + +/** * hb_font_get_glyph_h_origin: * @font: a font. * @glyph: @@ -921,6 +1024,26 @@ { return font->get_glyph_advance_for_direction (glyph, direction, x, y); } +/** + * hb_font_get_glyph_advances_for_direction: + * @font: a font. + * @direction: + * + * + * + * Since: 1.8.6 + **/ +HB_EXTERN void +hb_font_get_glyph_advances_for_direction (hb_font_t* font, + hb_direction_t direction, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride) +{ + font->get_glyph_advances_for_direction (direction, count, first_glyph, glyph_stride, first_advance, advance_stride); +} /** * hb_font_get_glyph_origin_for_direction: @@ -1100,6 +1223,37 @@ * hb_font_t */ +DEFINE_NULL_INSTANCE (hb_font_t) = +{ + HB_OBJECT_HEADER_STATIC, + + true, /* immutable */ + + nullptr, /* parent */ + const_cast (&_hb_Null_hb_face_t), + + 1000, /* x_scale */ + 1000, /* y_scale */ + + 0, /* x_ppem */ + 0, /* y_ppem */ + 0, /* ptem */ + + 0, /* num_coords */ + nullptr, /* coords */ + + const_cast (&_hb_Null_hb_font_funcs_t), /* klass */ + nullptr, /* user_data */ + nullptr, /* destroy */ + + { +#define HB_SHAPER_IMPLEMENT(shaper) HB_ATOMIC_PTR_INIT (HB_SHAPER_DATA_INVALID), +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT + } +}; + + /** * hb_font_create: (Xconstructor) * @face: a face. @@ -1187,36 +1341,7 @@ hb_font_t * hb_font_get_empty (void) { - static const hb_font_t _hb_font_nil = { - HB_OBJECT_HEADER_STATIC, - - true, /* immutable */ - - nullptr, /* parent */ - const_cast (&_hb_face_nil), - - 1000, /* x_scale */ - 1000, /* y_scale */ - - 0, /* x_ppem */ - 0, /* y_ppem */ - 0, /* ptem */ - - 0, /* num_coords */ - nullptr, /* coords */ - - const_cast (&_hb_font_funcs_nil), /* klass */ - nullptr, /* user_data */ - nullptr, /* destroy */ - - { -#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT - } - }; - - return const_cast (&_hb_font_nil); + return const_cast (&Null(hb_font_t)); } /** diff -Nru harfbuzz-1.8.5/src/hb-font.h harfbuzz-1.8.8/src/hb-font.h --- harfbuzz-1.8.5/src/hb-font.h 2018-02-14 00:27:23.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-font.h 2018-08-14 16:48:02.000000000 +0000 @@ -132,6 +132,16 @@ typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_h_advance_func_t; typedef hb_font_get_glyph_advance_func_t hb_font_get_glyph_v_advance_func_t; +typedef void (*hb_font_get_glyph_advances_func_t) (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); +typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_h_advances_func_t; +typedef hb_font_get_glyph_advances_func_t hb_font_get_glyph_v_advances_func_t; + typedef hb_bool_t (*hb_font_get_glyph_origin_func_t) (hb_font_t *font, void *font_data, hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y, @@ -265,6 +275,38 @@ void *user_data, hb_destroy_func_t destroy); /** + * hb_font_funcs_set_glyph_h_advances_func: + * @ffuncs: font functions. + * @func: (closure user_data) (destroy destroy) (scope notified): + * @user_data: + * @destroy: + * + * + * + * Since: 1.8.6 + **/ +HB_EXTERN void +hb_font_funcs_set_glyph_h_advances_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_h_advances_func_t func, + void *user_data, hb_destroy_func_t destroy); + +/** + * hb_font_funcs_set_glyph_v_advances_func: + * @ffuncs: font functions. + * @func: (closure user_data) (destroy destroy) (scope notified): + * @user_data: + * @destroy: + * + * + * + * Since: 1.8.6 + **/ +HB_EXTERN void +hb_font_funcs_set_glyph_v_advances_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_v_advances_func_t func, + void *user_data, hb_destroy_func_t destroy); + +/** * hb_font_funcs_set_glyph_h_origin_func: * @ffuncs: font functions. * @func: (closure user_data) (destroy destroy) (scope notified): @@ -417,6 +459,21 @@ hb_font_get_glyph_v_advance (hb_font_t *font, hb_codepoint_t glyph); +HB_EXTERN void +hb_font_get_glyph_h_advances (hb_font_t* font, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride); +HB_EXTERN void +hb_font_get_glyph_v_advances (hb_font_t* font, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride); + HB_EXTERN hb_bool_t hb_font_get_glyph_h_origin (hb_font_t *font, hb_codepoint_t glyph, @@ -472,6 +529,14 @@ hb_direction_t direction, hb_position_t *x, hb_position_t *y); HB_EXTERN void +hb_font_get_glyph_advances_for_direction (hb_font_t* font, + hb_direction_t direction, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride); +HB_EXTERN void hb_font_get_glyph_origin_for_direction (hb_font_t *font, hb_codepoint_t glyph, hb_direction_t direction, diff -Nru harfbuzz-1.8.5/src/hb-font-private.hh harfbuzz-1.8.8/src/hb-font-private.hh --- harfbuzz-1.8.5/src/hb-font-private.hh 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-font-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -35,7 +35,6 @@ #include "hb-shaper-private.hh" - /* * hb_font_funcs_t */ @@ -47,6 +46,8 @@ HB_FONT_FUNC_IMPLEMENT (variation_glyph) \ HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \ HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \ + HB_FONT_FUNC_IMPLEMENT (glyph_h_advances) \ + HB_FONT_FUNC_IMPLEMENT (glyph_v_advances) \ HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \ HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \ HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \ @@ -57,7 +58,8 @@ HB_FONT_FUNC_IMPLEMENT (glyph_from_name) \ /* ^--- Add new callbacks here */ -struct hb_font_funcs_t { +struct hb_font_funcs_t +{ hb_object_header_t header; ASSERT_POD (); @@ -89,14 +91,15 @@ ]) (void); } get; }; - +DECLARE_NULL_INSTANCE (hb_font_funcs_t); /* * hb_font_t */ -struct hb_font_t { +struct hb_font_t +{ hb_object_header_t header; ASSERT_POD (); @@ -233,6 +236,32 @@ klass->user_data.glyph_v_advance); } + inline void get_glyph_h_advances (unsigned int count, + hb_codepoint_t *first_glyph, + unsigned int glyph_stride, + hb_position_t *first_advance, + unsigned int advance_stride) + { + return klass->get.f.glyph_h_advances (this, user_data, + count, + first_glyph, glyph_stride, + first_advance, advance_stride, + klass->user_data.glyph_h_advances); + } + + inline void get_glyph_v_advances (unsigned int count, + hb_codepoint_t *first_glyph, + unsigned int glyph_stride, + hb_position_t *first_advance, + unsigned int advance_stride) + { + return klass->get.f.glyph_v_advances (this, user_data, + count, + first_glyph, glyph_stride, + first_advance, advance_stride, + klass->user_data.glyph_v_advances); + } + inline hb_bool_t get_glyph_h_origin (hb_codepoint_t glyph, hb_position_t *x, hb_position_t *y) { @@ -341,13 +370,23 @@ hb_direction_t direction, hb_position_t *x, hb_position_t *y) { - if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) { + *x = *y = 0; + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) *x = get_glyph_h_advance (glyph); - *y = 0; - } else { - *x = 0; + else *y = get_glyph_v_advance (glyph); - } + } + inline void get_glyph_advances_for_direction (hb_direction_t direction, + unsigned count, + hb_codepoint_t *first_glyph, + unsigned glyph_stride, + hb_position_t *first_advance, + unsigned advance_stride) + { + if (likely (HB_DIRECTION_IS_HORIZONTAL (direction))) + get_glyph_h_advances (count, first_glyph, glyph_stride, first_advance, advance_stride); + else + get_glyph_v_advances (count, first_glyph, glyph_stride, first_advance, advance_stride); } inline void guess_v_origin_minus_h_origin (hb_codepoint_t glyph, @@ -553,6 +592,7 @@ return (float) v * scale / face->get_upem (); } }; +DECLARE_NULL_INSTANCE (hb_font_t); #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, font); diff -Nru harfbuzz-1.8.5/src/hb-ft.cc harfbuzz-1.8.8/src/hb-ft.cc --- harfbuzz-1.8.5/src/hb-ft.cc 2018-07-27 21:54:58.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ft.cc 2018-08-14 16:48:02.000000000 +0000 @@ -32,6 +32,7 @@ #include "hb-ft.h" #include "hb-font-private.hh" +#include "hb-machinery-private.hh" #include FT_ADVANCES_H #include FT_MULTIPLE_MASTERS_H @@ -416,30 +417,13 @@ return true; } -static hb_font_funcs_t *static_ft_funcs = nullptr; +static void free_static_ft_funcs (void); -#ifdef HB_USE_ATEXIT -static -void free_static_ft_funcs (void) +static struct hb_ft_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t { -retry: - hb_font_funcs_t *ft_funcs = (hb_font_funcs_t *) hb_atomic_ptr_get (&static_ft_funcs); - if (!hb_atomic_ptr_cmpexch (&static_ft_funcs, ft_funcs, nullptr)) - goto retry; - - hb_font_funcs_destroy (ft_funcs); -} -#endif - -static void -_hb_ft_font_set_funcs (hb_font_t *font, FT_Face ft_face, bool unref) -{ -retry: - hb_font_funcs_t *funcs = (hb_font_funcs_t *) hb_atomic_ptr_get (&static_ft_funcs); - - if (unlikely (!funcs)) + static inline hb_font_funcs_t *create (void) { - funcs = hb_font_funcs_create (); + hb_font_funcs_t *funcs = hb_font_funcs_create (); hb_font_funcs_set_font_h_extents_func (funcs, hb_ft_get_font_h_extents, nullptr, nullptr); //hb_font_funcs_set_font_v_extents_func (funcs, hb_ft_get_font_v_extents, nullptr, nullptr); @@ -458,20 +442,35 @@ hb_font_funcs_make_immutable (funcs); - if (!hb_atomic_ptr_cmpexch (&static_ft_funcs, nullptr, funcs)) { - hb_font_funcs_destroy (funcs); - goto retry; - } +#ifdef HB_USE_ATEXIT + atexit (free_static_ft_funcs); +#endif + + return funcs; + } +} static_ft_funcs; #ifdef HB_USE_ATEXIT - atexit (free_static_ft_funcs); /* First person registers atexit() callback. */ +static +void free_static_ft_funcs (void) +{ + static_ft_funcs.free_instance (); +} #endif - }; +static hb_font_funcs_t * +_hb_ft_get_font_funcs (void) +{ + return static_ft_funcs.get_unconst (); +} + +static void +_hb_ft_font_set_funcs (hb_font_t *font, FT_Face ft_face, bool unref) +{ bool symbol = ft_face->charmap && ft_face->charmap->encoding == FT_ENCODING_MS_SYMBOL; hb_font_set_funcs (font, - funcs, + _hb_ft_get_font_funcs (), _hb_ft_font_create (ft_face, symbol, unref), _hb_ft_font_destroy); } @@ -684,46 +683,45 @@ } -/* Thread-safe, lock-free, FT_Library */ +static void free_static_ft_library (void); -static FT_Library ft_library; +static struct hb_ft_library_lazy_loader_t : hb_lazy_loader_t::value, + hb_ft_library_lazy_loader_t> +{ + static inline FT_Library create (void) + { + FT_Library l; + if (FT_Init_FreeType (&l)) + return nullptr; + +#ifdef HB_USE_ATEXIT + atexit (free_static_ft_library); +#endif + + return l; + } + static inline void destroy (FT_Library l) + { + FT_Done_FreeType (l); + } + static inline FT_Library get_null (void) + { + return nullptr; + } +} static_ft_library; #ifdef HB_USE_ATEXIT static -void free_ft_library (void) +void free_static_ft_library (void) { -retry: - FT_Library library = (FT_Library) hb_atomic_ptr_get (&ft_library); - if (!hb_atomic_ptr_cmpexch (&ft_library, library, nullptr)) - goto retry; - - FT_Done_FreeType (library); + static_ft_library.free_instance (); } #endif static FT_Library get_ft_library (void) { -retry: - FT_Library library = (FT_Library) hb_atomic_ptr_get (&ft_library); - - if (unlikely (!library)) - { - /* Not found; allocate one. */ - if (FT_Init_FreeType (&library)) - return nullptr; - - if (!hb_atomic_ptr_cmpexch (&ft_library, nullptr, library)) { - FT_Done_FreeType (library); - goto retry; - } - -#ifdef HB_USE_ATEXIT - atexit (free_ft_library); /* First person registers atexit() callback. */ -#endif - } - - return library; + return static_ft_library.get_unconst (); } static void diff -Nru harfbuzz-1.8.5/src/hb-glib.cc harfbuzz-1.8.8/src/hb-glib.cc --- harfbuzz-1.8.5/src/hb-glib.cc 2018-06-02 22:39:30.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-glib.cc 2018-08-14 16:48:02.000000000 +0000 @@ -31,6 +31,7 @@ #include "hb-glib.h" #include "hb-unicode-private.hh" +#include "hb-machinery-private.hh" #if !GLIB_CHECK_VERSION(2,29,14) @@ -364,30 +365,15 @@ return utf8_decomposed_len; } -static hb_unicode_funcs_t *static_glib_funcs = nullptr; -#ifdef HB_USE_ATEXIT -static -void free_static_glib_funcs (void) -{ -retry: - hb_unicode_funcs_t *glib_funcs = (hb_unicode_funcs_t *) hb_atomic_ptr_get (&static_glib_funcs); - if (!hb_atomic_ptr_cmpexch (&static_glib_funcs, glib_funcs, nullptr)) - goto retry; - hb_unicode_funcs_destroy (glib_funcs); -} -#endif +static void free_static_glib_funcs (void); -hb_unicode_funcs_t * -hb_glib_get_unicode_funcs (void) +static struct hb_glib_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_t { -retry: - hb_unicode_funcs_t *funcs = (hb_unicode_funcs_t *) hb_atomic_ptr_get (&static_glib_funcs); - - if (unlikely (!funcs)) + static inline hb_unicode_funcs_t *create (void) { - funcs = hb_unicode_funcs_create (nullptr); + hb_unicode_funcs_t *funcs = hb_unicode_funcs_create (nullptr); #define HB_UNICODE_FUNC_IMPLEMENT(name) \ hb_unicode_funcs_set_##name##_func (funcs, hb_glib_unicode_##name, nullptr, nullptr); @@ -396,19 +382,30 @@ hb_unicode_funcs_make_immutable (funcs); - if (!hb_atomic_ptr_cmpexch (&static_glib_funcs, nullptr, funcs)) { - hb_unicode_funcs_destroy (funcs); - goto retry; - } +#ifdef HB_USE_ATEXIT + atexit (free_static_glib_funcs); +#endif + + return funcs; + } +} static_glib_funcs; #ifdef HB_USE_ATEXIT - atexit (free_static_glib_funcs); /* First person registers atexit() callback. */ +static +void free_static_glib_funcs (void) +{ + static_glib_funcs.free_instance (); +} #endif - }; - return hb_unicode_funcs_reference (funcs); +hb_unicode_funcs_t * +hb_glib_get_unicode_funcs (void) +{ + return static_glib_funcs.get_unconst (); } + + #if GLIB_CHECK_VERSION(2,31,10) static void diff -Nru harfbuzz-1.8.5/src/hb-graphite2.cc harfbuzz-1.8.8/src/hb-graphite2.cc --- harfbuzz-1.8.5/src/hb-graphite2.cc 2018-06-02 22:39:30.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-graphite2.cc 2018-08-14 16:48:02.000000000 +0000 @@ -42,22 +42,24 @@ * shaper face data */ -typedef struct hb_graphite2_tablelist_t { +typedef struct hb_graphite2_tablelist_t +{ struct hb_graphite2_tablelist_t *next; hb_blob_t *blob; unsigned int tag; } hb_graphite2_tablelist_t; -struct hb_graphite2_shaper_face_data_t { +struct hb_graphite2_face_data_t +{ hb_face_t *face; gr_face *grface; - hb_graphite2_tablelist_t *tlist; + hb_atomic_ptr_t tlist; }; static const void *hb_graphite2_get_table (const void *data, unsigned int tag, size_t *len) { - hb_graphite2_shaper_face_data_t *face_data = (hb_graphite2_shaper_face_data_t *) data; - hb_graphite2_tablelist_t *tlist = face_data->tlist; + hb_graphite2_face_data_t *face_data = (hb_graphite2_face_data_t *) data; + hb_graphite2_tablelist_t *tlist = face_data->tlist.get (); hb_blob_t *blob = nullptr; @@ -80,10 +82,10 @@ p->tag = tag; retry: - hb_graphite2_tablelist_t *tlist = (hb_graphite2_tablelist_t *) hb_atomic_ptr_get (&face_data->tlist); + hb_graphite2_tablelist_t *tlist = face_data->tlist.get (); p->next = tlist; - if (!hb_atomic_ptr_cmpexch (&face_data->tlist, tlist, p)) + if (unlikely (!face_data->tlist.cmpexch (tlist, p))) goto retry; } @@ -93,7 +95,7 @@ return d; } -hb_graphite2_shaper_face_data_t * +hb_graphite2_face_data_t * _hb_graphite2_shaper_face_data_create (hb_face_t *face) { hb_blob_t *silf_blob = face->reference_table (HB_GRAPHITE2_TAG_SILF); @@ -106,7 +108,7 @@ } hb_blob_destroy (silf_blob); - hb_graphite2_shaper_face_data_t *data = (hb_graphite2_shaper_face_data_t *) calloc (1, sizeof (hb_graphite2_shaper_face_data_t)); + hb_graphite2_face_data_t *data = (hb_graphite2_face_data_t *) calloc (1, sizeof (hb_graphite2_face_data_t)); if (unlikely (!data)) return nullptr; @@ -122,9 +124,9 @@ } void -_hb_graphite2_shaper_face_data_destroy (hb_graphite2_shaper_face_data_t *data) +_hb_graphite2_shaper_face_data_destroy (hb_graphite2_face_data_t *data) { - hb_graphite2_tablelist_t *tlist = data->tlist; + hb_graphite2_tablelist_t *tlist = data->tlist.get (); while (tlist) { @@ -154,16 +156,16 @@ * shaper font data */ -struct hb_graphite2_shaper_font_data_t {}; +struct hb_graphite2_font_data_t {}; -hb_graphite2_shaper_font_data_t * +hb_graphite2_font_data_t * _hb_graphite2_shaper_font_data_create (hb_font_t *font HB_UNUSED) { - return (hb_graphite2_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_graphite2_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_graphite2_shaper_font_data_destroy (hb_graphite2_shaper_font_data_t *data HB_UNUSED) +_hb_graphite2_shaper_font_data_destroy (hb_graphite2_font_data_t *data HB_UNUSED) { } @@ -181,20 +183,20 @@ * shaper shape_plan data */ -struct hb_graphite2_shaper_shape_plan_data_t {}; +struct hb_graphite2_shape_plan_data_t {}; -hb_graphite2_shaper_shape_plan_data_t * +hb_graphite2_shape_plan_data_t * _hb_graphite2_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_graphite2_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_graphite2_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_graphite2_shaper_shape_plan_data_destroy (hb_graphite2_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_graphite2_shaper_shape_plan_data_destroy (hb_graphite2_shape_plan_data_t *data HB_UNUSED) { } diff -Nru harfbuzz-1.8.5/src/hb-icu.cc harfbuzz-1.8.8/src/hb-icu.cc --- harfbuzz-1.8.5/src/hb-icu.cc 2018-06-02 22:39:30.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-icu.cc 2018-08-14 16:48:02.000000000 +0000 @@ -32,6 +32,7 @@ #include "hb-icu.h" #include "hb-unicode-private.hh" +#include "hb-machinery-private.hh" #include #include @@ -164,10 +165,6 @@ return hb_icu_script_to_script (scriptCode); } -#if U_ICU_VERSION_MAJOR_NUM >= 49 -static const UNormalizer2 *normalizer; -#endif - static hb_bool_t hb_icu_unicode_compose (hb_unicode_funcs_t *ufuncs HB_UNUSED, hb_codepoint_t a, @@ -177,6 +174,7 @@ { #if U_ICU_VERSION_MAJOR_NUM >= 49 { + const UNormalizer2 *normalizer = (const UNormalizer2 *) user_data; UChar32 ret = unorm2_composePair (normalizer, a, b); if (ret < 0) return false; *ab = ret; @@ -222,6 +220,7 @@ { #if U_ICU_VERSION_MAJOR_NUM >= 49 { + const UNormalizer2 *normalizer = (const UNormalizer2 *) user_data; UChar decomposed[4]; int len; UErrorCode icu_err = U_ZERO_ERROR; @@ -345,55 +344,46 @@ } -static hb_unicode_funcs_t *static_icu_funcs = nullptr; - -#ifdef HB_USE_ATEXIT -static -void free_static_icu_funcs (void) -{ -retry: - hb_unicode_funcs_t *icu_funcs = (hb_unicode_funcs_t *) hb_atomic_ptr_get (&static_icu_funcs); - if (!hb_atomic_ptr_cmpexch (&static_icu_funcs, icu_funcs, nullptr)) - goto retry; - - hb_unicode_funcs_destroy (icu_funcs); -} -#endif +static void free_static_icu_funcs (void); -hb_unicode_funcs_t * -hb_icu_get_unicode_funcs (void) +static struct hb_icu_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_t { -retry: - hb_unicode_funcs_t *funcs = (hb_unicode_funcs_t *) hb_atomic_ptr_get (&static_icu_funcs); - - if (unlikely (!funcs)) + static inline hb_unicode_funcs_t *create (void) { + void *user_data = nullptr; #if U_ICU_VERSION_MAJOR_NUM >= 49 - if (!hb_atomic_ptr_get (&normalizer)) { - UErrorCode icu_err = U_ZERO_ERROR; - /* We ignore failure in getNFCInstace(). */ - (void) hb_atomic_ptr_cmpexch (&normalizer, nullptr, unorm2_getNFCInstance (&icu_err)); - } + UErrorCode icu_err = U_ZERO_ERROR; + user_data = (void *) unorm2_getNFCInstance (&icu_err); + assert (user_data); #endif - funcs = hb_unicode_funcs_create (nullptr); + hb_unicode_funcs_t *funcs = hb_unicode_funcs_create (nullptr); #define HB_UNICODE_FUNC_IMPLEMENT(name) \ - hb_unicode_funcs_set_##name##_func (funcs, hb_icu_unicode_##name, nullptr, nullptr); + hb_unicode_funcs_set_##name##_func (funcs, hb_icu_unicode_##name, user_data, nullptr); HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS #undef HB_UNICODE_FUNC_IMPLEMENT hb_unicode_funcs_make_immutable (funcs); - if (!hb_atomic_ptr_cmpexch (&static_icu_funcs, nullptr, funcs)) { - hb_unicode_funcs_destroy (funcs); - goto retry; - } +#ifdef HB_USE_ATEXIT + atexit (free_static_icu_funcs); +#endif + + return funcs; + } +} static_icu_funcs; #ifdef HB_USE_ATEXIT - atexit (free_static_icu_funcs); /* First person registers atexit() callback. */ +static +void free_static_icu_funcs (void) +{ + static_icu_funcs.free_instance (); +} #endif - }; - return hb_unicode_funcs_reference (funcs); +hb_unicode_funcs_t * +hb_icu_get_unicode_funcs (void) +{ + return static_icu_funcs.get_unconst (); } diff -Nru harfbuzz-1.8.5/src/hb-iter-private.hh harfbuzz-1.8.8/src/hb-iter-private.hh --- harfbuzz-1.8.5/src/hb-iter-private.hh 2018-07-27 21:54:15.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-iter-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -72,7 +72,7 @@ array (array_), length (length_) {} /* Emptiness. */ - inline operator bool (void) const { return bool (length); } + explicit_operator inline operator bool (void) const { return bool (length); } /* Current item. */ inline T &operator * (void) diff -Nru harfbuzz-1.8.5/src/hb-machinery-private.hh harfbuzz-1.8.8/src/hb-machinery-private.hh --- harfbuzz-1.8.5/src/hb-machinery-private.hh 2018-07-30 23:39:40.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-machinery-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -30,10 +30,9 @@ #define HB_MACHINERY_PRIVATE_HH #include "hb-private.hh" -#include "hb-iter-private.hh" - +#include "hb-blob-private.hh" -namespace OT { +#include "hb-iter-private.hh" /* @@ -188,7 +187,7 @@ inline void start_processing (void) { - this->start = hb_blob_get_data (this->blob, nullptr); + this->start = this->blob->data; this->end = this->start + this->blob->length; assert (this->start <= this->end); /* Must not overflow. */ this->max_ops = MAX ((unsigned int) (this->end - this->start) * HB_SANITIZE_MAX_OPS_FACTOR, @@ -336,7 +335,7 @@ DEBUG_MSG_FUNC (SANITIZE, start, sane ? "PASSED" : "FAILED"); if (sane) { - blob->lock (); + hb_blob_make_immutable (blob); return blob; } else @@ -350,8 +349,8 @@ inline hb_blob_t *reference_table (const hb_face_t *face, hb_tag_t tableTag = Type::tableTag) { if (!num_glyphs_set) - set_num_glyphs (face->get_num_glyphs ()); - return sanitize_blob (face->reference_table (tableTag)); + set_num_glyphs (hb_face_get_glyph_count (face)); + return sanitize_blob (hb_face_reference_table (face, tableTag)); } mutable unsigned int debug_depth; @@ -588,109 +587,206 @@ /* - * Lazy struct and blob loaders. + * Lazy loaders. */ -/* Logic is shared between hb_lazy_loader_t and hb_table_lazy_loader_t */ -template -struct hb_lazy_loader_t +template +struct hb_data_wrapper_t +{ + static_assert (WheresData > 0, ""); + + inline Data * get_data (void) const + { + return *(((Data **) (void *) this) - WheresData); + } + + template + inline Stored * call_create (void) const + { + Data *data = this->get_data (); + return likely (data) ? Subclass::create (data) : nullptr; + } +}; +template <> +struct hb_data_wrapper_t { - inline void init (hb_face_t *face_) + template + inline Stored * call_create (void) const { - face = face_; - instance = nullptr; + return Funcs::create (); } +}; +template struct hb_non_void_t { typedef T1 value; }; +template struct hb_non_void_t { typedef T2 value; }; + +template +struct hb_lazy_loader_t : hb_data_wrapper_t +{ + typedef typename hb_non_void_t + >::value Funcs; + + inline void init0 (void) {} /* Init, when memory is already set to 0. No-op for us. */ + inline void init (void) { instance.set_relaxed (nullptr); } inline void fini (void) { - if (instance && instance != &Null(T)) - { - instance->fini(); - free (instance); - } + do_destroy (instance.get ()); + } + inline void free_instance (void) + { + retry: + Stored *p = instance.get (); + if (unlikely (p && !this->instance.cmpexch (p, nullptr))) + goto retry; + do_destroy (p); } - inline const T* get (void) const + inline Stored * do_create (void) const + { + Stored *p = this->template call_create (); + if (unlikely (!p)) + p = const_cast (Funcs::get_null ()); + return p; + } + static inline void do_destroy (Stored *p) + { + if (p && p != Funcs::get_null ()) + Funcs::destroy (p); + } + + inline const Returned * operator -> (void) const { return get (); } + inline const Returned & operator * (void) const { return *get (); } + + inline Data * get_data (void) const + { + return *(((Data **) this) - WheresData); + } + + inline Stored * get_stored (void) const { retry: - T *p = (T *) hb_atomic_ptr_get (&instance); + Stored *p = this->instance.get (); if (unlikely (!p)) { - p = (T *) calloc (1, sizeof (T)); - if (unlikely (!p)) - p = const_cast (&Null(T)); - else - p->init (face); - if (unlikely (!hb_atomic_ptr_cmpexch (const_cast(&instance), nullptr, p))) + p = do_create (); + if (unlikely (!this->instance.cmpexch (nullptr, p))) { - if (p != &Null(T)) - p->fini (); + do_destroy (p); goto retry; } } return p; } - inline const T* operator-> (void) const + inline void set_stored (Stored *instance_) + { + /* This *must* be called when there are no other threads accessing. + * However, to make TSan, etc, happy, we using cmpexch. */ + retry: + Stored *p = this->instance.get (); + if (unlikely (!this->instance.cmpexch (p, instance_))) + goto retry; + do_destroy (p); + } + + inline const Returned * get (void) const { return Funcs::convert (get_stored ()); } + inline Returned * get_unconst (void) const { return const_cast (Funcs::convert (get_stored ())); } + + /* To be possibly overloaded by subclasses. */ + static inline Returned* convert (Stored *p) { return p; } + + /* By default null/init/fini the object. */ + static inline const Stored* get_null (void) { return &Null(Stored); } + static inline Stored *create (Data *data) { - return get (); + Stored *p = (Stored *) calloc (1, sizeof (Stored)); + if (likely (p)) + p->init (data); + return p; + } + static inline Stored *create (void) + { + Stored *p = (Stored *) calloc (1, sizeof (Stored)); + if (likely (p)) + p->init (); + return p; + } + static inline void destroy (Stored *p) + { + p->fini (); + free (p); } private: - hb_face_t *face; - mutable T *instance; + /* Must only have one pointer. */ + hb_atomic_ptr_t instance; }; -/* Logic is shared between hb_lazy_loader_t and hb_table_lazy_loader_t */ -template -struct hb_table_lazy_loader_t +/* Specializations. */ + +template +struct hb_face_lazy_loader_t : hb_lazy_loader_t, + hb_face_t, WheresFace> {}; + +template +struct hb_table_lazy_loader_t : hb_lazy_loader_t, + hb_face_t, WheresFace, + hb_blob_t> { - inline void init (hb_face_t *face_) + static inline hb_blob_t *create (hb_face_t *face) { - face = face_; - blob = nullptr; + return hb_sanitize_context_t ().reference_table (face); } - - inline void fini (void) + static inline void destroy (hb_blob_t *p) { - hb_blob_destroy (blob); + hb_blob_destroy (p); + } + static inline const hb_blob_t *get_null (void) + { + return hb_blob_get_empty (); + } + static inline const T* convert (const hb_blob_t *blob) + { + return blob->as (); } inline hb_blob_t* get_blob (void) const { - retry: - hb_blob_t *b = (hb_blob_t *) hb_atomic_ptr_get (&blob); - if (unlikely (!b)) - { - b = OT::hb_sanitize_context_t().reference_table (face); - if (!hb_atomic_ptr_cmpexch (&blob, nullptr, b)) - { - hb_blob_destroy (b); - goto retry; - } - blob = b; - } - return b; + return this->get_stored (); } +}; - inline const T* get (void) const +template +struct hb_font_funcs_lazy_loader_t : hb_lazy_loader_t +{ + static inline void destroy (hb_font_funcs_t *p) { - hb_blob_t *b = get_blob (); - return b->as (); + hb_font_funcs_destroy (p); } - - inline const T* operator-> (void) const + static inline const hb_font_funcs_t *get_null (void) { - return get(); + return hb_font_funcs_get_empty (); + } +}; +template +struct hb_unicode_funcs_lazy_loader_t : hb_lazy_loader_t +{ + static inline void destroy (hb_unicode_funcs_t *p) + { + hb_unicode_funcs_destroy (p); + } + static inline const hb_unicode_funcs_t *get_null (void) + { + return hb_unicode_funcs_get_empty (); } - - private: - hb_face_t *face; - mutable hb_blob_t *blob; }; - - -} /* namespace OT */ #endif /* HB_MACHINERY_PRIVATE_HH */ diff -Nru harfbuzz-1.8.5/src/hb-null.hh harfbuzz-1.8.8/src/hb-null.hh --- harfbuzz-1.8.5/src/hb-null.hh 1970-01-01 00:00:00.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-null.hh 2018-08-14 16:48:02.000000000 +0000 @@ -0,0 +1,106 @@ +/* + * Copyright © 2018 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_NULL_HH +#define HB_NULL_HH + +#include "hb-private.hh" + + +/* + * Static pools + */ + +/* Global nul-content Null pool. Enlarge as necessary. */ + +#define HB_NULL_POOL_SIZE 264 + +extern HB_INTERNAL +hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)]; + +/* Generic nul-content Null objects. */ +template +static inline Type const & Null (void) { + static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); + return *reinterpret_cast (_hb_NullPool); +} +#define Null(Type) Null() + +/* Specializaitons for arbitrary-content Null objects expressed in bytes. */ +#define DECLARE_NULL_NAMESPACE_BYTES(Namespace, Type) \ +} /* Close namespace. */ \ +extern HB_INTERNAL const unsigned char _hb_Null_##Namespace##_##Type[Namespace::Type::min_size]; \ +template <> \ +/*static*/ inline const Namespace::Type& Null (void) { \ + return *reinterpret_cast (_hb_Null_##Namespace##_##Type); \ +} \ +namespace Namespace { \ +static_assert (true, "Just so we take semicolon after.") +#define DEFINE_NULL_NAMESPACE_BYTES(Namespace, Type) \ +const unsigned char _hb_Null_##Namespace##_##Type[Namespace::Type::min_size] + +/* Specializaitons for arbitrary-content Null objects expressed as struct initializer. */ +#define DECLARE_NULL_INSTANCE(Type) \ +extern HB_INTERNAL const Type _hb_Null_##Type; \ +template <> \ +/*static*/ inline const Type& Null (void) { \ + return _hb_Null_##Type; \ +} \ +static_assert (true, "Just so we take semicolon after.") +#define DEFINE_NULL_INSTANCE(Type) \ +const Type _hb_Null_##Type + +/* Global writable pool. Enlarge as necessary. */ + +/* To be fully correct, CrapPool must be thread_local. However, we do not rely on CrapPool + * for correct operation. It only exist to catch and divert program logic bugs instead of + * causing bad memory access. So, races there are not actually introducing incorrectness + * in the code. Has ~12kb binary size overhead to have it, also clang build fails with it. */ +extern HB_INTERNAL +/*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)]; + +/* CRAP pool: Common Region for Access Protection. */ +template +static inline Type& Crap (void) { + static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); + Type *obj = reinterpret_cast (_hb_CrapPool); + *obj = Null(Type); + return *obj; +} +#define Crap(Type) Crap() + +template +struct CrapOrNull { + static inline Type & get (void) { return Crap(Type); } +}; +template +struct CrapOrNull { + static inline Type const & get (void) { return Null(Type); } +}; +#define CrapOrNull(Type) CrapOrNull::get () + + +#endif /* HB_NULL_HH */ diff -Nru harfbuzz-1.8.5/src/hb-object-private.hh harfbuzz-1.8.8/src/hb-object-private.hh --- harfbuzz-1.8.5/src/hb-object-private.hh 2018-08-01 04:07:12.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-object-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -35,9 +35,107 @@ #include "hb-private.hh" #include "hb-atomic-private.hh" #include "hb-mutex-private.hh" +#include "hb-vector-private.hh" -/* reference_count */ +/* + * Lockable set + */ + +template +struct hb_lockable_set_t +{ + hb_vector_t items; + + inline void init (void) { items.init (); } + + template + inline item_t *replace_or_insert (T v, lock_t &l, bool replace) + { + l.lock (); + item_t *item = items.find (v); + if (item) { + if (replace) { + item_t old = *item; + *item = v; + l.unlock (); + old.fini (); + } + else { + item = nullptr; + l.unlock (); + } + } else { + item = items.push (v); + l.unlock (); + } + return item; + } + + template + inline void remove (T v, lock_t &l) + { + l.lock (); + item_t *item = items.find (v); + if (item) { + item_t old = *item; + *item = items[items.len - 1]; + items.pop (); + l.unlock (); + old.fini (); + } else { + l.unlock (); + } + } + + template + inline bool find (T v, item_t *i, lock_t &l) + { + l.lock (); + item_t *item = items.find (v); + if (item) + *i = *item; + l.unlock (); + return !!item; + } + + template + inline item_t *find_or_insert (T v, lock_t &l) + { + l.lock (); + item_t *item = items.find (v); + if (!item) { + item = items.push (v); + } + l.unlock (); + return item; + } + + inline void fini (lock_t &l) + { + if (!items.len) { + /* No need for locking. */ + items.fini (); + return; + } + l.lock (); + while (items.len) { + item_t old = items[items.len - 1]; + items.pop (); + l.unlock (); + old.fini (); + l.lock (); + } + items.fini (); + l.unlock (); + } + +}; + + +/* + * Reference-count. + */ #define HB_REFERENCE_COUNT_INERT_VALUE 0 #define HB_REFERENCE_COUNT_POISON_VALUE -0x0000DEAD @@ -45,12 +143,12 @@ struct hb_reference_count_t { - hb_atomic_int_t ref_count; + mutable hb_atomic_int_t ref_count; - inline void init (int v) { ref_count.set_relaxed (v); } + inline void init (int v = 1) { ref_count.set_relaxed (v); } inline int get_relaxed (void) const { return ref_count.get_relaxed (); } - inline int inc (void) { return ref_count.inc (); } - inline int dec (void) { return ref_count.dec (); } + inline int inc (void) const { return ref_count.inc (); } + inline int dec (void) const { return ref_count.dec (); } inline void fini (void) { ref_count.set_relaxed (HB_REFERENCE_COUNT_POISON_VALUE); } inline bool is_inert (void) const { return ref_count.get_relaxed () == HB_REFERENCE_COUNT_INERT_VALUE; } @@ -89,21 +187,25 @@ }; -/* object_header */ +/* + * Object header + */ struct hb_object_header_t { hb_reference_count_t ref_count; - mutable hb_user_data_array_t *user_data; + hb_atomic_ptr_t user_data; -#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INIT, nullptr} +#define HB_OBJECT_HEADER_STATIC {HB_REFERENCE_COUNT_INIT, HB_ATOMIC_PTR_INIT (nullptr)} private: ASSERT_POD (); }; -/* object */ +/* + * Object + */ template static inline void hb_object_trace (const Type *obj, const char *function) @@ -129,8 +231,8 @@ template static inline void hb_object_init (Type *obj) { - obj->header.ref_count.init (1); - obj->header.user_data = nullptr; + obj->header.ref_count.init (); + obj->header.user_data.init (); } template static inline bool hb_object_is_inert (const Type *obj) @@ -169,10 +271,11 @@ static inline void hb_object_fini (Type *obj) { obj->header.ref_count.fini (); /* Do this before user_data */ - if (obj->header.user_data) + hb_user_data_array_t *user_data = obj->header.user_data.get (); + if (user_data) { - obj->header.user_data->fini (); - free (obj->header.user_data); + user_data->fini (); + free (user_data); } } template @@ -187,14 +290,14 @@ assert (hb_object_is_valid (obj)); retry: - hb_user_data_array_t *user_data = (hb_user_data_array_t *) hb_atomic_ptr_get (&obj->header.user_data); + hb_user_data_array_t *user_data = obj->header.user_data.get (); if (unlikely (!user_data)) { user_data = (hb_user_data_array_t *) calloc (sizeof (hb_user_data_array_t), 1); if (unlikely (!user_data)) return false; user_data->init (); - if (unlikely (!hb_atomic_ptr_cmpexch (&obj->header.user_data, nullptr, user_data))) + if (unlikely (!obj->header.user_data.cmpexch (nullptr, user_data))) { user_data->fini (); free (user_data); @@ -209,10 +312,13 @@ static inline void *hb_object_get_user_data (Type *obj, hb_user_data_key_t *key) { - if (unlikely (!obj || hb_object_is_inert (obj) || !obj->header.user_data)) + if (unlikely (!obj || hb_object_is_inert (obj))) return nullptr; assert (hb_object_is_valid (obj)); - return obj->header.user_data->get (key); + hb_user_data_array_t *user_data = obj->header.user_data.get (); + if (!user_data) + return nullptr; + return user_data->get (key); } diff -Nru harfbuzz-1.8.5/src/hb-open-type-private.hh harfbuzz-1.8.8/src/hb-open-type-private.hh --- harfbuzz-1.8.5/src/hb-open-type-private.hh 2018-07-25 23:58:00.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-open-type-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -140,7 +140,6 @@ public: DEFINE_SIZE_STATIC (4); }; -DEFINE_NULL_DATA (OT, Tag, " "); /* Glyph index number, same as uint16 (length = 16 bits) */ typedef HBUINT16 GlyphID; @@ -152,7 +151,7 @@ struct Index : HBUINT16 { static const unsigned int NOT_FOUND_INDEX = 0xFFFFu; }; -DEFINE_NULL_DATA (OT, Index, "\xff\xff"); +DECLARE_NULL_NAMESPACE_BYTES (OT, Index); /* Offset, Null offset = 0 */ template diff -Nru harfbuzz-1.8.5/src/hb-ot-font.cc harfbuzz-1.8.8/src/hb-ot-font.cc --- harfbuzz-1.8.5/src/hb-ot-font.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-font.cc 2018-08-14 16:48:02.000000000 +0000 @@ -29,6 +29,7 @@ #include "hb-ot.h" #include "hb-font-private.hh" +#include "hb-machinery-private.hh" #include "hb-ot-cmap-table.hh" #include "hb-ot-glyf-table.hh" @@ -41,13 +42,39 @@ struct hb_ot_font_t { + inline void init (hb_face_t *face) + { + cmap.init (face); + h_metrics.init (face); + v_metrics.init (face, h_metrics.ascender - h_metrics.descender); /* TODO Can we do this lazily? */ + + this->face = face; + glyf.init (); + cbdt.init (); + post.init (); + kern.init (); + } + inline void fini (void) + { + cmap.fini (); + h_metrics.fini (); + v_metrics.fini (); + + glyf.fini (); + cbdt.fini (); + post.fini (); + kern.fini (); + } + OT::cmap::accelerator_t cmap; OT::hmtx::accelerator_t h_metrics; OT::vmtx::accelerator_t v_metrics; - OT::hb_lazy_loader_t glyf; - OT::hb_lazy_loader_t cbdt; - OT::hb_lazy_loader_t post; - OT::hb_lazy_loader_t kern; + + hb_face_t *face; /* MUST be JUST before the lazy loaders. */ + hb_face_lazy_loader_t<1, OT::glyf::accelerator_t> glyf; + hb_face_lazy_loader_t<2, OT::CBDT::accelerator_t> cbdt; + hb_face_lazy_loader_t<3, OT::post::accelerator_t> post; + hb_face_lazy_loader_t<4, OT::kern::accelerator_t> kern; }; @@ -59,13 +86,7 @@ if (unlikely (!ot_font)) return nullptr; - ot_font->cmap.init (face); - ot_font->h_metrics.init (face); - ot_font->v_metrics.init (face, ot_font->h_metrics.ascender - ot_font->h_metrics.descender); /* TODO Can we do this lazily? */ - ot_font->glyf.init (face); - ot_font->cbdt.init (face); - ot_font->post.init (face); - ot_font->kern.init (face); + ot_font->init (face); return ot_font; } @@ -75,13 +96,7 @@ { hb_ot_font_t *ot_font = (hb_ot_font_t *) data; - ot_font->cmap.fini (); - ot_font->h_metrics.fini (); - ot_font->v_metrics.fini (); - ot_font->glyf.fini (); - ot_font->cbdt.fini (); - ot_font->post.fini (); - ot_font->kern.fini (); + ot_font->fini (); free (ot_font); } @@ -211,30 +226,14 @@ return ot_font->v_metrics.has_font_extents; } -static hb_font_funcs_t *static_ot_funcs = nullptr; - -#ifdef HB_USE_ATEXIT -static -void free_static_ot_funcs (void) -{ -retry: - hb_font_funcs_t *ot_funcs = (hb_font_funcs_t *) hb_atomic_ptr_get (&static_ot_funcs); - if (!hb_atomic_ptr_cmpexch (&static_ot_funcs, ot_funcs, nullptr)) - goto retry; - hb_font_funcs_destroy (ot_funcs); -} -#endif +static void free_static_ot_funcs (void); -static hb_font_funcs_t * -_hb_ot_get_font_funcs (void) +static struct hb_ot_font_funcs_lazy_loader_t : hb_font_funcs_lazy_loader_t { -retry: - hb_font_funcs_t *funcs = (hb_font_funcs_t *) hb_atomic_ptr_get (&static_ot_funcs); - - if (unlikely (!funcs)) + static inline hb_font_funcs_t *create (void) { - funcs = hb_font_funcs_create (); + hb_font_funcs_t *funcs = hb_font_funcs_create (); hb_font_funcs_set_font_h_extents_func (funcs, hb_ot_get_font_h_extents, nullptr, nullptr); hb_font_funcs_set_font_v_extents_func (funcs, hb_ot_get_font_v_extents, nullptr, nullptr); @@ -253,17 +252,26 @@ hb_font_funcs_make_immutable (funcs); - if (!hb_atomic_ptr_cmpexch (&static_ot_funcs, nullptr, funcs)) { - hb_font_funcs_destroy (funcs); - goto retry; - } +#ifdef HB_USE_ATEXIT + atexit (free_static_ot_funcs); +#endif + + return funcs; + } +} static_ot_funcs; #ifdef HB_USE_ATEXIT - atexit (free_static_ot_funcs); /* First person registers atexit() callback. */ +static +void free_static_ot_funcs (void) +{ + static_ot_funcs.free_instance (); +} #endif - }; - return funcs; +static hb_font_funcs_t * +_hb_ot_get_font_funcs (void) +{ + return static_ot_funcs.get_unconst (); } diff -Nru harfbuzz-1.8.5/src/hb-ot-glyf-table.hh harfbuzz-1.8.8/src/hb-ot-glyf-table.hh --- harfbuzz-1.8.5/src/hb-ot-glyf-table.hh 2018-07-23 21:38:01.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-glyf-table.hh 2018-08-14 16:48:02.000000000 +0000 @@ -238,9 +238,9 @@ hb_blob_t *head_blob = hb_sanitize_context_t().reference_table (face); const head *head_table = head_blob->as (); - if (head_table == &Null(head) || (unsigned int) head_table->indexToLocFormat > 1 || head_table->glyphDataFormat != 0) + if (head_table->indexToLocFormat > 1 || head_table->glyphDataFormat != 0) { - /* head table is not present, or in an unknown format. Leave num_glyphs=0, that takes care of disabling us. */ + /* Unknown format. Leave num_glyphs=0, that takes care of disabling us. */ hb_blob_destroy (head_blob); return; } @@ -270,7 +270,7 @@ inline bool get_composite (hb_codepoint_t glyph, CompositeGlyphHeader::Iterator *composite /* OUT */) const { - if (this->glyf_table == &Null(glyf) || !num_glyphs) + if (unlikely (!num_glyphs)) return false; unsigned int start_offset, end_offset; diff -Nru harfbuzz-1.8.5/src/hb-ot-head-table.hh harfbuzz-1.8.8/src/hb-ot-head-table.hh --- harfbuzz-1.8.5/src/hb-ot-head-table.hh 2018-06-02 22:39:30.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-head-table.hh 2018-08-14 16:48:02.000000000 +0000 @@ -141,8 +141,8 @@ * -1: Only strongly right to left; * -2: Like -1 but also contains neutrals. */ public: - HBINT16 indexToLocFormat; /* 0 for short offsets, 1 for long. */ - HBINT16 glyphDataFormat; /* 0 for current format. */ + HBUINT16 indexToLocFormat; /* 0 for short offsets, 1 for long. */ + HBUINT16 glyphDataFormat; /* 0 for current format. */ DEFINE_SIZE_STATIC (54); }; diff -Nru harfbuzz-1.8.5/src/hb-ot-layout-base-table.hh harfbuzz-1.8.8/src/hb-ot-layout-base-table.hh --- harfbuzz-1.8.5/src/hb-ot-layout-base-table.hh 2018-06-02 22:39:30.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-layout-base-table.hh 2018-08-14 16:48:02.000000000 +0000 @@ -33,13 +33,16 @@ namespace OT { -#define NOT_INDEXED ((unsigned int) -1) - /* * BASE -- Baseline * https://docs.microsoft.com/en-us/typography/opentype/spec/base */ + +/* XXX Review this. */ +#define NOT_INDEXED ((unsigned int) -1) + + struct BaseCoordFormat1 { inline int get_coord (void) const { return coordinate; } @@ -52,7 +55,7 @@ protected: HBUINT16 format; /* Format identifier--format = 1 */ - HBINT16 coordinate; /* X or Y value, in design units */ + FWORD coordinate; /* X or Y value, in design units */ public: DEFINE_SIZE_STATIC (4); }; @@ -73,7 +76,7 @@ protected: HBUINT16 format; /* Format identifier--format = 2 */ - HBINT16 coordinate; /* X or Y value, in design units */ + FWORD coordinate; /* X or Y value, in design units */ GlyphID referenceGlyph; /* Glyph ID of control glyph */ HBUINT16 coordPoint; /* Index of contour point on the * reference glyph */ @@ -97,7 +100,7 @@ protected: HBUINT16 format; /* Format identifier--format = 3 */ - HBINT16 coordinate; /* X or Y value, in design units */ + FWORD coordinate; /* X or Y value, in design units */ OffsetTo deviceTable; /* Offset to Device table for X or * Y value, from beginning of * BaseCoord table (may be NULL). */ @@ -109,6 +112,7 @@ { inline int get_coord (void) const { + /* XXX wire up direction and font. */ switch (u.format) { case 1: return u.format1.get_coord (); case 2: return u.format2.get_coord (); @@ -142,14 +146,10 @@ struct FeatMinMaxRecord { - inline int get_min_value (void) const - { return (this+minCoord).get_coord(); } - - inline int get_max_value (void) const - { return (this+maxCoord).get_coord(); } + inline int get_min_value (void) const { return (this+minCoord).get_coord(); } + inline int get_max_value (void) const { return (this+maxCoord).get_coord(); } - inline const Tag &get_tag () const - { return tag; } + inline const Tag& get_tag () const { return tag; } inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { @@ -181,7 +181,7 @@ unsigned int count = featMinMaxRecords.len; for (unsigned int i = 0; i < count; i++) { - Tag tag = featMinMaxRecords[i].get_tag(); + Tag tag = featMinMaxRecords[i].get_tag (); int cmp = tag.cmp(featureTableTag); if (cmp == 0) return i; if (cmp > 0) return NOT_INDEXED; @@ -233,13 +233,13 @@ { return baseLangSysTag; } inline unsigned int get_feature_tag_index (Tag featureTableTag) const - { return (this+minMax).get_feature_tag_index(featureTableTag); } + { return (this+minMax).get_feature_tag_index( featureTableTag); } inline int get_min_value (unsigned int featureTableTagIndex) const - { return (this+minMax).get_min_value(featureTableTagIndex); } + { return (this+minMax).get_min_value( featureTableTagIndex); } inline int get_max_value (unsigned int featureTableTagIndex) const - { return (this+minMax).get_max_value(featureTableTagIndex); } + { return (this+minMax).get_max_value (featureTableTagIndex); } inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { @@ -263,34 +263,34 @@ inline int get_base_coord (unsigned int baselineTagIndex) const { - return (this+baseCoords[baselineTagIndex]).get_coord(); + return (this+baseCoords[baselineTagIndex]).get_coord (); } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - defaultIndex <= baseCoordCount && - baseCoords.sanitize (c, this)); + baseCoords.sanitize (c, this)); } protected: Index defaultIndex; - HBUINT16 baseCoordCount; OffsetArrayOf baseCoords; public: - DEFINE_SIZE_ARRAY (6, baseCoords); - + DEFINE_SIZE_ARRAY (4, baseCoords); }; struct BaseScript { inline unsigned int get_lang_tag_index (Tag baseLangSysTag) const { + /* XXX bsearch */ Tag tag; int cmp; - for (unsigned int i = 0; i < baseLangSysCount; i++) { - tag = baseLangSysRecords[i].get_tag(); + unsigned int count = baseLangSysRecords.len; + for (unsigned int i = 0; i < count; i++) + { + tag = baseLangSysRecords[i].get_tag (); // taking advantage of alphabetical order cmp = tag.cmp(baseLangSysTag); if (cmp == 0) return i; @@ -301,51 +301,50 @@ inline unsigned int get_feature_tag_index (unsigned int baseLangSysIndex, Tag featureTableTag) const { - if (baseLangSysIndex == NOT_INDEXED) { + if (baseLangSysIndex == NOT_INDEXED) + { if (unlikely(defaultMinMax)) return NOT_INDEXED; - return (this+defaultMinMax).get_feature_tag_index(featureTableTag); + return (this+defaultMinMax).get_feature_tag_index (featureTableTag); } - if (unlikely(baseLangSysIndex >= baseLangSysCount)) return NOT_INDEXED; - return baseLangSysRecords[baseLangSysIndex].get_feature_tag_index(featureTableTag); + return baseLangSysRecords[baseLangSysIndex].get_feature_tag_index (featureTableTag); } inline int get_min_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { if (baseLangSysIndex == NOT_INDEXED) - return (this+defaultMinMax).get_min_value(featureTableTagIndex); - return baseLangSysRecords[baseLangSysIndex].get_max_value(featureTableTagIndex); + return (this+defaultMinMax).get_min_value (featureTableTagIndex); + return baseLangSysRecords[baseLangSysIndex].get_max_value (featureTableTagIndex); } inline int get_max_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { if (baseLangSysIndex == NOT_INDEXED) - return (this+defaultMinMax).get_min_value(featureTableTagIndex); - return baseLangSysRecords[baseLangSysIndex].get_max_value(featureTableTagIndex); + return (this+defaultMinMax).get_min_value (featureTableTagIndex); + return baseLangSysRecords[baseLangSysIndex].get_max_value (featureTableTagIndex); } inline unsigned int get_default_base_tag_index (void) const - { return (this+baseValues).get_default_base_tag_index(); } + { return (this+baseValues).get_default_base_tag_index (); } inline int get_base_coord (unsigned int baselineTagIndex) const - { return (this+baseValues).get_base_coord(baselineTagIndex); } + { return (this+baseValues).get_base_coord (baselineTagIndex); } inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - baseValues.sanitize (c, this) && - defaultMinMax.sanitize (c, this) && - baseLangSysRecords.sanitize (c, this)); + baseValues.sanitize (c, this) && + defaultMinMax.sanitize (c, this) && + baseLangSysRecords.sanitize (c, this)); } protected: - OffsetTo baseValues; - OffsetTo defaultMinMax; - HBUINT16 baseLangSysCount; - ArrayOf baseLangSysRecords; + OffsetTo baseValues; + OffsetTo defaultMinMax; + ArrayOf baseLangSysRecords; public: - DEFINE_SIZE_ARRAY (8, baseLangSysRecords); + DEFINE_SIZE_ARRAY (6, baseLangSysRecords); }; @@ -355,29 +354,28 @@ { return baseScriptTag; } inline unsigned int get_default_base_tag_index(void) const - { return (this+baseScript).get_default_base_tag_index(); } + { return (this+baseScript).get_default_base_tag_index (); } inline int get_base_coord(unsigned int baselineTagIndex) const - { return (this+baseScript).get_base_coord(baselineTagIndex); } + { return (this+baseScript).get_base_coord (baselineTagIndex); } inline unsigned int get_lang_tag_index (Tag baseLangSysTag) const - { return (this+baseScript).get_lang_tag_index(baseLangSysTag); } + { return (this+baseScript).get_lang_tag_index (baseLangSysTag); } inline unsigned int get_feature_tag_index (unsigned int baseLangSysIndex, Tag featureTableTag) const - { return (this+baseScript).get_feature_tag_index(baseLangSysIndex, featureTableTag); } + { return (this+baseScript).get_feature_tag_index (baseLangSysIndex, featureTableTag); } inline int get_max_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { return (this+baseScript).get_max_value(baseLangSysIndex, featureTableTagIndex); } + { return (this+baseScript).get_max_value (baseLangSysIndex, featureTableTagIndex); } inline int get_min_value (unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const - { return (this+baseScript).get_min_value(baseLangSysIndex, featureTableTagIndex); } + { return (this+baseScript).get_min_value (baseLangSysIndex, featureTableTagIndex); } inline bool sanitize (hb_sanitize_context_t *c, const void *base) const { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - baseScript != Null(OffsetTo) && - baseScript.sanitize (c, base)); + baseScript.sanitize (c, base)); } protected: @@ -392,7 +390,9 @@ inline unsigned int get_base_script_index (Tag baseScriptTag) const { - for (unsigned int i = 0; i < baseScriptCount; i++) + /* XXX bsearch? */ + unsigned int count = baseScriptRecords.len; + for (unsigned int i = 0; i < count; i++) if (baseScriptRecords[i].get_tag() == baseScriptTag) return i; return NOT_INDEXED; @@ -400,7 +400,6 @@ inline unsigned int get_default_base_tag_index (unsigned int baseScriptIndex) const { - if (unlikely(baseScriptIndex >= baseScriptCount)) return NOT_INDEXED; return baseScriptRecords[baseScriptIndex].get_default_base_tag_index(); } @@ -411,13 +410,11 @@ inline unsigned int get_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const { - if (unlikely(baseScriptIndex >= baseScriptCount)) return NOT_INDEXED; return baseScriptRecords[baseScriptIndex].get_lang_tag_index(baseLangSysTag); } inline unsigned int get_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const { - if (unlikely(baseScriptIndex >= baseScriptCount)) return NOT_INDEXED; return baseScriptRecords[baseScriptIndex].get_feature_tag_index(baseLangSysIndex, featureTableTag); } @@ -435,24 +432,23 @@ { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - baseScriptRecords.sanitize (c, this)); + baseScriptRecords.sanitize (c, this)); } protected: - HBUINT16 baseScriptCount; - ArrayOf baseScriptRecords; + ArrayOf baseScriptRecords; public: - DEFINE_SIZE_ARRAY (4, baseScriptRecords); - + DEFINE_SIZE_ARRAY (2, baseScriptRecords); }; struct BaseTagList { - - inline unsigned int get_tag_index(Tag baselineTag) const + inline unsigned int get_tag_index (Tag baselineTag) const { - for (unsigned int i = 0; i < baseTagCount; i++) + /* TODO bsearch? */ + unsigned int count = baselineTags.len; + for (unsigned int i = 0; i < count; i++) if (baselineTags[i] == baselineTag) return i; return NOT_INDEXED; @@ -465,42 +461,37 @@ } protected: - HBUINT16 baseTagCount; SortedArrayOf baselineTags; public: - DEFINE_SIZE_ARRAY (4, baselineTags); + DEFINE_SIZE_ARRAY (2, baselineTags); }; struct Axis { - inline unsigned int get_base_tag_index(Tag baselineTag) const + inline unsigned int get_base_tag_index (Tag baselineTag) const { - if (unlikely(baseTagList == Null(OffsetTo))) return NOT_INDEXED; return (this+baseTagList).get_tag_index(baselineTag); } inline unsigned int get_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const { - if (unlikely(baseScriptList == Null(OffsetTo))) return NOT_INDEXED; return (this+baseScriptList).get_default_base_tag_index(baseScriptIndex); } - inline int get_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const + inline int get_base_coord (unsigned int baseScriptIndex, unsigned int baselineTagIndex) const { return (this+baseScriptList).get_base_coord(baseScriptIndex, baselineTagIndex); } inline unsigned int get_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const { - if (unlikely(baseScriptList == Null(OffsetTo))) return NOT_INDEXED; return (this+baseScriptList).get_lang_tag_index(baseScriptIndex, baseLangSysTag); } inline unsigned int get_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const { - if (unlikely(baseScriptList == Null(OffsetTo))) return NOT_INDEXED; return (this+baseScriptList).get_feature_tag_index(baseScriptIndex, baseLangSysIndex, featureTableTag); } @@ -518,13 +509,13 @@ { TRACE_SANITIZE (this); return_trace (c->check_struct (this) && - baseTagList.sanitize (c, this) && - baseScriptList.sanitize (c, this)); + baseTagList.sanitize (c, this) && + baseScriptList.sanitize (c, this)); } protected: - OffsetTo baseTagList; - OffsetTo baseScriptList; + OffsetTo baseTagList; + OffsetTo baseScriptList; public: DEFINE_SIZE_STATIC (4); @@ -534,96 +525,78 @@ { static const hb_tag_t tableTag = HB_OT_TAG_BASE; - inline bool has_vert_axis(void) - { return vertAxis != Null(OffsetTo); } + inline bool has_v_axis(void) { return vAxis != 0; } - inline bool has_horiz_axis(void) - { return horizAxis != Null(OffsetTo); } + inline bool has_h_axis(void) { return hAxis != 0; } - // horizontal axis base coords: - - inline unsigned int get_horiz_base_tag_index(Tag baselineTag) const + inline unsigned int get_h_base_tag_index (Tag baselineTag) const { - if (unlikely(horizAxis == Null(OffsetTo))) return NOT_INDEXED; - return (this+horizAxis).get_base_tag_index(baselineTag); + return (this+hAxis).get_base_tag_index(baselineTag); } - inline unsigned int get_horiz_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const + inline unsigned int get_h_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const { - if (unlikely(horizAxis == Null(OffsetTo))) return NOT_INDEXED; - return (this+horizAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); + return (this+hAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); } - inline int get_horiz_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const + inline int get_h_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const { - return (this+horizAxis).get_base_coord(baseScriptIndex, baselineTagIndex); + return (this+hAxis).get_base_coord(baseScriptIndex, baselineTagIndex); } - // vertical axis base coords: - - inline unsigned int get_vert_base_tag_index(Tag baselineTag) const + inline unsigned int get_v_base_tag_index(Tag baselineTag) const { - if (unlikely(vertAxis == Null(OffsetTo))) return NOT_INDEXED; - return (this+vertAxis).get_base_tag_index(baselineTag); + return (this+vAxis).get_base_tag_index(baselineTag); } - inline unsigned int get_vert_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const + inline unsigned int get_v_default_base_tag_index_for_script_index (unsigned int baseScriptIndex) const { - if (unlikely(vertAxis == Null(OffsetTo))) return NOT_INDEXED; - return (this+vertAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); + return (this+vAxis).get_default_base_tag_index_for_script_index(baseScriptIndex); } - inline int get_vert_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const + inline int get_v_base_coord(unsigned int baseScriptIndex, unsigned int baselineTagIndex) const { - return (this+vertAxis).get_base_coord(baseScriptIndex, baselineTagIndex); + return (this+vAxis).get_base_coord(baseScriptIndex, baselineTagIndex); } - // horizontal axis min/max coords: - - inline unsigned int get_horiz_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const + inline unsigned int get_h_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const { - if (unlikely(horizAxis == Null(OffsetTo))) return NOT_INDEXED; - return (this+horizAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); + return (this+hAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); } - inline unsigned int get_horiz_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const + inline unsigned int get_h_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const { - if (unlikely(horizAxis == Null(OffsetTo))) return NOT_INDEXED; - return (this+horizAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); + return (this+hAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); } - inline int get_horiz_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const + inline int get_h_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { - return (this+horizAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); + return (this+hAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); } - inline int get_horiz_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const + inline int get_h_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { - return (this+horizAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); + return (this+hAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); } - // vertical axis min/max coords: - - inline unsigned int get_vert_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const + inline unsigned int get_v_lang_tag_index (unsigned int baseScriptIndex, Tag baseLangSysTag) const { - if (unlikely(vertAxis == Null(OffsetTo))) return NOT_INDEXED; - return (this+vertAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); + return (this+vAxis).get_lang_tag_index (baseScriptIndex, baseLangSysTag); } - inline unsigned int get_vert_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const + inline unsigned int get_v_feature_tag_index (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, Tag featureTableTag) const { - if (unlikely(vertAxis == Null(OffsetTo))) return NOT_INDEXED; - return (this+vertAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); + return (this+vAxis).get_feature_tag_index (baseScriptIndex, baseLangSysIndex, featureTableTag); } - inline int get_vert_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const + inline int get_v_max_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { - return (this+vertAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); + return (this+vAxis).get_max_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); } - inline int get_vert_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const + inline int get_v_min_value (unsigned int baseScriptIndex, unsigned int baseLangSysIndex, unsigned int featureTableTagIndex) const { - return (this+vertAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); + return (this+vAxis).get_min_value (baseScriptIndex, baseLangSysIndex, featureTableTagIndex); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -631,15 +604,15 @@ TRACE_SANITIZE (this); return_trace (c->check_struct (this) && likely (version.major == 1) && - horizAxis.sanitize (c, this) && - vertAxis.sanitize (c, this) && + hAxis.sanitize (c, this) && + vAxis.sanitize (c, this) && (version.to_int () < 0x00010001u || varStore.sanitize (c, this))); } protected: FixedVersion<> version; - OffsetTo horizAxis; - OffsetTo vertAxis; + OffsetTo hAxis; + OffsetTo vAxis; LOffsetTo varStore; /* Offset to the table of Item Variation * Store--from beginning of BASE diff -Nru harfbuzz-1.8.5/src/hb-ot-layout.cc harfbuzz-1.8.8/src/hb-ot-layout.cc --- harfbuzz-1.8.5/src/hb-ot-layout.cc 2018-08-01 21:46:09.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-layout.cc 2018-08-14 16:48:02.000000000 +0000 @@ -31,6 +31,7 @@ #include "hb-open-type-private.hh" #include "hb-ot-layout-private.hh" #include "hb-ot-map-private.hh" +#include "hb-map-private.hh" #include "hb-ot-layout-gdef-table.hh" #include "hb-ot-layout-gsub-table.hh" @@ -44,9 +45,124 @@ #include "hb-ot-color-sbix-table.hh" #include "hb-ot-color-svg-table.hh" #include "hb-ot-name-table.hh" -#include "hb-map-private.hh" +static bool +_hb_ot_blacklist_gdef (unsigned int gdef_len, + unsigned int gsub_len, + unsigned int gpos_len) +{ + /* The ugly business of blacklisting individual fonts' tables happen here! + * See this thread for why we finally had to bend in and do this: + * https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html + * + * In certain versions of Times New Roman Italic and Bold Italic, + * ASCII double quotation mark U+0022 has wrong glyph class 3 (mark) + * in GDEF. Many versions of Tahoma have bad GDEF tables that + * incorrectly classify some spacing marks such as certain IPA + * symbols as glyph class 3. So do older versions of Microsoft + * Himalaya, and the version of Cantarell shipped by Ubuntu 16.04. + * + * Nuke the GDEF tables of to avoid unwanted width-zeroing. + * + * See https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 + * https://bugzilla.mozilla.org/show_bug.cgi?id=1279693 + * https://bugzilla.mozilla.org/show_bug.cgi?id=1279875 + */ +#define ENCODE(x,y,z) ((int64_t) (x) << 32 | (int64_t) (y) << 16 | (z)) + switch ENCODE(gdef_len, gsub_len, gpos_len) + { + /* sha1sum:c5ee92f0bca4bfb7d06c4d03e8cf9f9cf75d2e8a Windows 7? timesi.ttf */ + case ENCODE (442, 2874, 42038): + /* sha1sum:37fc8c16a0894ab7b749e35579856c73c840867b Windows 7? timesbi.ttf */ + case ENCODE (430, 2874, 40662): + /* sha1sum:19fc45110ea6cd3cdd0a5faca256a3797a069a80 Windows 7 timesi.ttf */ + case ENCODE (442, 2874, 39116): + /* sha1sum:6d2d3c9ed5b7de87bc84eae0df95ee5232ecde26 Windows 7 timesbi.ttf */ + case ENCODE (430, 2874, 39374): + /* sha1sum:8583225a8b49667c077b3525333f84af08c6bcd8 OS X 10.11.3 Times New Roman Italic.ttf */ + case ENCODE (490, 3046, 41638): + /* sha1sum:ec0f5a8751845355b7c3271d11f9918a966cb8c9 OS X 10.11.3 Times New Roman Bold Italic.ttf */ + case ENCODE (478, 3046, 41902): + /* sha1sum:96eda93f7d33e79962451c6c39a6b51ee893ce8c tahoma.ttf from Windows 8 */ + case ENCODE (898, 12554, 46470): + /* sha1sum:20928dc06014e0cd120b6fc942d0c3b1a46ac2bc tahomabd.ttf from Windows 8 */ + case ENCODE (910, 12566, 47732): + /* sha1sum:4f95b7e4878f60fa3a39ca269618dfde9721a79e tahoma.ttf from Windows 8.1 */ + case ENCODE (928, 23298, 59332): + /* sha1sum:6d400781948517c3c0441ba42acb309584b73033 tahomabd.ttf from Windows 8.1 */ + case ENCODE (940, 23310, 60732): + /* tahoma.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (964, 23836, 60072): + /* tahomabd.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (976, 23832, 61456): + /* sha1sum:e55fa2dfe957a9f7ec26be516a0e30b0c925f846 tahoma.ttf from Windows 10 */ + case ENCODE (994, 24474, 60336): + /* sha1sum:7199385abb4c2cc81c83a151a7599b6368e92343 tahomabd.ttf from Windows 10 */ + case ENCODE (1006, 24470, 61740): + /* tahoma.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (1006, 24576, 61346): + /* tahomabd.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ + case ENCODE (1018, 24572, 62828): + /* sha1sum:b9c84d820c49850d3d27ec498be93955b82772b5 tahoma.ttf from Windows 10 AU */ + case ENCODE (1006, 24576, 61352): + /* sha1sum:2bdfaab28174bdadd2f3d4200a30a7ae31db79d2 tahomabd.ttf from Windows 10 AU */ + case ENCODE (1018, 24572, 62834): + /* sha1sum:b0d36cf5a2fbe746a3dd277bffc6756a820807a7 Tahoma.ttf from Mac OS X 10.9 */ + case ENCODE (832, 7324, 47162): + /* sha1sum:12fc4538e84d461771b30c18b5eb6bd434e30fba Tahoma Bold.ttf from Mac OS X 10.9 */ + case ENCODE (844, 7302, 45474): + /* sha1sum:eb8afadd28e9cf963e886b23a30b44ab4fd83acc himalaya.ttf from Windows 7 */ + case ENCODE (180, 13054, 7254): + /* sha1sum:73da7f025b238a3f737aa1fde22577a6370f77b0 himalaya.ttf from Windows 8 */ + case ENCODE (192, 12638, 7254): + /* sha1sum:6e80fd1c0b059bbee49272401583160dc1e6a427 himalaya.ttf from Windows 8.1 */ + case ENCODE (192, 12690, 7254): + /* 8d9267aea9cd2c852ecfb9f12a6e834bfaeafe44 cantarell-fonts-0.0.21/otf/Cantarell-Regular.otf */ + /* 983988ff7b47439ab79aeaf9a45bd4a2c5b9d371 cantarell-fonts-0.0.21/otf/Cantarell-Oblique.otf */ + case ENCODE (188, 248, 3852): + /* 2c0c90c6f6087ffbfea76589c93113a9cbb0e75f cantarell-fonts-0.0.21/otf/Cantarell-Bold.otf */ + /* 55461f5b853c6da88069ffcdf7f4dd3f8d7e3e6b cantarell-fonts-0.0.21/otf/Cantarell-Bold-Oblique.otf */ + case ENCODE (188, 264, 3426): + /* d125afa82a77a6475ac0e74e7c207914af84b37a padauk-2.80/Padauk.ttf RHEL 7.2 */ + case ENCODE (1058, 47032, 11818): + /* 0f7b80437227b90a577cc078c0216160ae61b031 padauk-2.80/Padauk-Bold.ttf RHEL 7.2*/ + case ENCODE (1046, 47030, 12600): + /* d3dde9aa0a6b7f8f6a89ef1002e9aaa11b882290 padauk-2.80/Padauk.ttf Ubuntu 16.04 */ + case ENCODE (1058, 71796, 16770): + /* 5f3c98ccccae8a953be2d122c1b3a77fd805093f padauk-2.80/Padauk-Bold.ttf Ubuntu 16.04 */ + case ENCODE (1046, 71790, 17862): + /* 6c93b63b64e8b2c93f5e824e78caca555dc887c7 padauk-2.80/Padauk-book.ttf */ + case ENCODE (1046, 71788, 17112): + /* d89b1664058359b8ec82e35d3531931125991fb9 padauk-2.80/Padauk-bookbold.ttf */ + case ENCODE (1058, 71794, 17514): + /* 824cfd193aaf6234b2b4dc0cf3c6ef576c0d00ef padauk-3.0/Padauk-book.ttf */ + case ENCODE (1330, 109904, 57938): + /* 91fcc10cf15e012d27571e075b3b4dfe31754a8a padauk-3.0/Padauk-bookbold.ttf */ + case ENCODE (1330, 109904, 58972): + /* sha1sum: c26e41d567ed821bed997e937bc0c41435689e85 Padauk.ttf + * "Padauk Regular" "Version 2.5", see https://crbug.com/681813 */ + case ENCODE (1004, 59092, 14836): + return true; +#undef ENCODE + } + return false; +} + +void hb_ot_layout_t::tables_t::init0 (hb_face_t *face) +{ + this->face = face; +#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.init0 (); + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE +} +void hb_ot_layout_t::tables_t::fini (void) +{ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) Type.fini (); + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE +} + hb_ot_layout_t * _hb_ot_layout_create (hb_face_t *face) { @@ -54,144 +170,33 @@ if (unlikely (!layout)) return nullptr; - layout->gdef_blob = OT::hb_sanitize_context_t().reference_table (face); - layout->gdef = layout->gdef_blob->as (); + layout->table.init0 (face); - layout->gsub_blob = OT::hb_sanitize_context_t().reference_table (face); - layout->gsub = layout->gsub_blob->as (); + const OT::GSUB &gsub = *layout->table.GSUB; + const OT::GPOS &gpos = *layout->table.GPOS; - layout->gpos_blob = OT::hb_sanitize_context_t().reference_table (face); - layout->gpos = layout->gpos_blob->as (); - - layout->math.init (face); - layout->fvar.init (face); - layout->avar.init (face); - layout->morx.init (face); - - { - /* - * The ugly business of blacklisting individual fonts' tables happen here! - * See this thread for why we finally had to bend in and do this: - * https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html - */ - unsigned int gdef_len = layout->gdef_blob->length; - unsigned int gsub_len = layout->gsub_blob->length; - unsigned int gpos_len = layout->gpos_blob->length; - if (0 - /* sha1sum:c5ee92f0bca4bfb7d06c4d03e8cf9f9cf75d2e8a Windows 7? timesi.ttf */ - || (442 == gdef_len && 42038 == gpos_len && 2874 == gsub_len) - /* sha1sum:37fc8c16a0894ab7b749e35579856c73c840867b Windows 7? timesbi.ttf */ - || (430 == gdef_len && 40662 == gpos_len && 2874 == gsub_len) - /* sha1sum:19fc45110ea6cd3cdd0a5faca256a3797a069a80 Windows 7 timesi.ttf */ - || (442 == gdef_len && 39116 == gpos_len && 2874 == gsub_len) - /* sha1sum:6d2d3c9ed5b7de87bc84eae0df95ee5232ecde26 Windows 7 timesbi.ttf */ - || (430 == gdef_len && 39374 == gpos_len && 2874 == gsub_len) - /* sha1sum:8583225a8b49667c077b3525333f84af08c6bcd8 OS X 10.11.3 Times New Roman Italic.ttf */ - || (490 == gdef_len && 41638 == gpos_len && 3046 == gsub_len) - /* sha1sum:ec0f5a8751845355b7c3271d11f9918a966cb8c9 OS X 10.11.3 Times New Roman Bold Italic.ttf */ - || (478 == gdef_len && 41902 == gpos_len && 3046 == gsub_len) - ) - { - /* In certain versions of Times New Roman Italic and Bold Italic, - * ASCII double quotation mark U+0022, mapped to glyph 5, has wrong - * glyph class 3 (mark) in GDEF. Nuke the GDEF to avoid zero-width - * double-quote. See: - * https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html - */ - if (3 == layout->gdef->get_glyph_class (5)) - layout->gdef = &Null(OT::GDEF); - } - else if (0 - /* sha1sum:96eda93f7d33e79962451c6c39a6b51ee893ce8c tahoma.ttf from Windows 8 */ - || (898 == gdef_len && 46470 == gpos_len && 12554 == gsub_len) - /* sha1sum:20928dc06014e0cd120b6fc942d0c3b1a46ac2bc tahomabd.ttf from Windows 8 */ - || (910 == gdef_len && 47732 == gpos_len && 12566 == gsub_len) - /* sha1sum:4f95b7e4878f60fa3a39ca269618dfde9721a79e tahoma.ttf from Windows 8.1 */ - || (928 == gdef_len && 59332 == gpos_len && 23298 == gsub_len) - /* sha1sum:6d400781948517c3c0441ba42acb309584b73033 tahomabd.ttf from Windows 8.1 */ - || (940 == gdef_len && 60732 == gpos_len && 23310 == gsub_len) - /* tahoma.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (964 == gdef_len && 60072 == gpos_len && 23836 == gsub_len) - /* tahomabd.ttf v6.04 from Windows 8.1 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (976 == gdef_len && 61456 == gpos_len && 23832 == gsub_len) - /* sha1sum:e55fa2dfe957a9f7ec26be516a0e30b0c925f846 tahoma.ttf from Windows 10 */ - || (994 == gdef_len && 60336 == gpos_len && 24474 == gsub_len) - /* sha1sum:7199385abb4c2cc81c83a151a7599b6368e92343 tahomabd.ttf from Windows 10 */ - || (1006 == gdef_len && 61740 == gpos_len && 24470 == gsub_len) - /* tahoma.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (1006 == gdef_len && 61346 == gpos_len && 24576 == gsub_len) - /* tahomabd.ttf v6.91 from Windows 10 x64, see https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 */ - || (1018 == gdef_len && 62828 == gpos_len && 24572 == gsub_len) - /* sha1sum:b9c84d820c49850d3d27ec498be93955b82772b5 tahoma.ttf from Windows 10 AU */ - || (1006 == gdef_len && 61352 == gpos_len && 24576 == gsub_len) - /* sha1sum:2bdfaab28174bdadd2f3d4200a30a7ae31db79d2 tahomabd.ttf from Windows 10 AU */ - || (1018 == gdef_len && 62834 == gpos_len && 24572 == gsub_len) - /* sha1sum:b0d36cf5a2fbe746a3dd277bffc6756a820807a7 Tahoma.ttf from Mac OS X 10.9 */ - || (832 == gdef_len && 47162 == gpos_len && 7324 == gsub_len) - /* sha1sum:12fc4538e84d461771b30c18b5eb6bd434e30fba Tahoma Bold.ttf from Mac OS X 10.9 */ - || (844 == gdef_len && 45474 == gpos_len && 7302 == gsub_len) - /* sha1sum:eb8afadd28e9cf963e886b23a30b44ab4fd83acc himalaya.ttf from Windows 7 */ - || (180 == gdef_len && 7254 == gpos_len && 13054 == gsub_len) - /* sha1sum:73da7f025b238a3f737aa1fde22577a6370f77b0 himalaya.ttf from Windows 8 */ - || (192 == gdef_len && 7254 == gpos_len && 12638 == gsub_len) - /* sha1sum:6e80fd1c0b059bbee49272401583160dc1e6a427 himalaya.ttf from Windows 8.1 */ - || (192 == gdef_len && 7254 == gpos_len && 12690 == gsub_len) - /* 8d9267aea9cd2c852ecfb9f12a6e834bfaeafe44 cantarell-fonts-0.0.21/otf/Cantarell-Regular.otf */ - /* 983988ff7b47439ab79aeaf9a45bd4a2c5b9d371 cantarell-fonts-0.0.21/otf/Cantarell-Oblique.otf */ - || (188 == gdef_len && 3852 == gpos_len && 248 == gsub_len) - /* 2c0c90c6f6087ffbfea76589c93113a9cbb0e75f cantarell-fonts-0.0.21/otf/Cantarell-Bold.otf */ - /* 55461f5b853c6da88069ffcdf7f4dd3f8d7e3e6b cantarell-fonts-0.0.21/otf/Cantarell-Bold-Oblique.otf */ - || (188 == gdef_len && 3426 == gpos_len && 264 == gsub_len) - /* d125afa82a77a6475ac0e74e7c207914af84b37a padauk-2.80/Padauk.ttf RHEL 7.2 */ - || (1058 == gdef_len && 11818 == gpos_len && 47032 == gsub_len) - /* 0f7b80437227b90a577cc078c0216160ae61b031 padauk-2.80/Padauk-Bold.ttf RHEL 7.2*/ - || (1046 == gdef_len && 12600 == gpos_len && 47030 == gsub_len) - /* d3dde9aa0a6b7f8f6a89ef1002e9aaa11b882290 padauk-2.80/Padauk.ttf Ubuntu 16.04 */ - || (1058 == gdef_len && 16770 == gpos_len && 71796 == gsub_len) - /* 5f3c98ccccae8a953be2d122c1b3a77fd805093f padauk-2.80/Padauk-Bold.ttf Ubuntu 16.04 */ - || (1046 == gdef_len && 17862 == gpos_len && 71790 == gsub_len) - /* 6c93b63b64e8b2c93f5e824e78caca555dc887c7 padauk-2.80/Padauk-book.ttf */ - || (1046 == gdef_len && 17112 == gpos_len && 71788 == gsub_len) - /* d89b1664058359b8ec82e35d3531931125991fb9 padauk-2.80/Padauk-bookbold.ttf */ - || (1058 == gdef_len && 17514 == gpos_len && 71794 == gsub_len) - /* 824cfd193aaf6234b2b4dc0cf3c6ef576c0d00ef padauk-3.0/Padauk-book.ttf */ - || (1330 == gdef_len && 57938 == gpos_len && 109904 == gsub_len) - /* 91fcc10cf15e012d27571e075b3b4dfe31754a8a padauk-3.0/Padauk-bookbold.ttf */ - || (1330 == gdef_len && 58972 == gpos_len && 109904 == gsub_len) - /* sha1sum: c26e41d567ed821bed997e937bc0c41435689e85 Padauk.ttf - * "Padauk Regular" "Version 2.5", see https://crbug.com/681813 */ - || (1004 == gdef_len && 14836 == gpos_len && 59092 == gsub_len) - ) - { - /* Many versions of Tahoma have bad GDEF tables that incorrectly classify some spacing marks - * such as certain IPA symbols as glyph class 3. So do older versions of Microsoft Himalaya, - * and the version of Cantarell shipped by Ubuntu 16.04. - * Nuke the GDEF tables of these fonts to avoid unwanted width-zeroing. - * See https://bugzilla.mozilla.org/show_bug.cgi?id=1279925 - * https://bugzilla.mozilla.org/show_bug.cgi?id=1279693 - * https://bugzilla.mozilla.org/show_bug.cgi?id=1279875 - */ - layout->gdef = &Null(OT::GDEF); - } - } + if (unlikely (_hb_ot_blacklist_gdef (layout->table.GDEF.get_blob ()->length, + layout->table.GSUB.get_blob ()->length, + layout->table.GPOS.get_blob ()->length))) + layout->table.GDEF.set_stored (hb_blob_get_empty ()); - layout->gsub_lookup_count = layout->gsub->get_lookup_count (); - layout->gpos_lookup_count = layout->gpos->get_lookup_count (); + unsigned int gsub_lookup_count = layout->gsub_lookup_count = gsub.get_lookup_count (); + unsigned int gpos_lookup_count = layout->gpos_lookup_count = gpos.get_lookup_count (); - layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gsub->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t)); - layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (layout->gpos->get_lookup_count (), sizeof (hb_ot_layout_lookup_accelerator_t)); + layout->gsub_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gsub_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); + layout->gpos_accels = (hb_ot_layout_lookup_accelerator_t *) calloc (gpos_lookup_count, sizeof (hb_ot_layout_lookup_accelerator_t)); - if (unlikely ((layout->gsub_lookup_count && !layout->gsub_accels) || - (layout->gpos_lookup_count && !layout->gpos_accels))) + if (unlikely ((gsub_lookup_count && !layout->gsub_accels) || + (gpos_lookup_count && !layout->gpos_accels))) { _hb_ot_layout_destroy (layout); return nullptr; } - for (unsigned int i = 0; i < layout->gsub_lookup_count; i++) - layout->gsub_accels[i].init (layout->gsub->get_lookup (i)); - for (unsigned int i = 0; i < layout->gpos_lookup_count; i++) - layout->gpos_accels[i].init (layout->gpos->get_lookup (i)); + for (unsigned int i = 0; i < gsub_lookup_count; i++) + layout->gsub_accels[i].init (gsub.get_lookup (i)); + for (unsigned int i = 0; i < gpos_lookup_count; i++) + layout->gpos_accels[i].init (gpos.get_lookup (i)); return layout; } @@ -209,14 +214,7 @@ free (layout->gsub_accels); free (layout->gpos_accels); - hb_blob_destroy (layout->gdef_blob); - hb_blob_destroy (layout->gsub_blob); - hb_blob_destroy (layout->gpos_blob); - - layout->math.fini (); - layout->fvar.fini (); - layout->avar.fini (); - layout->morx.fini (); + layout->table.fini (); free (layout); } @@ -233,19 +231,19 @@ _get_gdef (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GDEF); - return *hb_ot_layout_from_face (face)->gdef; + return *hb_ot_layout_from_face (face)->table.GDEF; } static inline const OT::GSUB& _get_gsub (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GSUB); - return *hb_ot_layout_from_face (face)->gsub; + return *hb_ot_layout_from_face (face)->table.GSUB; } static inline const OT::GPOS& _get_gpos (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::GPOS); - return *hb_ot_layout_from_face (face)->gpos; + return *hb_ot_layout_from_face (face)->table.GPOS; } /* @@ -853,13 +851,13 @@ { case HB_OT_TAG_GSUB: { - const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index); + const OT::SubstLookup& l = hb_ot_layout_from_face (face)->table.GSUB->get_lookup (lookup_index); l.collect_glyphs (&c); return; } case HB_OT_TAG_GPOS: { - const OT::PosLookup& l = hb_ot_layout_from_face (face)->gpos->get_lookup (lookup_index); + const OT::PosLookup& l = hb_ot_layout_from_face (face)->table.GPOS->get_lookup (lookup_index); l.collect_glyphs (&c); return; } @@ -906,7 +904,7 @@ hb_bool_t hb_ot_layout_has_substitution (hb_face_t *face) { - return &_get_gsub (face) != &Null(OT::GSUB); + return _get_gsub (face).has_data (); } /** @@ -935,7 +933,7 @@ if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false; OT::hb_would_apply_context_t c (face, glyphs, glyphs_length, (bool) zero_context); - const OT::SubstLookup& l = hb_ot_layout_from_face (face)->gsub->get_lookup (lookup_index); + const OT::SubstLookup& l = hb_ot_layout_from_face (face)->table.GSUB->get_lookup (lookup_index); return l.would_apply (&c, &hb_ot_layout_from_face (face)->gsub_accels[lookup_index]); } @@ -1008,7 +1006,7 @@ hb_bool_t hb_ot_layout_has_positioning (hb_face_t *face) { - return &_get_gpos (face) != &Null(OT::GPOS); + return _get_gpos (face).has_data (); } void @@ -1093,7 +1091,7 @@ typedef OT::SubstLookup Lookup; GSUBProxy (hb_face_t *face) : - table (*hb_ot_layout_from_face (face)->gsub), + table (*hb_ot_layout_from_face (face)->table.GSUB), accels (hb_ot_layout_from_face (face)->gsub_accels) {} const OT::GSUB &table; @@ -1107,7 +1105,7 @@ typedef OT::PosLookup Lookup; GPOSProxy (hb_face_t *face) : - table (*hb_ot_layout_from_face (face)->gpos), + table (*hb_ot_layout_from_face (face)->table.GPOS), accels (hb_ot_layout_from_face (face)->gpos_accels) {} const OT::GPOS &table; @@ -1116,7 +1114,7 @@ struct hb_get_subtables_context_t : - OT::hb_dispatch_context_t + hb_dispatch_context_t { template static inline bool apply_to (const void *obj, OT::hb_ot_apply_context_t *c) @@ -1343,5 +1341,5 @@ // hb_bool_t // hb_ot_base_has_data (hb_face_t *face) // { -// return &_get_base (face) != &Null(OT::BASE); +// return _get_base (face).has_data (); // } diff -Nru harfbuzz-1.8.5/src/hb-ot-layout-common-private.hh harfbuzz-1.8.8/src/hb-ot-layout-common-private.hh --- harfbuzz-1.8.5/src/hb-ot-layout-common-private.hh 2018-08-01 21:15:00.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-layout-common-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -173,7 +173,7 @@ public: DEFINE_SIZE_STATIC (6); }; -DEFINE_NULL_DATA (OT, RangeRecord, "\000\001"); +DECLARE_NULL_NAMESPACE_BYTES (OT, RangeRecord); struct IndexArray : ArrayOf @@ -240,8 +240,7 @@ public: DEFINE_SIZE_ARRAY (6, featureIndex); }; -DEFINE_NULL_DATA (OT, LangSys, "\0\0\xFF\xFF"); - +DECLARE_NULL_NAMESPACE_BYTES (OT, LangSys); struct Script { diff -Nru harfbuzz-1.8.5/src/hb-ot-layout-gdef-table.hh harfbuzz-1.8.8/src/hb-ot-layout-gdef-table.hh --- harfbuzz-1.8.5/src/hb-ot-layout-gdef-table.hh 2018-06-02 22:39:30.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-layout-gdef-table.hh 2018-08-14 16:48:02.000000000 +0000 @@ -349,6 +349,7 @@ ComponentGlyph = 4 }; + inline bool has_data (void) const { return version.to_int () != 0; } inline bool has_glyph_classes (void) const { return glyphClassDef != 0; } inline unsigned int get_glyph_class (hb_codepoint_t glyph) const { return (this+glyphClassDef).get_class (glyph); } diff -Nru harfbuzz-1.8.5/src/hb-ot-layout-gpos-table.hh harfbuzz-1.8.8/src/hb-ot-layout-gpos-table.hh --- harfbuzz-1.8.5/src/hb-ot-layout-gpos-table.hh 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-layout-gpos-table.hh 2018-08-14 16:48:02.000000000 +0000 @@ -1628,14 +1628,14 @@ template /*static*/ inline typename context_t::return_t PosLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) { - const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); + const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS); const PosLookup &l = gpos.get_lookup (lookup_index); return l.dispatch (c); } /*static*/ inline bool PosLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index) { - const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->gpos); + const GPOS &gpos = *(hb_ot_layout_from_face (c->face)->table.GPOS); const PosLookup &l = gpos.get_lookup (lookup_index); unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_index = c->lookup_index; diff -Nru harfbuzz-1.8.5/src/hb-ot-layout-gsubgpos-private.hh harfbuzz-1.8.8/src/hb-ot-layout-gsubgpos-private.hh --- harfbuzz-1.8.5/src/hb-ot-layout-gsubgpos-private.hh 2018-07-25 23:01:24.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-layout-gsubgpos-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -480,7 +480,7 @@ iter_input (), iter_context (), font (font_), face (font->face), buffer (buffer_), recurse_func (nullptr), - gdef (*hb_ot_layout_from_face (face)->gdef), + gdef (*hb_ot_layout_from_face (face)->table.GDEF), var_store (gdef.get_var_store ()), direction (buffer_->props.direction), lookup_mask (1), @@ -2320,6 +2320,7 @@ struct GSUBGPOS { + inline bool has_data (void) const { return version.to_int () != 0; } inline unsigned int get_script_count (void) const { return (this+scriptList).len; } inline const Tag& get_script_tag (unsigned int i) const diff -Nru harfbuzz-1.8.5/src/hb-ot-layout-gsub-table.hh harfbuzz-1.8.8/src/hb-ot-layout-gsub-table.hh --- harfbuzz-1.8.5/src/hb-ot-layout-gsub-table.hh 2018-07-24 20:24:40.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-layout-gsub-table.hh 2018-08-14 16:48:02.000000000 +0000 @@ -1335,7 +1335,7 @@ { _hb_buffer_assert_gsubgpos_vars (buffer); - const GDEF &gdef = *hb_ot_layout_from_face (font->face)->gdef; + const GDEF &gdef = *hb_ot_layout_from_face (font->face)->table.GDEF; unsigned int count = buffer->len; for (unsigned int i = 0; i < count; i++) { @@ -1359,14 +1359,14 @@ template /*static*/ inline typename context_t::return_t SubstLookup::dispatch_recurse_func (context_t *c, unsigned int lookup_index) { - const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); + const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB); const SubstLookup &l = gsub.get_lookup (lookup_index); return l.dispatch (c); } /*static*/ inline bool SubstLookup::apply_recurse_func (hb_ot_apply_context_t *c, unsigned int lookup_index) { - const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->gsub); + const GSUB &gsub = *(hb_ot_layout_from_face (c->face)->table.GSUB); const SubstLookup &l = gsub.get_lookup (lookup_index); unsigned int saved_lookup_props = c->lookup_props; unsigned int saved_lookup_index = c->lookup_index; diff -Nru harfbuzz-1.8.5/src/hb-ot-layout-private.hh harfbuzz-1.8.8/src/hb-ot-layout-private.hh --- harfbuzz-1.8.5/src/hb-ot-layout-private.hh 2018-07-17 15:28:18.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-layout-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -121,25 +121,6 @@ * hb_ot_layout_t */ -namespace OT { - struct BASE; - struct COLR; - struct CPAL; - struct GDEF; - struct GSUB; - struct GPOS; - struct MATH; - struct fvar; - struct avar; -} - -namespace AAT { - struct ankr; - struct kerx; - struct morx; - struct trak; -} - struct hb_ot_layout_lookup_accelerator_t { template @@ -161,28 +142,73 @@ hb_set_digest_t digest; }; +/* Most of these tables are NOT needed for shaping. But we need to hook them *somewhere*. + * This is as good as any place. */ +#define HB_OT_LAYOUT_TABLES \ + /* OpenType shaping. */ \ + HB_OT_LAYOUT_TABLE(OT, GDEF) \ + HB_OT_LAYOUT_TABLE(OT, GSUB) \ + HB_OT_LAYOUT_TABLE(OT, GPOS) \ + HB_OT_LAYOUT_TABLE(OT, JSTF) \ + HB_OT_LAYOUT_TABLE(OT, BASE) \ + /* AAT shaping. */ \ + HB_OT_LAYOUT_TABLE(AAT, morx) \ + HB_OT_LAYOUT_TABLE(AAT, kerx) \ + HB_OT_LAYOUT_TABLE(AAT, ankr) \ + HB_OT_LAYOUT_TABLE(AAT, trak) \ + /* OpenType variations. */ \ + HB_OT_LAYOUT_TABLE(OT, fvar) \ + HB_OT_LAYOUT_TABLE(OT, avar) \ + HB_OT_LAYOUT_TABLE(OT, MVAR) \ + /* OpenType color. */ \ + HB_OT_LAYOUT_TABLE(OT, COLR) \ + HB_OT_LAYOUT_TABLE(OT, CPAL) \ + HB_OT_LAYOUT_TABLE(OT, CBDT) \ + HB_OT_LAYOUT_TABLE(OT, CBLC) \ + HB_OT_LAYOUT_TABLE(OT, sbix) \ + HB_OT_LAYOUT_TABLE(OT, svg) \ + /* OpenType math. */ \ + HB_OT_LAYOUT_TABLE(OT, MATH) \ + /* OpenType fundamentals. */ \ + HB_OT_LAYOUT_TABLE(OT, post) \ + /* */ + +/* Declare tables. */ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) namespace Namespace { struct Type; } +HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE + struct hb_ot_layout_t { - hb_blob_t *gdef_blob; - hb_blob_t *gsub_blob; - hb_blob_t *gpos_blob; - - const struct OT::GDEF *gdef; - const struct OT::GSUB *gsub; - const struct OT::GPOS *gpos; - - /* TODO Move the following out of this struct. */ - OT::hb_table_lazy_loader_t base; - OT::hb_table_lazy_loader_t math; - OT::hb_table_lazy_loader_t fvar; - OT::hb_table_lazy_loader_t avar; - OT::hb_table_lazy_loader_t morx; - unsigned int gsub_lookup_count; unsigned int gpos_lookup_count; hb_ot_layout_lookup_accelerator_t *gsub_accels; hb_ot_layout_lookup_accelerator_t *gpos_accels; + + /* Various non-shaping tables. */ + struct tables_t + { + HB_INTERNAL void init0 (hb_face_t *face); + HB_INTERNAL void fini (void); + +#define HB_OT_LAYOUT_TABLE_ORDER(Namespace, Type) \ + HB_PASTE (ORDER_, HB_PASTE (Namespace, HB_PASTE (_, Type))) + enum order_t + { + ORDER_ZERO, +#define HB_OT_LAYOUT_TABLE(Namespace, Type) \ + HB_OT_LAYOUT_TABLE_ORDER (Namespace, Type), + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE + }; + + hb_face_t *face; /* MUST be JUST before the lazy loaders. */ +#define HB_OT_LAYOUT_TABLE(Namespace, Type) \ + hb_table_lazy_loader_t Type; + HB_OT_LAYOUT_TABLES +#undef HB_OT_LAYOUT_TABLE + } table; }; @@ -193,7 +219,7 @@ _hb_ot_layout_destroy (hb_ot_layout_t *layout); -#define hb_ot_layout_from_face(face) ((hb_ot_layout_t *) face->shaper_data.ot) +#define hb_ot_layout_from_face(face) ((hb_ot_layout_t *) face->shaper_data.ot.get_relaxed ()) /* diff -Nru harfbuzz-1.8.5/src/hb-ot-math.cc harfbuzz-1.8.8/src/hb-ot-math.cc --- harfbuzz-1.8.5/src/hb-ot-math.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-math.cc 2018-08-14 16:48:02.000000000 +0000 @@ -34,7 +34,7 @@ { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::MATH); hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->math.get ()); + return *(layout->table.MATH.get ()); } /* @@ -55,7 +55,7 @@ hb_bool_t hb_ot_math_has_data (hb_face_t *face) { - return &_get_math (face) != &Null(OT::MATH); + return _get_math (face).has_data (); } /** diff -Nru harfbuzz-1.8.5/src/hb-ot-math-table.hh harfbuzz-1.8.8/src/hb-ot-math-table.hh --- harfbuzz-1.8.5/src/hb-ot-math-table.hh 2018-06-02 22:39:30.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-math-table.hh 2018-08-14 16:48:02.000000000 +0000 @@ -686,6 +686,8 @@ { static const hb_tag_t tableTag = HB_OT_TAG_MATH; + inline bool has_data (void) const { return version.to_int () != 0; } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); diff -Nru harfbuzz-1.8.5/src/hb-ot-post-table.hh harfbuzz-1.8.8/src/hb-ot-post-table.hh --- harfbuzz-1.8.5/src/hb-ot-post-table.hh 2018-07-23 21:38:01.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-post-table.hh 2018-08-14 16:48:02.000000000 +0000 @@ -130,7 +130,7 @@ inline void fini (void) { index_to_offset.fini (); - free (gids_sorted_by_name); + free (gids_sorted_by_name.get ()); } inline bool get_glyph_name (hb_codepoint_t glyph, @@ -162,7 +162,7 @@ return false; retry: - uint16_t *gids = (uint16_t *) hb_atomic_ptr_get (&gids_sorted_by_name); + uint16_t *gids = gids_sorted_by_name.get (); if (unlikely (!gids)) { @@ -174,7 +174,8 @@ gids[i] = i; hb_sort_r (gids, count, sizeof (gids[0]), cmp_gids, (void *) this); - if (!hb_atomic_ptr_cmpexch (&gids_sorted_by_name, nullptr, gids)) { + if (unlikely (!gids_sorted_by_name.cmpexch (nullptr, gids))) + { free (gids); goto retry; } @@ -255,7 +256,7 @@ const ArrayOf *glyphNameIndex; hb_vector_t index_to_offset; const uint8_t *pool; - mutable uint16_t *gids_sorted_by_name; + hb_atomic_ptr_t gids_sorted_by_name; }; public: diff -Nru harfbuzz-1.8.5/src/hb-ot-shape.cc harfbuzz-1.8.8/src/hb-ot-shape.cc --- harfbuzz-1.8.5/src/hb-ot-shape.cc 2018-07-27 21:55:22.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-shape.cc 2018-08-14 16:48:02.000000000 +0000 @@ -27,8 +27,8 @@ */ #define HB_SHAPER ot -#define hb_ot_shaper_face_data_t hb_ot_layout_t -#define hb_ot_shaper_shape_plan_data_t hb_ot_shape_plan_t +#define hb_ot_face_data_t hb_ot_layout_t +#define hb_ot_shape_plan_data_t hb_ot_shape_plan_t #include "hb-shaper-impl-private.hh" #include "hb-ot-shape-private.hh" @@ -132,14 +132,14 @@ HB_SHAPER_DATA_ENSURE_DEFINE(ot, face) -hb_ot_shaper_face_data_t * +hb_ot_face_data_t * _hb_ot_shaper_face_data_create (hb_face_t *face) { return _hb_ot_layout_create (face); } void -_hb_ot_shaper_face_data_destroy (hb_ot_shaper_face_data_t *data) +_hb_ot_shaper_face_data_destroy (hb_ot_face_data_t *data) { _hb_ot_layout_destroy (data); } @@ -151,16 +151,16 @@ HB_SHAPER_DATA_ENSURE_DEFINE(ot, font) -struct hb_ot_shaper_font_data_t {}; +struct hb_ot_font_data_t {}; -hb_ot_shaper_font_data_t * +hb_ot_font_data_t * _hb_ot_shaper_font_data_create (hb_font_t *font HB_UNUSED) { - return (hb_ot_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_ot_font_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_ot_shaper_font_data_destroy (hb_ot_shaper_font_data_t *data) +_hb_ot_shaper_font_data_destroy (hb_ot_font_data_t *data) { } @@ -169,7 +169,7 @@ * shaper shape_plan data */ -hb_ot_shaper_shape_plan_data_t * +hb_ot_shape_plan_data_t * _hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan, const hb_feature_t *user_features, unsigned int num_user_features, @@ -204,7 +204,7 @@ } void -_hb_ot_shaper_shape_plan_data_destroy (hb_ot_shaper_shape_plan_data_t *plan) +_hb_ot_shaper_shape_plan_data_destroy (hb_ot_shape_plan_data_t *plan) { if (plan->shaper->data_destroy) plan->shaper->data_destroy (const_cast (plan->data)); @@ -680,8 +680,8 @@ if (HB_DIRECTION_IS_HORIZONTAL (direction)) { - for (unsigned int i = 0; i < count; i++) - pos[i].x_advance = c->font->get_glyph_h_advance (info[i].codepoint); + c->font->get_glyph_h_advances (count, &info[0].codepoint, sizeof(info[0]), + &pos[0].x_advance, sizeof(pos[0])); /* The nil glyph_h_origin() func returns 0, so no need to apply it. */ if (c->font->has_glyph_h_origin_func ()) for (unsigned int i = 0; i < count; i++) @@ -691,9 +691,10 @@ } else { + c->font->get_glyph_v_advances (count, &info[0].codepoint, sizeof(info[0]), + &pos[0].y_advance, sizeof(pos[0])); for (unsigned int i = 0; i < count; i++) { - pos[i].y_advance = c->font->get_glyph_v_advance (info[i].codepoint); c->font->subtract_glyph_v_origin (info[i].codepoint, &pos[i].x_offset, &pos[i].y_offset); diff -Nru harfbuzz-1.8.5/src/hb-ot-shape-complex-arabic.cc harfbuzz-1.8.8/src/hb-ot-shape-complex-arabic.cc --- harfbuzz-1.8.5/src/hb-ot-shape-complex-arabic.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-shape-complex-arabic.cc 2018-08-14 16:48:02.000000000 +0000 @@ -250,7 +250,7 @@ * mask_array[NONE] == 0. */ hb_mask_t mask_array[ARABIC_NUM_FEATURES + 1]; - mutable arabic_fallback_plan_t *fallback_plan; + hb_atomic_ptr_t fallback_plan; unsigned int do_fallback : 1; unsigned int has_stch : 1; @@ -280,7 +280,7 @@ { arabic_shape_plan_t *arabic_plan = (arabic_shape_plan_t *) data; - arabic_fallback_plan_destroy (arabic_plan->fallback_plan); + arabic_fallback_plan_destroy (arabic_plan->fallback_plan.get ()); free (data); } @@ -403,12 +403,13 @@ return; retry: - arabic_fallback_plan_t *fallback_plan = (arabic_fallback_plan_t *) hb_atomic_ptr_get (&arabic_plan->fallback_plan); + arabic_fallback_plan_t *fallback_plan = arabic_plan->fallback_plan.get (); if (unlikely (!fallback_plan)) { /* This sucks. We need a font to build the fallback plan... */ fallback_plan = arabic_fallback_plan_create (plan, font); - if (unlikely (!hb_atomic_ptr_cmpexch (&(const_cast (arabic_plan))->fallback_plan, nullptr, fallback_plan))) { + if (unlikely (!arabic_plan->fallback_plan.cmpexch (nullptr, fallback_plan))) + { arabic_fallback_plan_destroy (fallback_plan); goto retry; } diff -Nru harfbuzz-1.8.5/src/hb-ot-shape-complex-arabic-fallback.hh harfbuzz-1.8.8/src/hb-ot-shape-complex-arabic-fallback.hh --- harfbuzz-1.8.5/src/hb-ot-shape-complex-arabic-fallback.hh 2018-05-08 09:55:16.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-shape-complex-arabic-fallback.hh 2018-08-14 16:48:02.000000000 +0000 @@ -79,12 +79,12 @@ * May not be good-enough for presidential candidate interviews, but good-enough for us... */ hb_stable_sort (&glyphs[0], num_glyphs, (int(*)(const OT::GlyphID*, const OT::GlyphID *)) OT::GlyphID::cmp, &substitutes[0]); - OT::Supplier glyphs_supplier (glyphs, num_glyphs); - OT::Supplier substitutes_supplier (substitutes, num_glyphs); + Supplier glyphs_supplier (glyphs, num_glyphs); + Supplier substitutes_supplier (substitutes, num_glyphs); /* Each glyph takes four bytes max, and there's some overhead. */ char buf[(SHAPING_TABLE_LAST - SHAPING_TABLE_FIRST + 1) * 4 + 128]; - OT::hb_serialize_context_t c (buf, sizeof (buf)); + hb_serialize_context_t c (buf, sizeof (buf)); OT::SubstLookup *lookup = c.start_serialize (); bool ret = lookup->serialize_single (&c, OT::LookupFlag::IgnoreMarks, @@ -155,15 +155,15 @@ if (!num_ligatures) return nullptr; - OT::Supplier first_glyphs_supplier (first_glyphs, num_first_glyphs); - OT::Supplier ligature_per_first_glyph_count_supplier (ligature_per_first_glyph_count_list, num_first_glyphs); - OT::Supplier ligatures_supplier (ligature_list, num_ligatures); - OT::Supplier component_count_supplier (component_count_list, num_ligatures); - OT::Supplier component_supplier (component_list, num_ligatures); + Supplier first_glyphs_supplier (first_glyphs, num_first_glyphs); + Supplier ligature_per_first_glyph_count_supplier (ligature_per_first_glyph_count_list, num_first_glyphs); + Supplier ligatures_supplier (ligature_list, num_ligatures); + Supplier component_count_supplier (component_count_list, num_ligatures); + Supplier component_supplier (component_list, num_ligatures); /* 16 bytes per ligature ought to be enough... */ char buf[ARRAY_LENGTH_CONST (ligature_list) * 16 + 128]; - OT::hb_serialize_context_t c (buf, sizeof (buf)); + hb_serialize_context_t c (buf, sizeof (buf)); OT::SubstLookup *lookup = c.start_serialize (); bool ret = lookup->serialize_ligature (&c, OT::LookupFlag::IgnoreMarks, @@ -205,8 +205,6 @@ hb_ot_layout_lookup_accelerator_t accel_array[ARABIC_FALLBACK_MAX_LOOKUPS]; }; -static const arabic_fallback_plan_t arabic_fallback_plan_nil = {}; - #if (defined(_WIN32) || defined(__CYGWIN__)) && !defined(HB_NO_WIN1256) #define HB_WITH_WIN1256 #endif @@ -215,7 +213,8 @@ #include "hb-ot-shape-complex-arabic-win1256.hh" #endif -struct ManifestLookup { +struct ManifestLookup +{ OT::Tag tag; OT::OffsetTo lookupOffset; }; @@ -299,7 +298,7 @@ { arabic_fallback_plan_t *fallback_plan = (arabic_fallback_plan_t *) calloc (1, sizeof (arabic_fallback_plan_t)); if (unlikely (!fallback_plan)) - return const_cast (&arabic_fallback_plan_nil); + return const_cast (&Null(arabic_fallback_plan_t)); fallback_plan->num_lookups = 0; fallback_plan->free_lookups = false; @@ -314,14 +313,15 @@ if (arabic_fallback_plan_init_win1256 (fallback_plan, plan, font)) return fallback_plan; + assert (fallback_plan->num_lookups == 0); free (fallback_plan); - return const_cast (&arabic_fallback_plan_nil); + return const_cast (&Null(arabic_fallback_plan_t)); } static void arabic_fallback_plan_destroy (arabic_fallback_plan_t *fallback_plan) { - if (!fallback_plan || fallback_plan == &arabic_fallback_plan_nil) + if (!fallback_plan || fallback_plan->num_lookups == 0) return; for (unsigned int i = 0; i < fallback_plan->num_lookups; i++) diff -Nru harfbuzz-1.8.5/src/hb-ot-var.cc harfbuzz-1.8.8/src/hb-ot-var.cc --- harfbuzz-1.8.5/src/hb-ot-var.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-var.cc 2018-08-14 16:48:02.000000000 +0000 @@ -41,14 +41,14 @@ { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::fvar); hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->fvar.get ()); + return *(layout->table.fvar.get ()); } static inline const OT::avar& _get_avar (hb_face_t *face) { if (unlikely (!hb_ot_shaper_face_data_ensure (face))) return Null(OT::avar); hb_ot_layout_t * layout = hb_ot_layout_from_face (face); - return *(layout->avar.get ()); + return *(layout->table.avar.get ()); } /** @@ -65,7 +65,7 @@ hb_bool_t hb_ot_var_has_data (hb_face_t *face) { - return &_get_fvar (face) != &Null(OT::fvar); + return _get_fvar (face).has_data (); } /** diff -Nru harfbuzz-1.8.5/src/hb-ot-var-fvar-table.hh harfbuzz-1.8.8/src/hb-ot-var-fvar-table.hh --- harfbuzz-1.8.5/src/hb-ot-var-fvar-table.hh 2018-06-02 22:39:30.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ot-var-fvar-table.hh 2018-08-14 16:48:02.000000000 +0000 @@ -87,6 +87,8 @@ { static const hb_tag_t tableTag = HB_OT_TAG_fvar; + inline bool has_data (void) const { return version.to_int () != 0; } + inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); diff -Nru harfbuzz-1.8.5/src/hb-private.hh harfbuzz-1.8.8/src/hb-private.hh --- harfbuzz-1.8.5/src/hb-private.hh 2018-08-01 04:11:44.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -86,7 +86,7 @@ /* * Compiler attributes - * */ + */ #if __cplusplus < 201103L @@ -98,7 +98,6 @@ #define constexpr const #endif -// Static assertions #ifndef static_assert #define static_assert(e, msg) \ HB_UNUSED typedef int HB_PASTE(static_assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1] @@ -124,9 +123,22 @@ }; #ifndef alignof #define alignof(x) (_hb_alignof::value) -#endif // alignof +#endif + +/* https://github.com/harfbuzz/harfbuzz/issues/1127 */ +#ifndef explicit_operator +#define explicit_operator +#endif + +#else /* __cplusplus >= 201103L */ + +/* https://github.com/harfbuzz/harfbuzz/issues/1127 */ +#ifndef explicit_operator +#define explicit_operator explicit +#endif + +#endif /* __cplusplus < 201103L */ -#endif // __cplusplus < 201103L #if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE__) #define likely(expr) (__builtin_expect (!!(expr), 1)) @@ -286,13 +298,12 @@ #define HB_STMT_START do #define HB_STMT_END while (0) +/* Static-assert as expression. */ template class hb_assert_constant_t; template <> class hb_assert_constant_t<1> {}; - #define ASSERT_STATIC_EXPR_ZERO(_cond) (0 * (unsigned int) sizeof (hb_assert_constant_t<_cond>)) /* Lets assert int types. Saves trouble down the road. */ - static_assert ((sizeof (int8_t) == 1), ""); static_assert ((sizeof (uint8_t) == 1), ""); static_assert ((sizeof (int16_t) == 2), ""); @@ -301,7 +312,6 @@ static_assert ((sizeof (uint32_t) == 4), ""); static_assert ((sizeof (int64_t) == 8), ""); static_assert ((sizeof (uint64_t) == 8), ""); - static_assert ((sizeof (hb_codepoint_t) == 4), ""); static_assert ((sizeof (hb_position_t) == 4), ""); static_assert ((sizeof (hb_mask_t) == 4), ""); @@ -371,82 +381,6 @@ #endif -/* - * Static pools - */ - -/* Global nul-content Null pool. Enlarge as necessary. */ - -#define HB_NULL_POOL_SIZE 264 - -extern HB_INTERNAL -hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)]; - -/* Generic nul-content Null objects. */ -template -static inline Type const & Null (void) { - static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); - return *reinterpret_cast (_hb_NullPool); -} -#define Null(Type) Null() - -/* Specializaiton for arbitrary-content arbitrary-sized Null objects. */ -#define DEFINE_NULL_DATA(Namespace, Type, data) \ -} /* Close namespace. */ \ -static const char _Null##Type[sizeof (Namespace::Type) + 1] = data; /* +1 is for nul-termination in data */ \ -template <> \ -/*static*/ inline const Namespace::Type& Null (void) { \ - return *reinterpret_cast (_Null##Type); \ -} \ -namespace Namespace { \ -/* The following line really exists such that we end in a place needing semicolon */ \ -static_assert (Namespace::Type::min_size + 1 <= sizeof (_Null##Type), "Null pool too small. Enlarge.") - - -/* Global writable pool. Enlarge as necessary. */ - -/* To be fully correct, CrapPool must be thread_local. However, we do not rely on CrapPool - * for correct operation. It only exist to catch and divert program logic bugs instead of - * causing bad memory access. So, races there are not actually introducing incorrectness - * in the code. Has ~12kb binary size overhead to have it, also clang build fails with it. */ -extern HB_INTERNAL -/*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)]; - -/* CRAP pool: Common Region for Access Protection. */ -template -static inline Type& Crap (void) { - static_assert (sizeof (Type) <= HB_NULL_POOL_SIZE, "Increase HB_NULL_POOL_SIZE."); - Type *obj = reinterpret_cast (_hb_CrapPool); - *obj = Null(Type); - return *obj; -} -#define Crap(Type) Crap() - -template -struct CrapOrNull { - static inline Type & get (void) { return Crap(Type); } -}; -template -struct CrapOrNull { - static inline Type const & get (void) { return Null(Type); } -}; -#define CrapOrNull(Type) CrapOrNull::get () - - -/* ASCII tag/character handling */ - -static inline bool ISALPHA (unsigned char c) -{ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } -static inline bool ISALNUM (unsigned char c) -{ return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'); } -static inline bool ISSPACE (unsigned char c) -{ return c == ' ' || c =='\f'|| c =='\n'|| c =='\r'|| c =='\t'|| c =='\v'; } -static inline unsigned char TOUPPER (unsigned char c) -{ return (c >= 'a' && c <= 'z') ? c - 'a' + 'A' : c; } -static inline unsigned char TOLOWER (unsigned char c) -{ return (c >= 'A' && c <= 'Z') ? c - 'A' + 'a' : c; } - - /* HB_NDEBUG disables some sanity checks that are very safe to disable and * should be disabled in production systems. If NDEBUG is defined, enable * HB_NDEBUG; but if it's desirable that normal assert()s (which are very @@ -457,41 +391,7 @@ #endif -/* Misc */ - -template class hb_assert_unsigned_t; -template <> class hb_assert_unsigned_t {}; -template <> class hb_assert_unsigned_t {}; -template <> class hb_assert_unsigned_t {}; -template <> class hb_assert_unsigned_t {}; - -template static inline bool -hb_in_range (T u, T lo, T hi) -{ - /* The sizeof() is here to force template instantiation. - * I'm sure there are better ways to do this but can't think of - * one right now. Declaring a variable won't work as HB_UNUSED - * is unusable on some platforms and unused types are less likely - * to generate a warning than unused variables. */ - static_assert ((sizeof (hb_assert_unsigned_t) >= 0), ""); - - /* The casts below are important as if T is smaller than int, - * the subtract results will become a signed int! */ - return (T)(u - lo) <= (T)(hi - lo); -} - -template static inline bool -hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2) -{ - return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2); -} - -template static inline bool -hb_in_ranges (T u, T lo1, T hi1, T lo2, T hi2, T lo3, T hi3) -{ - return hb_in_range (u, lo1, hi1) || hb_in_range (u, lo2, hi2) || hb_in_range (u, lo3, hi3); -} - +/* Flags */ /* Enable bitwise ops on enums marked as flags_t */ /* To my surprise, looks like the function resolver is happy to silently cast @@ -515,7 +415,6 @@ static inline T& operator ^= (T& l, T r) { l = l ^ r; return l; } \ } - /* Useful for set-operations on small enums. * For example, for testing "x ∈ {x1, x2, x3}" use: * (FLAG_UNSAFE(x) & (FLAG(x1) | FLAG(x2) | FLAG(x3))) @@ -575,6 +474,7 @@ #include "hb-debug.hh" #include "hb-dsalgs.hh" #include "hb-mutex-private.hh" +#include "hb-null.hh" #include "hb-object-private.hh" #endif /* HB_PRIVATE_HH */ diff -Nru harfbuzz-1.8.5/src/hb-shape.cc harfbuzz-1.8.8/src/hb-shape.cc --- harfbuzz-1.8.5/src/hb-shape.cc 2018-06-02 22:39:30.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-shape.cc 2018-08-14 16:48:02.000000000 +0000 @@ -32,6 +32,7 @@ #include "hb-shape-plan-private.hh" #include "hb-buffer-private.hh" #include "hb-font-private.hh" +#include "hb-machinery-private.hh" /** * SECTION:hb-shape @@ -45,21 +46,50 @@ * contains the output glyphs and their positions. **/ -static const char **static_shaper_list; + +static void free_static_shaper_list (void); +static const char *nil_shaper_list[] = {nullptr}; + +static struct hb_shaper_list_lazy_loader_t : hb_lazy_loader_t +{ + static inline const char ** create (void) + { + const char **shaper_list = (const char **) calloc (1 + HB_SHAPERS_COUNT, sizeof (const char *)); + if (unlikely (!shaper_list)) + return nullptr; + + const hb_shaper_pair_t *shapers = _hb_shapers_get (); + unsigned int i; + for (i = 0; i < HB_SHAPERS_COUNT; i++) + shaper_list[i] = shapers[i].name; + shaper_list[i] = nullptr; + +#ifdef HB_USE_ATEXIT + atexit (free_static_shaper_list); +#endif + + return shaper_list; + } + static inline void destroy (const char **l) + { + free (l); + } + static inline const char ** get_null (void) + { + return nil_shaper_list; + } +} static_shaper_list; #ifdef HB_USE_ATEXIT static void free_static_shaper_list (void) { -retry: - const char **shaper_list = (const char **) hb_atomic_ptr_get (&static_shaper_list); - if (!hb_atomic_ptr_cmpexch (&static_shaper_list, shaper_list, nullptr)) - goto retry; - - free (shaper_list); + static_shaper_list.free_instance (); } #endif + /** * hb_shape_list_shapers: * @@ -73,35 +103,7 @@ const char ** hb_shape_list_shapers (void) { -retry: - const char **shaper_list = (const char **) hb_atomic_ptr_get (&static_shaper_list); - - if (unlikely (!shaper_list)) - { - /* Not found; allocate one. */ - shaper_list = (const char **) calloc (1 + HB_SHAPERS_COUNT, sizeof (const char *)); - if (unlikely (!shaper_list)) { - static const char *nil_shaper_list[] = {nullptr}; - return nil_shaper_list; - } - - const hb_shaper_pair_t *shapers = _hb_shapers_get (); - unsigned int i; - for (i = 0; i < HB_SHAPERS_COUNT; i++) - shaper_list[i] = shapers[i].name; - shaper_list[i] = nullptr; - - if (!hb_atomic_ptr_cmpexch (&static_shaper_list, nullptr, shaper_list)) { - free (shaper_list); - goto retry; - } - -#ifdef HB_USE_ATEXIT - atexit (free_static_shaper_list); /* First person registers atexit() callback. */ -#endif - } - - return shaper_list; + return static_shaper_list.get_unconst (); } diff -Nru harfbuzz-1.8.5/src/hb-shape-plan.cc harfbuzz-1.8.8/src/hb-shape-plan.cc --- harfbuzz-1.8.5/src/hb-shape-plan.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-shape-plan.cc 2018-08-14 16:48:02.000000000 +0000 @@ -49,11 +49,13 @@ #define HB_SHAPER_PLAN(shaper) \ HB_STMT_START { \ - if (hb_##shaper##_shaper_face_data_ensure (shape_plan->face_unsafe)) { \ - HB_SHAPER_DATA (shaper, shape_plan) = \ + if (hb_##shaper##_shaper_face_data_ensure (shape_plan->face_unsafe)) \ + { \ + /* XXX-MT-bug What happened to *ensure*ing this?!!!! */ \ + HB_SHAPER_DATA (shaper, shape_plan).set_relaxed ( \ HB_SHAPER_DATA_CREATE_FUNC (shaper, shape_plan) (shape_plan, \ user_features, num_user_features, \ - coords, num_coords); \ + coords, num_coords)); \ shape_plan->shaper_func = _hb_##shaper##_shape; \ shape_plan->shaper_name = #shaper; \ return; \ @@ -88,6 +90,31 @@ * hb_shape_plan_t */ +DEFINE_NULL_INSTANCE (hb_shape_plan_t) = +{ + HB_OBJECT_HEADER_STATIC, + + true, /* default_shaper_list */ + nullptr, /* face */ + HB_SEGMENT_PROPERTIES_DEFAULT, /* props */ + + nullptr, /* shaper_func */ + nullptr, /* shaper_name */ + + nullptr, /* user_features */ + 0, /* num_user_featurs */ + + nullptr, /* coords */ + 0, /* num_coords */ + + { +#define HB_SHAPER_IMPLEMENT(shaper) HB_ATOMIC_PTR_INIT (HB_SHAPER_DATA_INVALID), +#include "hb-shaper-list.hh" +#undef HB_SHAPER_IMPLEMENT + }, +}; + + /** * hb_shape_plan_create: (Xconstructor) * @face: @@ -188,30 +215,7 @@ hb_shape_plan_t * hb_shape_plan_get_empty (void) { - static const hb_shape_plan_t _hb_shape_plan_nil = { - HB_OBJECT_HEADER_STATIC, - - true, /* default_shaper_list */ - nullptr, /* face */ - HB_SEGMENT_PROPERTIES_DEFAULT, /* props */ - - nullptr, /* shaper_func */ - nullptr, /* shaper_name */ - - nullptr, /* user_features */ - 0, /* num_user_featurs */ - - nullptr, /* coords */ - 0, /* num_coords */ - - { -#define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_INVALID, -#include "hb-shaper-list.hh" -#undef HB_SHAPER_IMPLEMENT - } - }; - - return const_cast (&_hb_shape_plan_nil); + return const_cast (&Null(hb_shape_plan_t)); } /** @@ -337,7 +341,7 @@ #define HB_SHAPER_EXECUTE(shaper) \ HB_STMT_START { \ - return HB_SHAPER_DATA (shaper, shape_plan) && \ + return HB_SHAPER_DATA (shaper, shape_plan).get () && \ hb_##shaper##_shaper_font_data_ensure (font) && \ _hb_##shaper##_shape (shape_plan, font, buffer, features, num_features); \ } HB_STMT_END @@ -515,7 +519,7 @@ retry: - hb_face_t::plan_node_t *cached_plan_nodes = (hb_face_t::plan_node_t *) hb_atomic_ptr_get (&face->shape_plans); + hb_face_t::plan_node_t *cached_plan_nodes = face->shape_plans.get (); /* Don't look for plan in the cache if there were variation coordinates XXX Fix me. */ if (!hb_coords_present (coords, num_coords)) @@ -550,7 +554,8 @@ node->shape_plan = shape_plan; node->next = cached_plan_nodes; - if (!hb_atomic_ptr_cmpexch (&face->shape_plans, cached_plan_nodes, node)) { + if (unlikely (!face->shape_plans.cmpexch (cached_plan_nodes, node))) + { hb_shape_plan_destroy (shape_plan); free (node); goto retry; diff -Nru harfbuzz-1.8.5/src/hb-shape-plan-private.hh harfbuzz-1.8.8/src/hb-shape-plan-private.hh --- harfbuzz-1.8.5/src/hb-shape-plan-private.hh 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-shape-plan-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -51,6 +51,7 @@ struct hb_shaper_data_t shaper_data; }; +DECLARE_NULL_INSTANCE (hb_shape_plan_t); #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS \ , const hb_feature_t *user_features \ diff -Nru harfbuzz-1.8.5/src/hb-shaper.cc harfbuzz-1.8.8/src/hb-shaper.cc --- harfbuzz-1.8.5/src/hb-shaper.cc 2018-06-02 22:39:30.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-shaper.cc 2018-08-14 16:48:02.000000000 +0000 @@ -26,7 +26,7 @@ #include "hb-private.hh" #include "hb-shaper-private.hh" -#include "hb-atomic-private.hh" +#include "hb-machinery-private.hh" static const hb_shaper_pair_t all_shapers[] = { @@ -36,51 +36,28 @@ }; -/* Thread-safe, lock-free, shapers */ +static void free_static_shapers (void); -static const hb_shaper_pair_t *static_shapers; - -#ifdef HB_USE_ATEXIT -static -void free_static_shapers (void) -{ -retry: - hb_shaper_pair_t *shapers = (hb_shaper_pair_t *) hb_atomic_ptr_get (&static_shapers); - if (!hb_atomic_ptr_cmpexch (&static_shapers, shapers, nullptr)) - goto retry; - - if (unlikely (shapers != all_shapers)) - free ((void *) shapers); -} -#endif - -const hb_shaper_pair_t * -_hb_shapers_get (void) +static struct hb_shapers_lazy_loader_t : hb_lazy_loader_t { -retry: - hb_shaper_pair_t *shapers = (hb_shaper_pair_t *) hb_atomic_ptr_get (&static_shapers); - - if (unlikely (!shapers)) + static inline hb_shaper_pair_t *create (void) { char *env = getenv ("HB_SHAPER_LIST"); - if (!env || !*env) { - (void) hb_atomic_ptr_cmpexch (&static_shapers, nullptr, &all_shapers[0]); - return (const hb_shaper_pair_t *) all_shapers; - } + if (!env || !*env) + return nullptr; - /* Not found; allocate one. */ - shapers = (hb_shaper_pair_t *) calloc (1, sizeof (all_shapers)); - if (unlikely (!shapers)) { - (void) hb_atomic_ptr_cmpexch (&static_shapers, nullptr, &all_shapers[0]); - return (const hb_shaper_pair_t *) all_shapers; - } + hb_shaper_pair_t *shapers = (hb_shaper_pair_t *) calloc (1, sizeof (all_shapers)); + if (unlikely (!shapers)) + return nullptr; memcpy (shapers, all_shapers, sizeof (all_shapers)); /* Reorder shaper list to prefer requested shapers. */ unsigned int i = 0; char *end, *p = env; - for (;;) { + for (;;) + { end = strchr (p, ','); if (!end) end = p + strlen (p); @@ -102,15 +79,32 @@ p = end + 1; } - if (!hb_atomic_ptr_cmpexch (&static_shapers, nullptr, shapers)) { - free (shapers); - goto retry; - } - #ifdef HB_USE_ATEXIT - atexit (free_static_shapers); /* First person registers atexit() callback. */ + atexit (free_static_shapers); #endif + + return shapers; + } + static inline void destroy (const hb_shaper_pair_t *p) + { + free ((void *) p); + } + static inline const hb_shaper_pair_t *get_null (void) + { + return all_shapers; } +} static_shapers; - return shapers; +#ifdef HB_USE_ATEXIT +static +void free_static_shapers (void) +{ + static_shapers.free_instance (); +} +#endif + +const hb_shaper_pair_t * +_hb_shapers_get (void) +{ + return static_shapers.get_unconst (); } diff -Nru harfbuzz-1.8.5/src/hb-shaper-impl-private.hh harfbuzz-1.8.8/src/hb-shaper-impl-private.hh --- harfbuzz-1.8.5/src/hb-shaper-impl-private.hh 2018-05-08 09:55:16.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-shaper-impl-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -36,7 +36,7 @@ #ifdef HB_SHAPER -#define HB_SHAPER_DATA_GET(object) HB_SHAPER_DATA (HB_SHAPER, object) +#define HB_SHAPER_DATA_GET(object) HB_SHAPER_DATA (HB_SHAPER, object).get () #endif diff -Nru harfbuzz-1.8.5/src/hb-shaper-private.hh harfbuzz-1.8.8/src/hb-shaper-private.hh --- harfbuzz-1.8.5/src/hb-shaper-private.hh 2018-07-31 17:40:18.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-shaper-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -54,9 +54,9 @@ /* Means: tried but failed to create. */ #define HB_SHAPER_DATA_INVALID ((void *) -1) -#define HB_SHAPER_DATA_TYPE_NAME(shaper, object) hb_##shaper##_shaper_##object##_data_t +#define HB_SHAPER_DATA_TYPE_NAME(shaper, object) hb_##shaper##_##object##_data_t #define HB_SHAPER_DATA_TYPE(shaper, object) struct HB_SHAPER_DATA_TYPE_NAME(shaper, object) -#define HB_SHAPER_DATA_INSTANCE(shaper, object, instance) (* (HB_SHAPER_DATA_TYPE(shaper, object) **) &(instance)->shaper_data.shaper) +#define HB_SHAPER_DATA_INSTANCE(shaper, object, instance) (* reinterpret_cast *> (&(instance)->shaper_data.shaper)) #define HB_SHAPER_DATA(shaper, object) HB_SHAPER_DATA_INSTANCE(shaper, object, object) #define HB_SHAPER_DATA_CREATE_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_create #define HB_SHAPER_DATA_DESTROY_FUNC(shaper, object) _hb_##shaper##_shaper_##object##_data_destroy @@ -72,7 +72,7 @@ HB_SHAPER_DATA_ENSURE_FUNC (shaper, object) (hb_##object##_t *object) #define HB_SHAPER_DATA_DESTROY(shaper, object) \ - if (HB_SHAPER_DATA_TYPE (shaper, object) *data = HB_SHAPER_DATA (shaper, object)) \ + if (HB_SHAPER_DATA_TYPE (shaper, object) *data = HB_SHAPER_DATA (shaper, object).get ()) \ if (data != HB_SHAPER_DATA_INVALID && data != HB_SHAPER_DATA_SUCCEEDED) \ HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data); @@ -84,16 +84,24 @@ HB_SHAPER_DATA_ENSURE_FUNC(shaper, object) (hb_##object##_t *object) \ {\ retry: \ - HB_SHAPER_DATA_TYPE (shaper, object) *data = (HB_SHAPER_DATA_TYPE (shaper, object) *) hb_atomic_ptr_get (&HB_SHAPER_DATA (shaper, object)); \ + HB_SHAPER_DATA_TYPE (shaper, object) *data = HB_SHAPER_DATA (shaper, object).get (); \ if (likely (data) && !(condition)) { \ - /* Note that evaluating condition above can be dangerous if another thread \ + /* XXX-MT-bug \ + * Note that evaluating condition above can be dangerous if another thread \ * got here first and destructed data. That's, as always, bad use pattern. \ * If you modify the font (change font size), other threads must not be \ - * using it at the same time. */ \ + * using it at the same time. However, since this check is delayed to \ + * when one actually tries to shape something, this is a XXX race condition \ + * (and the only know we have that I know of) right now. Ie. you modify the \ + * font size in one thread, then (supposedly safely) try to use it from two \ + * or more threads and BOOM! I'm not sure how to fix this. We want RCU. \ + * Maybe when it doesn't matter when we finally implement AAT shaping, as + * this (condition) is currently only used by hb-coretext. */ \ /* Drop and recreate. */ \ /* If someone dropped it in the mean time, throw it away and don't touch it. \ * Otherwise, destruct it. */ \ - if (hb_atomic_ptr_cmpexch (&HB_SHAPER_DATA (shaper, object), data, nullptr)) { \ + if (likely (HB_SHAPER_DATA (shaper, object).cmpexch (data, nullptr))) \ + { \ HB_SHAPER_DATA_DESTROY_FUNC (shaper, object) (data); \ } \ goto retry; \ @@ -102,7 +110,7 @@ data = HB_SHAPER_DATA_CREATE_FUNC (shaper, object) (object); \ if (unlikely (!data)) \ data = (HB_SHAPER_DATA_TYPE (shaper, object) *) HB_SHAPER_DATA_INVALID; \ - if (!hb_atomic_ptr_cmpexch (&HB_SHAPER_DATA (shaper, object), nullptr, data)) { \ + if (unlikely (!HB_SHAPER_DATA (shaper, object).cmpexch (nullptr, data))) { \ if (data && \ data != HB_SHAPER_DATA_INVALID && \ data != HB_SHAPER_DATA_SUCCEEDED) \ @@ -116,7 +124,7 @@ /* For embedding in face / font / ... */ struct hb_shaper_data_t { -#define HB_SHAPER_IMPLEMENT(shaper) void *shaper; +#define HB_SHAPER_IMPLEMENT(shaper) hb_atomic_ptr_t shaper; #include "hb-shaper-list.hh" #undef HB_SHAPER_IMPLEMENT }; diff -Nru harfbuzz-1.8.5/src/hb-static.cc harfbuzz-1.8.8/src/hb-static.cc --- harfbuzz-1.8.5/src/hb-static.cc 2018-07-23 21:43:33.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-static.cc 2018-08-14 16:48:02.000000000 +0000 @@ -25,8 +25,11 @@ */ #include "hb-private.hh" -#include "hb-face-private.hh" + #include "hb-open-type-private.hh" +#include "hb-ot-layout-common-private.hh" + +#include "hb-face-private.hh" #include "hb-ot-head-table.hh" #include "hb-ot-maxp-table.hh" @@ -35,10 +38,15 @@ hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {}; /*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {}; +DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF}; +DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00}; +DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00}; + + void hb_face_t::load_num_glyphs (void) const { - OT::hb_sanitize_context_t c = OT::hb_sanitize_context_t(); + hb_sanitize_context_t c = hb_sanitize_context_t (); c.set_num_glyphs (0); /* So we don't recurse ad infinitum. */ hb_blob_t *maxp_blob = c.reference_table (this); const OT::maxp *maxp_table = maxp_blob->as (); @@ -49,7 +57,7 @@ void hb_face_t::load_upem (void) const { - hb_blob_t *head_blob = OT::hb_sanitize_context_t().reference_table (this); + hb_blob_t *head_blob = hb_sanitize_context_t ().reference_table (this); const OT::head *head_table = head_blob->as (); upem = head_table->get_upem (); hb_blob_destroy (head_blob); diff -Nru harfbuzz-1.8.5/src/hb-subset.cc harfbuzz-1.8.8/src/hb-subset.cc --- harfbuzz-1.8.5/src/hb-subset.cc 2018-07-23 05:43:25.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-subset.cc 2018-08-14 16:48:02.000000000 +0000 @@ -78,12 +78,12 @@ static bool _subset (hb_subset_plan_t *plan) { - hb_blob_t *source_blob = OT::hb_sanitize_context_t().reference_table (plan->source); + hb_blob_t *source_blob = hb_sanitize_context_t ().reference_table (plan->source); const TableType *table = source_blob->as (); hb_tag_t tag = TableType::tableTag; hb_bool_t result = false; - if (table != &Null(TableType)) + if (source_blob->data) { result = table->subset(plan); } else { @@ -157,14 +157,14 @@ if (unlikely (!buf)) return nullptr; - OT::hb_serialize_context_t c (buf, face_length); + hb_serialize_context_t c (buf, face_length); OT::OpenTypeFontFile *f = c.start_serialize (); bool is_cff = data->tables.lsearch (HB_TAG ('C','F','F',' ')) || data->tables.lsearch (HB_TAG ('C','F','F','2')); hb_tag_t sfnt_tag = is_cff ? OT::OpenTypeFontFile::CFFTag : OT::OpenTypeFontFile::TrueTypeTag; - OT::Supplier tags_supplier (&data->tables[0].tag, table_count, sizeof (data->tables[0])); - OT::Supplier blobs_supplier (&data->tables[0].blob, table_count, sizeof (data->tables[0])); + Supplier tags_supplier (&data->tables[0].tag, table_count, sizeof (data->tables[0])); + Supplier blobs_supplier (&data->tables[0].blob, table_count, sizeof (data->tables[0])); bool ret = f->serialize_single (&c, sfnt_tag, tags_supplier, diff -Nru harfbuzz-1.8.5/src/hb-subset-glyf.cc harfbuzz-1.8.8/src/hb-subset-glyf.cc --- harfbuzz-1.8.5/src/hb-subset-glyf.cc 2018-07-23 05:18:01.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-subset-glyf.cc 2018-08-14 16:48:02.000000000 +0000 @@ -292,7 +292,7 @@ hb_blob_t **glyf_prime, /* OUT */ hb_blob_t **loca_prime /* OUT */) { - hb_blob_t *glyf_blob = OT::hb_sanitize_context_t().reference_table (plan->source); + hb_blob_t *glyf_blob = hb_sanitize_context_t ().reference_table (plan->source); const char *glyf_data = hb_blob_get_data(glyf_blob, nullptr); OT::glyf::accelerator_t glyf; diff -Nru harfbuzz-1.8.5/src/hb-ucdn.cc harfbuzz-1.8.8/src/hb-ucdn.cc --- harfbuzz-1.8.5/src/hb-ucdn.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-ucdn.cc 2018-08-14 16:48:02.000000000 +0000 @@ -17,6 +17,7 @@ #include "hb-private.hh" #include "hb-unicode-private.hh" +#include "hb-machinery-private.hh" #include "ucdn.h" @@ -238,31 +239,14 @@ return ucdn_compat_decompose(u, decomposed); } -static hb_unicode_funcs_t *static_ucdn_funcs = nullptr; -#ifdef HB_USE_ATEXIT -static -void free_static_ucdn_funcs (void) -{ -retry: - hb_unicode_funcs_t *ucdn_funcs = (hb_unicode_funcs_t *) hb_atomic_ptr_get (&static_ucdn_funcs); - if (!hb_atomic_ptr_cmpexch (&static_ucdn_funcs, ucdn_funcs, nullptr)) - goto retry; +static void free_static_ucdn_funcs (void); - hb_unicode_funcs_destroy (ucdn_funcs); -} -#endif - -extern "C" HB_INTERNAL -hb_unicode_funcs_t * -hb_ucdn_get_unicode_funcs (void) +static struct hb_ucdn_unicode_funcs_lazy_loader_t : hb_unicode_funcs_lazy_loader_t { -retry: - hb_unicode_funcs_t *funcs = (hb_unicode_funcs_t *) hb_atomic_ptr_get (&static_ucdn_funcs); - - if (unlikely (!funcs)) + static inline hb_unicode_funcs_t *create (void) { - funcs = hb_unicode_funcs_create (nullptr); + hb_unicode_funcs_t *funcs = hb_unicode_funcs_create (nullptr); #define HB_UNICODE_FUNC_IMPLEMENT(name) \ hb_unicode_funcs_set_##name##_func (funcs, hb_ucdn_##name, nullptr, nullptr); @@ -271,15 +255,25 @@ hb_unicode_funcs_make_immutable (funcs); - if (!hb_atomic_ptr_cmpexch (&static_ucdn_funcs, nullptr, funcs)) { - hb_unicode_funcs_destroy (funcs); - goto retry; - } +#ifdef HB_USE_ATEXIT + atexit (free_static_ucdn_funcs); +#endif + + return funcs; + } +} static_ucdn_funcs; #ifdef HB_USE_ATEXIT - atexit (free_static_ucdn_funcs); /* First person registers atexit() callback. */ +static +void free_static_ucdn_funcs (void) +{ + static_ucdn_funcs.free_instance (); +} #endif - }; - return hb_unicode_funcs_reference (funcs); +extern "C" HB_INTERNAL +hb_unicode_funcs_t * +hb_ucdn_get_unicode_funcs (void) +{ + return static_ucdn_funcs.get_unconst (); } diff -Nru harfbuzz-1.8.5/src/hb-unicode.cc harfbuzz-1.8.8/src/hb-unicode.cc --- harfbuzz-1.8.5/src/hb-unicode.cc 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-unicode.cc 2018-08-14 16:48:02.000000000 +0000 @@ -185,7 +185,8 @@ } -const hb_unicode_funcs_t _hb_unicode_funcs_nil = { +DEFINE_NULL_INSTANCE (hb_unicode_funcs_t) = +{ HB_OBJECT_HEADER_STATIC, nullptr, /* parent */ @@ -209,7 +210,7 @@ hb_unicode_funcs_t * hb_unicode_funcs_get_empty (void) { - return const_cast (&_hb_unicode_funcs_nil); + return const_cast (&Null(hb_unicode_funcs_t)); } /** diff -Nru harfbuzz-1.8.5/src/hb-unicode-private.hh harfbuzz-1.8.8/src/hb-unicode-private.hh --- harfbuzz-1.8.5/src/hb-unicode-private.hh 2018-07-17 14:29:54.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-unicode-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -60,7 +60,8 @@ HB_UNICODE_FUNC_IMPLEMENT (hb_script_t, script) \ /* ^--- Add new simple callbacks here */ -struct hb_unicode_funcs_t { +struct hb_unicode_funcs_t +{ hb_object_header_t header; ASSERT_POD (); @@ -263,9 +264,7 @@ #undef HB_UNICODE_FUNC_IMPLEMENT } destroy; }; - - -extern HB_INTERNAL const hb_unicode_funcs_t _hb_unicode_funcs_nil; +DECLARE_NULL_INSTANCE (hb_unicode_funcs_t); /* Modified combining marks */ diff -Nru harfbuzz-1.8.5/src/hb-uniscribe.cc harfbuzz-1.8.8/src/hb-uniscribe.cc --- harfbuzz-1.8.5/src/hb-uniscribe.cc 2018-07-23 05:18:01.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-uniscribe.cc 2018-08-14 16:48:02.000000000 +0000 @@ -190,7 +190,8 @@ } -struct hb_uniscribe_shaper_funcs_t { +struct hb_uniscribe_shaper_funcs_t +{ SIOT ScriptItemizeOpenType; SSOT ScriptShapeOpenType; SPOT ScriptPlaceOpenType; @@ -220,47 +221,49 @@ } } }; -static hb_uniscribe_shaper_funcs_t *uniscribe_funcs; -#ifdef HB_USE_ATEXIT -static inline void -free_uniscribe_funcs (void) -{ -retry: - hb_uniscribe_shaper_funcs_t *local_uniscribe_funcs = - (hb_uniscribe_shaper_funcs_t *) hb_atomic_ptr_get (&uniscribe_funcs); - if (!hb_atomic_ptr_cmpexch (&uniscribe_funcs, local_uniscribe_funcs, nullptr)) - goto retry; - free (uniscribe_funcs); -} -#endif +static void free_static_uniscribe_shaper_funcs (void); -static hb_uniscribe_shaper_funcs_t * -hb_uniscribe_shaper_get_funcs (void) +static struct hb_uniscribe_shaper_funcs_lazy_loader_t : hb_lazy_loader_t { -retry: - hb_uniscribe_shaper_funcs_t *funcs = (hb_uniscribe_shaper_funcs_t *) hb_atomic_ptr_get (&uniscribe_funcs); - - if (unlikely (!funcs)) + static inline hb_uniscribe_shaper_funcs_t *create (void) { - funcs = (hb_uniscribe_shaper_funcs_t *) calloc (1, sizeof (hb_uniscribe_shaper_funcs_t)); + hb_uniscribe_shaper_funcs_t *funcs = (hb_uniscribe_shaper_funcs_t *) calloc (1, sizeof (hb_uniscribe_shaper_funcs_t)); if (unlikely (!funcs)) return nullptr; funcs->init (); - if (!hb_atomic_ptr_cmpexch (&uniscribe_funcs, nullptr, funcs)) { - free (funcs); - goto retry; - } - #ifdef HB_USE_ATEXIT - atexit (free_uniscribe_funcs); /* First person registers atexit() callback. */ + atexit (free_static_uniscribe_shaper_funcs); #endif + + return funcs; + } + static inline void destroy (hb_uniscribe_shaper_funcs_t *p) + { + free ((void *) p); + } + static inline hb_uniscribe_shaper_funcs_t *get_null (void) + { + return nullptr; } +} static_uniscribe_shaper_funcs; + +#ifdef HB_USE_ATEXIT +static +void free_static_uniscribe_shaper_funcs (void) +{ + static_uniscribe_shaper_funcs.free_instance (); +} +#endif - return funcs; +static hb_uniscribe_shaper_funcs_t * +hb_uniscribe_shaper_get_funcs (void) +{ + return static_uniscribe_shaper_funcs.get_unconst (); } @@ -309,7 +312,7 @@ * shaper face data */ -struct hb_uniscribe_shaper_face_data_t { +struct hb_uniscribe_face_data_t { HANDLE fh; hb_uniscribe_shaper_funcs_t *funcs; wchar_t face_name[LF_FACESIZE]; @@ -358,7 +361,7 @@ * full, PS. All of them point to the same name data with our unique name. */ - blob = OT::hb_sanitize_context_t().sanitize_blob (blob); + blob = hb_sanitize_context_t ().sanitize_blob (blob); unsigned int length, new_length, name_str_len; const char *orig_sfnt_data = hb_blob_get_data (blob, &length); @@ -383,7 +386,7 @@ memcpy(new_sfnt_data, orig_sfnt_data, length); - OT::name &name = OT::StructAtOffset (new_sfnt_data, name_table_offset); + OT::name &name = StructAtOffset (new_sfnt_data, name_table_offset); name.format.set (0); name.count.set (ARRAY_LENGTH (name_IDs)); name.stringOffset.set (name.get_size ()); @@ -399,7 +402,7 @@ } /* Copy string data from new_name, converting wchar_t to UTF16BE. */ - unsigned char *p = &OT::StructAfter (name); + unsigned char *p = &StructAfter (name); for (unsigned int i = 0; i < name_str_len; i++) { *p++ = new_name[i] >> 8; @@ -439,10 +442,10 @@ HB_MEMORY_MODE_WRITABLE, nullptr, free); } -hb_uniscribe_shaper_face_data_t * +hb_uniscribe_face_data_t * _hb_uniscribe_shaper_face_data_create (hb_face_t *face) { - hb_uniscribe_shaper_face_data_t *data = (hb_uniscribe_shaper_face_data_t *) calloc (1, sizeof (hb_uniscribe_shaper_face_data_t)); + hb_uniscribe_face_data_t *data = (hb_uniscribe_face_data_t *) calloc (1, sizeof (hb_uniscribe_face_data_t)); if (unlikely (!data)) return nullptr; @@ -479,7 +482,7 @@ } void -_hb_uniscribe_shaper_face_data_destroy (hb_uniscribe_shaper_face_data_t *data) +_hb_uniscribe_shaper_face_data_destroy (hb_uniscribe_face_data_t *data) { RemoveFontMemResourceEx (data->fh); free (data); @@ -490,7 +493,7 @@ * shaper font data */ -struct hb_uniscribe_shaper_font_data_t { +struct hb_uniscribe_font_data_t { HDC hdc; LOGFONTW log_font; HFONT hfont; @@ -508,19 +511,19 @@ lf->lfCharSet = DEFAULT_CHARSET; hb_face_t *face = font->face; - hb_uniscribe_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); + hb_uniscribe_face_data_t *face_data = HB_SHAPER_DATA_GET (face); memcpy (lf->lfFaceName, face_data->face_name, sizeof (lf->lfFaceName)); return true; } -hb_uniscribe_shaper_font_data_t * +hb_uniscribe_font_data_t * _hb_uniscribe_shaper_font_data_create (hb_font_t *font) { if (unlikely (!hb_uniscribe_shaper_face_data_ensure (font->face))) return nullptr; - hb_uniscribe_shaper_font_data_t *data = (hb_uniscribe_shaper_font_data_t *) calloc (1, sizeof (hb_uniscribe_shaper_font_data_t)); + hb_uniscribe_font_data_t *data = (hb_uniscribe_font_data_t *) calloc (1, sizeof (hb_uniscribe_font_data_t)); if (unlikely (!data)) return nullptr; @@ -559,7 +562,7 @@ } void -_hb_uniscribe_shaper_font_data_destroy (hb_uniscribe_shaper_font_data_t *data) +_hb_uniscribe_shaper_font_data_destroy (hb_uniscribe_font_data_t *data) { if (data->hdc) ReleaseDC (nullptr, data->hdc); @@ -574,7 +577,7 @@ hb_uniscribe_font_get_logfontw (hb_font_t *font) { if (unlikely (!hb_uniscribe_shaper_font_data_ensure (font))) return nullptr; - hb_uniscribe_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); + hb_uniscribe_font_data_t *font_data = HB_SHAPER_DATA_GET (font); return &font_data->log_font; } @@ -582,7 +585,7 @@ hb_uniscribe_font_get_hfont (hb_font_t *font) { if (unlikely (!hb_uniscribe_shaper_font_data_ensure (font))) return nullptr; - hb_uniscribe_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); + hb_uniscribe_font_data_t *font_data = HB_SHAPER_DATA_GET (font); return font_data->hfont; } @@ -591,20 +594,20 @@ * shaper shape_plan data */ -struct hb_uniscribe_shaper_shape_plan_data_t {}; +struct hb_uniscribe_shape_plan_data_t {}; -hb_uniscribe_shaper_shape_plan_data_t * +hb_uniscribe_shape_plan_data_t * _hb_uniscribe_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan HB_UNUSED, const hb_feature_t *user_features HB_UNUSED, unsigned int num_user_features HB_UNUSED, const int *coords HB_UNUSED, unsigned int num_coords HB_UNUSED) { - return (hb_uniscribe_shaper_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; + return (hb_uniscribe_shape_plan_data_t *) HB_SHAPER_DATA_SUCCEEDED; } void -_hb_uniscribe_shaper_shape_plan_data_destroy (hb_uniscribe_shaper_shape_plan_data_t *data HB_UNUSED) +_hb_uniscribe_shaper_shape_plan_data_destroy (hb_uniscribe_shape_plan_data_t *data HB_UNUSED) { } @@ -622,8 +625,8 @@ unsigned int num_features) { hb_face_t *face = font->face; - hb_uniscribe_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face); - hb_uniscribe_shaper_font_data_t *font_data = HB_SHAPER_DATA_GET (font); + hb_uniscribe_face_data_t *face_data = HB_SHAPER_DATA_GET (face); + hb_uniscribe_font_data_t *font_data = HB_SHAPER_DATA_GET (font); hb_uniscribe_shaper_funcs_t *funcs = face_data->funcs; /* diff -Nru harfbuzz-1.8.5/src/hb-vector-private.hh harfbuzz-1.8.8/src/hb-vector-private.hh --- harfbuzz-1.8.5/src/hb-vector-private.hh 1970-01-01 00:00:00.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-vector-private.hh 2018-08-14 16:48:02.000000000 +0000 @@ -0,0 +1,238 @@ +/* + * Copyright © 2017,2018 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. + * + * Red Hat Author(s): Behdad Esfahbod + * Google Author(s): Behdad Esfahbod + */ + +#ifndef HB_VECTOR_PRIVATE_HH +#define HB_VECTOR_PRIVATE_HH + +#include "hb-private.hh" + + +template +struct hb_vector_t +{ + unsigned int len; + unsigned int allocated; /* == 0 means allocation failed. */ + Type *arrayZ; + Type static_array[StaticSize]; + + void init (void) + { + len = 0; + allocated = ARRAY_LENGTH (static_array); + arrayZ = static_array; + } + + inline Type& operator [] (unsigned int i) + { + if (unlikely (i >= len)) + return Crap (Type); + return arrayZ[i]; + } + inline const Type& operator [] (unsigned int i) const + { + if (unlikely (i >= len)) + return Null(Type); + return arrayZ[i]; + } + + inline Type *push (void) + { + if (unlikely (!resize (len + 1))) + return &Crap(Type); + return &arrayZ[len - 1]; + } + inline Type *push (const Type& v) + { + Type *p = push (); + *p = v; + return p; + } + + /* Allocate for size but don't adjust len. */ + inline bool alloc (unsigned int size) + { + if (unlikely (!allocated)) + return false; + + if (likely (size <= allocated)) + return true; + + /* Reallocate */ + + unsigned int new_allocated = allocated; + while (size >= new_allocated) + new_allocated += (new_allocated >> 1) + 8; + + Type *new_array = nullptr; + + if (arrayZ == static_array) + { + new_array = (Type *) calloc (new_allocated, sizeof (Type)); + if (new_array) + memcpy (new_array, arrayZ, len * sizeof (Type)); + } + else + { + bool overflows = (new_allocated < allocated) || hb_unsigned_mul_overflows (new_allocated, sizeof (Type)); + if (likely (!overflows)) + new_array = (Type *) realloc (arrayZ, new_allocated * sizeof (Type)); + } + + if (unlikely (!new_array)) + { + allocated = 0; + return false; + } + + arrayZ = new_array; + allocated = new_allocated; + + return true; + } + + inline bool resize (int size_) + { + unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; + if (!alloc (size)) + return false; + + if (size > len) + memset (arrayZ + len, 0, (size - len) * sizeof (*arrayZ)); + + len = size; + return true; + } + + inline void pop (void) + { + if (!len) return; + len--; + } + + inline void remove (unsigned int i) + { + if (unlikely (i >= len)) + return; + memmove (static_cast (&arrayZ[i]), + static_cast (&arrayZ[i + 1]), + (len - i - 1) * sizeof (Type)); + len--; + } + + inline void shrink (int size_) + { + unsigned int size = size_ < 0 ? 0u : (unsigned int) size_; + if (size < len) + len = size; + } + + template + inline Type *find (T v) { + for (unsigned int i = 0; i < len; i++) + if (arrayZ[i] == v) + return &arrayZ[i]; + return nullptr; + } + template + inline const Type *find (T v) const { + for (unsigned int i = 0; i < len; i++) + if (arrayZ[i] == v) + return &arrayZ[i]; + return nullptr; + } + + inline void qsort (int (*cmp)(const void*, const void*)) + { + ::qsort (arrayZ, len, sizeof (Type), cmp); + } + + inline void qsort (void) + { + ::qsort (arrayZ, len, sizeof (Type), Type::cmp); + } + + inline void qsort (unsigned int start, unsigned int end) + { + ::qsort (arrayZ + start, end - start, sizeof (Type), Type::cmp); + } + + template + inline Type *lsearch (const T &x) + { + for (unsigned int i = 0; i < len; i++) + if (0 == this->arrayZ[i].cmp (&x)) + return &arrayZ[i]; + return nullptr; + } + + template + inline Type *bsearch (const T &x) + { + unsigned int i; + return bfind (x, &i) ? &arrayZ[i] : nullptr; + } + template + inline const Type *bsearch (const T &x) const + { + unsigned int i; + return bfind (x, &i) ? &arrayZ[i] : nullptr; + } + template + inline bool bfind (const T &x, unsigned int *i) const + { + int min = 0, max = (int) this->len - 1; + while (min <= max) + { + int mid = (min + max) / 2; + int c = this->arrayZ[mid].cmp (&x); + if (c < 0) + max = mid - 1; + else if (c > 0) + min = mid + 1; + else + { + *i = mid; + return true; + } + } + if (max < 0 || (max < (int) this->len && this->arrayZ[max].cmp (&x) > 0)) + max++; + *i = max; + return false; + } + + inline void fini (void) + { + if (arrayZ != static_array) + free (arrayZ); + arrayZ = nullptr; + allocated = len = 0; + } +}; + + +#endif /* HB_VECTOR_PRIVATE_HH */ diff -Nru harfbuzz-1.8.5/src/hb-version.h harfbuzz-1.8.8/src/hb-version.h --- harfbuzz-1.8.5/src/hb-version.h 2018-08-01 21:48:10.000000000 +0000 +++ harfbuzz-1.8.8/src/hb-version.h 2018-08-14 17:57:55.000000000 +0000 @@ -38,9 +38,9 @@ #define HB_VERSION_MAJOR 1 #define HB_VERSION_MINOR 8 -#define HB_VERSION_MICRO 5 +#define HB_VERSION_MICRO 8 -#define HB_VERSION_STRING "1.8.5" +#define HB_VERSION_STRING "1.8.8" #define HB_VERSION_ATLEAST(major,minor,micro) \ ((major)*10000+(minor)*100+(micro) <= \ diff -Nru harfbuzz-1.8.5/src/main.cc harfbuzz-1.8.8/src/main.cc --- harfbuzz-1.8.5/src/main.cc 2018-07-23 05:48:16.000000000 +0000 +++ harfbuzz-1.8.8/src/main.cc 2018-08-14 16:48:02.000000000 +0000 @@ -53,7 +53,7 @@ hb_blob_t *font_blob = hb_sanitize_context_t().sanitize_blob (blob); const OpenTypeFontFile* sanitized = font_blob->as (); - if (sanitized == &Null(OpenTypeFontFile)) + if (!font_blob->data) { printf ("Sanitization of the file wasn't successful. Exit"); return 1; diff -Nru harfbuzz-1.8.5/src/Makefile.in harfbuzz-1.8.8/src/Makefile.in --- harfbuzz-1.8.5/src/Makefile.in 2018-08-01 21:47:09.000000000 +0000 +++ harfbuzz-1.8.8/src/Makefile.in 2018-08-14 17:57:46.000000000 +0000 @@ -246,7 +246,7 @@ hb-buffer-serialize.cc hb-buffer.cc hb-common.cc hb-debug.hh \ hb-dsalgs.hh hb-face-private.hh hb-face.cc hb-font-private.hh \ hb-font.cc hb-iter-private.hh hb-map-private.hh hb-map.cc \ - hb-machinery-private.hh hb-mutex-private.hh \ + hb-machinery-private.hh hb-mutex-private.hh hb-null.hh \ hb-object-private.hh hb-open-file-private.hh \ hb-open-type-private.hh hb-ot-color-cbdt-table.hh \ hb-ot-cmap-table.hh hb-ot-glyf-table.hh hb-ot-hdmx-table.hh \ @@ -259,21 +259,22 @@ hb-shape-plan.cc hb-shaper-list.hh hb-shaper-impl-private.hh \ hb-shaper-private.hh hb-shaper.cc hb-static.cc \ hb-string-array.hh hb-unicode-private.hh hb-unicode.cc \ - hb-utf-private.hh hb-warning.cc hb-buffer-deserialize-json.hh \ - hb-buffer-deserialize-text.hh hb-aat-layout.cc \ - hb-aat-layout-common-private.hh hb-aat-layout-ankr-table.hh \ - hb-aat-layout-bsln-table.hh hb-aat-layout-feat-table.hh \ - hb-aat-layout-kerx-table.hh hb-aat-layout-morx-table.hh \ - hb-aat-layout-trak-table.hh hb-aat-layout-private.hh \ - hb-aat-ltag-table.hh hb-ot-font.cc hb-ot-layout.cc \ - hb-ot-layout-base-table.hh hb-ot-layout-common-private.hh \ - hb-ot-layout-gdef-table.hh hb-ot-layout-gpos-table.hh \ - hb-ot-layout-gsubgpos-private.hh hb-ot-layout-gsub-table.hh \ - hb-ot-layout-jstf-table.hh hb-ot-layout-private.hh \ - hb-ot-color.cc hb-ot-color-colr-table.hh \ - hb-ot-color-cpal-table.hh hb-ot-color-sbix-table.hh \ - hb-ot-color-svg-table.hh hb-ot-map.cc hb-ot-map-private.hh \ - hb-ot-math.cc hb-ot-math-table.hh hb-ot-shape.cc \ + hb-vector-private.hh hb-utf-private.hh hb-warning.cc \ + hb-buffer-deserialize-json.hh hb-buffer-deserialize-text.hh \ + hb-aat-layout.cc hb-aat-layout-common-private.hh \ + hb-aat-layout-ankr-table.hh hb-aat-layout-bsln-table.hh \ + hb-aat-layout-feat-table.hh hb-aat-layout-kerx-table.hh \ + hb-aat-layout-morx-table.hh hb-aat-layout-trak-table.hh \ + hb-aat-layout-private.hh hb-aat-ltag-table.hh hb-ot-font.cc \ + hb-ot-layout.cc hb-ot-layout-base-table.hh \ + hb-ot-layout-common-private.hh hb-ot-layout-gdef-table.hh \ + hb-ot-layout-gpos-table.hh hb-ot-layout-gsubgpos-private.hh \ + hb-ot-layout-gsub-table.hh hb-ot-layout-jstf-table.hh \ + hb-ot-layout-private.hh hb-ot-color.cc \ + hb-ot-color-colr-table.hh hb-ot-color-cpal-table.hh \ + hb-ot-color-sbix-table.hh hb-ot-color-svg-table.hh \ + hb-ot-map.cc hb-ot-map-private.hh hb-ot-math.cc \ + hb-ot-math-table.hh hb-ot-shape.cc \ hb-ot-shape-complex-arabic.cc \ hb-ot-shape-complex-arabic-fallback.hh \ hb-ot-shape-complex-arabic-private.hh \ @@ -447,7 +448,7 @@ hb-buffer-serialize.cc hb-buffer.cc hb-common.cc hb-debug.hh \ hb-dsalgs.hh hb-face-private.hh hb-face.cc hb-font-private.hh \ hb-font.cc hb-iter-private.hh hb-map-private.hh hb-map.cc \ - hb-machinery-private.hh hb-mutex-private.hh \ + hb-machinery-private.hh hb-mutex-private.hh hb-null.hh \ hb-object-private.hh hb-open-file-private.hh \ hb-open-type-private.hh hb-ot-color-cbdt-table.hh \ hb-ot-cmap-table.hh hb-ot-glyf-table.hh hb-ot-hdmx-table.hh \ @@ -460,21 +461,22 @@ hb-shape-plan.cc hb-shaper-list.hh hb-shaper-impl-private.hh \ hb-shaper-private.hh hb-shaper.cc hb-static.cc \ hb-string-array.hh hb-unicode-private.hh hb-unicode.cc \ - hb-utf-private.hh hb-warning.cc hb-buffer-deserialize-json.hh \ - hb-buffer-deserialize-text.hh hb-aat-layout.cc \ - hb-aat-layout-common-private.hh hb-aat-layout-ankr-table.hh \ - hb-aat-layout-bsln-table.hh hb-aat-layout-feat-table.hh \ - hb-aat-layout-kerx-table.hh hb-aat-layout-morx-table.hh \ - hb-aat-layout-trak-table.hh hb-aat-layout-private.hh \ - hb-aat-ltag-table.hh hb-ot-font.cc hb-ot-layout.cc \ - hb-ot-layout-base-table.hh hb-ot-layout-common-private.hh \ - hb-ot-layout-gdef-table.hh hb-ot-layout-gpos-table.hh \ - hb-ot-layout-gsubgpos-private.hh hb-ot-layout-gsub-table.hh \ - hb-ot-layout-jstf-table.hh hb-ot-layout-private.hh \ - hb-ot-color.cc hb-ot-color-colr-table.hh \ - hb-ot-color-cpal-table.hh hb-ot-color-sbix-table.hh \ - hb-ot-color-svg-table.hh hb-ot-map.cc hb-ot-map-private.hh \ - hb-ot-math.cc hb-ot-math-table.hh hb-ot-shape.cc \ + hb-vector-private.hh hb-utf-private.hh hb-warning.cc \ + hb-buffer-deserialize-json.hh hb-buffer-deserialize-text.hh \ + hb-aat-layout.cc hb-aat-layout-common-private.hh \ + hb-aat-layout-ankr-table.hh hb-aat-layout-bsln-table.hh \ + hb-aat-layout-feat-table.hh hb-aat-layout-kerx-table.hh \ + hb-aat-layout-morx-table.hh hb-aat-layout-trak-table.hh \ + hb-aat-layout-private.hh hb-aat-ltag-table.hh hb-ot-font.cc \ + hb-ot-layout.cc hb-ot-layout-base-table.hh \ + hb-ot-layout-common-private.hh hb-ot-layout-gdef-table.hh \ + hb-ot-layout-gpos-table.hh hb-ot-layout-gsubgpos-private.hh \ + hb-ot-layout-gsub-table.hh hb-ot-layout-jstf-table.hh \ + hb-ot-layout-private.hh hb-ot-color.cc \ + hb-ot-color-colr-table.hh hb-ot-color-cpal-table.hh \ + hb-ot-color-sbix-table.hh hb-ot-color-svg-table.hh \ + hb-ot-map.cc hb-ot-map-private.hh hb-ot-math.cc \ + hb-ot-math-table.hh hb-ot-shape.cc \ hb-ot-shape-complex-arabic.cc \ hb-ot-shape-complex-arabic-fallback.hh \ hb-ot-shape-complex-arabic-private.hh \ @@ -1181,6 +1183,7 @@ hb-map.cc \ hb-machinery-private.hh \ hb-mutex-private.hh \ + hb-null.hh \ hb-object-private.hh \ hb-open-file-private.hh \ hb-open-type-private.hh \ @@ -1214,6 +1217,7 @@ hb-string-array.hh \ hb-unicode-private.hh \ hb-unicode.cc \ + hb-vector-private.hh \ hb-utf-private.hh \ hb-warning.cc \ $(NULL) diff -Nru harfbuzz-1.8.5/src/Makefile.sources harfbuzz-1.8.8/src/Makefile.sources --- harfbuzz-1.8.5/src/Makefile.sources 2018-07-26 00:07:11.000000000 +0000 +++ harfbuzz-1.8.8/src/Makefile.sources 2018-08-14 16:48:02.000000000 +0000 @@ -19,6 +19,7 @@ hb-map.cc \ hb-machinery-private.hh \ hb-mutex-private.hh \ + hb-null.hh \ hb-object-private.hh \ hb-open-file-private.hh \ hb-open-type-private.hh \ @@ -52,6 +53,7 @@ hb-string-array.hh \ hb-unicode-private.hh \ hb-unicode.cc \ + hb-vector-private.hh \ hb-utf-private.hh \ hb-warning.cc \ $(NULL)