diff options
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src')
24 files changed, 818 insertions, 201 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/Android.mk b/Build/source/libs/harfbuzz/harfbuzz-src/Android.mk index 2c266221d85..654f0e0fc61 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/Android.mk +++ b/Build/source/libs/harfbuzz/harfbuzz-src/Android.mk @@ -101,6 +101,7 @@ LOCAL_SHARED_LIBRARIES := \ liblog LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/src -LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_ICU -DHAVE_ICU_BUILTIN +LOCAL_CFLAGS += -DHB_NO_MT -DHAVE_OT -DHAVE_ICU -DHAVE_ICU_BUILTIN \ + -Wno-unused-parameter -Wno-missing-field-initializers LOCAL_MODULE:= libharfbuzz_ng include $(BUILD_SHARED_LIBRARY) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog b/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog index ea9485b04c0..ffb7facacd2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog +++ b/Build/source/libs/harfbuzz/harfbuzz-src/ChangeLog @@ -1,3 +1,234 @@ +commit 988165021f8d48dc7120b071d056491256569f4f +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Feb 25 12:23:02 2016 +0900 + + Disable internal buffer variable bookkeeping in NDEBUG builds + + Saves some sweet time and binary size! + + src/Makefile.am | 1 + + src/hb-buffer-private.hh | 30 ++++++++++++++++++++---------- + src/hb-buffer.cc | 6 ++++-- + 3 files changed, 25 insertions(+), 12 deletions(-) + +commit 94dd0bb7e78125994cb7c833a5b03110f1ffc822 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Feb 25 11:31:03 2016 +0900 + + Add blacklist signature for Times New Roman (Bold) Italic on OS X + + src/hb-ot-layout.cc | 2 ++ + 1 file changed, 2 insertions(+) + +commit dd8598c1c7f29fc92253b0cd4e856c1941b1d0c0 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Feb 25 11:20:05 2016 +0900 + + [test] Pass closure to hb_font_set_glyph_func() + + Exercises fix in c335fd7986fe360ab8e1c032c9b988d0d30511eb + + test/api/test-shape.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit e23cf902e91142a10229e3514be4ceee69efde04 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Feb 25 11:11:15 2016 +0900 + + Blacklist GDEF table of timesi.ttf and timesbi.ttf on Win 7 + + See discussion: + https://lists.freedesktop.org/archives/harfbuzz/2016-February/005489.html + + src/hb-ot-layout.cc | 25 +++++++++++++++++++++++++ + 1 file changed, 25 insertions(+) + +commit c335fd7986fe360ab8e1c032c9b988d0d30511eb +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Thu Feb 25 09:16:05 2016 +0900 + + In trampoline implementation of get_glyph(), don't destroy user + data twice! + + src/hb-font.cc | 41 +++++++++++++++++++++++++++-------------- + 1 file changed, 27 insertions(+), 14 deletions(-) + +commit 23335deaad9d4d9824ff41343264514d3f9f7e37 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 20:27:13 2016 +0900 + + [ot-font] Accelerate cmap format4 get_glyph + + src/hb-ot-cmap-table.hh | 111 + ++++++++++++++++++++++++++++-------------------- + src/hb-ot-font.cc | 14 +++++- + 2 files changed, 77 insertions(+), 48 deletions(-) + +commit e0f16a715bc3e621ff21a8be88102e9672630574 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 19:52:36 2016 +0900 + + [ot-font] Towards accelerating get_glyph() + + src/hb-ot-font.cc | 23 ++++++++++++++++++++--- + 1 file changed, 20 insertions(+), 3 deletions(-) + +commit 5473ebfb84c7b6059ac16e04676b363acc51aa00 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 19:32:43 2016 +0900 + + [ot-font] Remove level of indirection in get_glyph_variant + + src/hb-ot-cmap-table.hh | 14 ++------------ + src/hb-ot-font.cc | 13 +++++++++---- + 2 files changed, 11 insertions(+), 16 deletions(-) + +commit 49fe6ecf19522413e79a11a29aa0ffc5bdfcd2f8 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 19:10:06 2016 +0900 + + [TODO] Update + + This file is rather obsolete. Still, give it a refresh. + + TODO | 16 ++-------------- + 1 file changed, 2 insertions(+), 14 deletions(-) + +commit 8b5bc141cd3a6bfcea3c91a882a630426876ceb3 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 19:05:23 2016 +0900 + + Add get_nominal_glyph() and get_variation_glyph() instead of + get_glyph() + + New API: + - hb_font_get_nominal_glyph_func_t + - hb_font_get_variation_glyph_func_t + - hb_font_funcs_set_nominal_glyph_func() + - hb_font_funcs_set_variation_glyph_func() + - hb_font_get_nominal_glyph() + - hb_font_get_variation_glyph() + + Deprecated API: + - hb_font_get_glyph_func_t + - hb_font_funcs_set_glyph_func() + + Clients that implement their own font-funcs are encouraged to replace + their get_glyph() implementation with a get_nominal_glyph() and + get_variation_glyph() pair. The variation version can assume that + variation_selector argument is not zero. + + src/hb-deprecated.h | 10 ++ + src/hb-fallback-shape.cc | 4 +- + src/hb-font-private.hh | 26 +++-- + src/hb-font.cc | 203 + ++++++++++++++++++++++++++++++++++--- + src/hb-font.h | 55 +++++++--- + src/hb-ft.cc | 38 ++++--- + src/hb-ot-font.cc | 57 +++++++---- + src/hb-ot-shape-complex-indic.cc | 8 +- + src/hb-ot-shape-complex-myanmar.cc | 2 +- + src/hb-ot-shape-complex-use.cc | 2 +- + src/hb-ot-shape-fallback.cc | 6 +- + src/hb-ot-shape-normalize.cc | 18 ++-- + src/hb-ot-shape.cc | 6 +- + 13 files changed, 344 insertions(+), 91 deletions(-) + +commit b30a971bf792b9c683c345e1be25c5a5869a113c +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 17:32:22 2016 +0900 + + 1.2.2 + + NEWS | 14 +++++++++++++- + configure.ac | 2 +- + 2 files changed, 14 insertions(+), 2 deletions(-) + +commit af48e3d27c01c538f46f1dc376d994a0c24a8170 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 16:06:40 2016 +0900 + + Fix recent test + + Not sure why the FT functions were returning advance 1024. This + caused failure on drone.io. Switch to hb-ot-font and disable + glyph names. + + test/shaping/tests/cursive-positioning.tests | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +commit 17c831701756bb46300c412fd64b19d67f299c18 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 16:06:23 2016 +0900 + + [tests] Fix for multiple options in test runner scripts + + test/shaping/run-tests.sh | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +commit ebd7431f824c718db6ce5b85e94f2b3911127af4 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 15:53:40 2016 +0900 + + Partially revert 86c68c7a2c971efe8e35b1f1bd99401dc8b688d2 + + That commit moved the advance adjustment for mark positioning to + be applied immediately, instead of doing late before. This breaks + if mark advances are zeroed late, like in Arabic. Also, easier to + hit it in RTL scripts since a single mark with non-zero advance is + enough to hit the bug, whereas in LTR, at least two marks are needed. + + This reopens https://github.com/behdad/harfbuzz/issues/211 + The cursive+mark interaction is broken again. To be fixed in a + different way. + + src/hb-ot-layout-gpos-table.hh | 28 + ++++++++++++---------------- + test/shaping/tests/cursive-positioning.tests | 2 +- + 2 files changed, 13 insertions(+), 17 deletions(-) + +commit 284481b3120963353f5f34ed094f07ffc13480ef +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 15:52:37 2016 +0900 + + Add test for mark positioning in rtl with non-zero mark advance + + Apparently I broke this 86c68c7a2c971efe8e35b1f1bd99401dc8b688d2. + Fix coming. + + .../sha1sum/07f054357ff8638bac3711b422a1e31180bba863.ttf | Bin 0 -> + 848 bytes + test/shaping/tests/cursive-positioning.tests | 1 + + 2 files changed, 1 insertion(+) + +commit 56a84e8dd18c63782b8db3a86e94651dae5bb01b +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 15:50:33 2016 +0900 + + [tests] Allow commenting out tests to be skipped + + test/shaping/run-tests.sh | 4 ++++ + 1 file changed, 4 insertions(+) + +commit 7cfd6cc486f2751d7f78c5008a636d677af4e12f +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Wed Feb 24 12:30:57 2016 +0900 + + [Android.mk] Update with warning flags + + Android.mk | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +commit dabf32a5ad706726412ba5c64e1ea614a707b928 +Author: Behdad Esfahbod <behdad@behdad.org> +Date: Tue Feb 23 15:38:43 2016 +0900 + + 1.2.1 + + NEWS | 13 +++++++++++++ + configure.ac | 2 +- + 2 files changed, 14 insertions(+), 1 deletion(-) + commit 525cc7d28cbe4e8149ddba677224f134dc0a3274 Author: Behdad Esfahbod <behdad@behdad.org> Date: Tue Feb 23 15:19:27 2016 +0900 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/NEWS b/Build/source/libs/harfbuzz/harfbuzz-src/NEWS index b1b63b2c5af..516b7f7ae80 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/NEWS +++ b/Build/source/libs/harfbuzz/harfbuzz-src/NEWS @@ -1,5 +1,59 @@ +Overview of changes leading to 1.2.3 +Thursday, February 25, 2016 +==================================== + +- Blacklist GDEF table of certain versions of Times New Roman (Bold) Italic, + due to bug in glyph class of ASCII double-quote character. This should + address "regression" introduced in 1.2.0 when we switched mark zeroing + in most shapers from BY_UNICODE_LATE to BY_GDEF_LATE. + This fourth release in a week should finally stablize things... + +- hb-ot-font's get_glyph() implementation saw some optimizations. Though, + might be really hard to measure in real-world situations. + +- Also, two rather small API changes: + +We now disable some time-consuming internal bookkeeping if built with NDEBUG +defined. This is a first time that we use NDEBUG to disable debug code. If +there exist production systems that do NOT want to enable NDEBUG, please let +me know and I'll add HB_NDEBUG. + +Added get_nominal_glyph() and get_variation_glyph() instead of get_glyph() + +New API: +- hb_font_get_nominal_glyph_func_t +- hb_font_get_variation_glyph_func_t +- hb_font_funcs_set_nominal_glyph_func() +- hb_font_funcs_set_variation_glyph_func() +- hb_font_get_nominal_glyph() +- hb_font_get_variation_glyph() + +Deprecated API: +- hb_font_get_glyph_func_t +- hb_font_funcs_set_glyph_func() + +Clients that implement their own font-funcs are encouraged to replace +their get_glyph() implementation with a get_nominal_glyph() and +get_variation_glyph() pair. The variation version can assume that +variation_selector argument is not zero. Old (deprecated) functions +will continue working indefinitely using internal gymnastics; it is +just more efficient to use the new functions. + + +Overview of changes leading to 1.2.2 +Wednesday, February 24, 2016 +==================================== + +- Fix regression with mark positioning with fonts that have + non-zero mark advances. This was introduced in 1.2.0 while + trying to make mark and cursive attachments to work together. + I have partially reverted that, so this version is much more + like what we had before. All clients who updated to 1.2.0 + should update to this version. + + Overview of changes leading to 1.2.1 -Friday, February 23, 2016 +Tuesday, February 23, 2016 ==================================== - CoreText: Fix bug with wrong scale if font scale was changed later. diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/TODO b/Build/source/libs/harfbuzz/harfbuzz-src/TODO index e1aa39c4c01..4f37f605b11 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/TODO +++ b/Build/source/libs/harfbuzz/harfbuzz-src/TODO @@ -9,26 +9,14 @@ General fixes: - mask propagation? (when ligation, "or" the masks). -- Warn at compile time (and runtime with HB_DEBUG?) if no Unicode / font - funcs found / set. -- Do proper rounding when scaling from font space? May be a non-issue. - -- Misc features: - * init/medi/fina/isol for non-cursive scripts - - -API issues to fix before 1.0: -============================ +API issues: +=========== - API to accept a list of languages? - Add init_func to font_funcs. Adjust ft. -- hb-ft load_flags issues. - -- Add pkg-config files for glue codes (harfbuzz-glib, etc) - - 'const' for getter APIs? (use mutable internally) - Remove hb_ot_shape_glyphs_closure()? diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac b/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac index d12d4b81413..91ccb70da0a 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac +++ b/Build/source/libs/harfbuzz/harfbuzz-src/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.64]) AC_INIT([HarfBuzz], - [1.2.1], + [1.2.3], [http://bugs.freedesktop.org/enter_bug.cgi?product=harfbuzz], [harfbuzz], [http://harfbuzz.org/]) diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am index bb085ad0030..2a3d6c79aa7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/Makefile.am @@ -130,6 +130,7 @@ pkgconfig_DATA = harfbuzz.pc EXTRA_DIST += harfbuzz.pc.in FUZZING_CPPFLAGS= \ + -DNDEBUG \ -DHB_MAX_NESTING_LEVEL=3 \ -DHB_SANITIZE_MAX_EDITS=3 \ -DHB_BUFFER_MAX_EXPANSION_FACTOR=3 \ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-private.hh index c8eec3c1780..c3184cf7653 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer-private.hh @@ -112,10 +112,6 @@ struct hb_buffer_t { unsigned int serial; - /* These reflect current allocations of the bytes in glyph_info_t's var1 and var2. */ - uint8_t allocated_var_bytes[8]; - const char *allocated_var_owner[8]; - /* Text before / after the main buffer contents. * Always in Unicode, and ordered outward. * Index 0 is for "pre-context", 1 for "post-context". */ @@ -123,11 +119,24 @@ struct hb_buffer_t { hb_codepoint_t context[2][CONTEXT_LENGTH]; unsigned int context_len[2]; - /* Debugging */ + /* Debugging API */ hb_buffer_message_func_t message_func; void *message_data; hb_destroy_func_t message_destroy; +#ifndef NDEBUG + /* Internal debugging. */ + /* These reflect current allocations of the bytes in glyph_info_t's var1 and var2. */ + uint8_t allocated_var_bytes[8]; + const char *allocated_var_owner[8]; + HB_INTERNAL void allocate_var (unsigned int byte_i, unsigned int count, const char *owner); + HB_INTERNAL void deallocate_var (unsigned int byte_i, unsigned int count, const char *owner); + HB_INTERNAL void assert_var (unsigned int byte_i, unsigned int count, const char *owner); + HB_INTERNAL void deallocate_var_all (void); +#else + inline void deallocate_var_all (void) {} +#endif + /* Methods */ @@ -140,11 +149,6 @@ struct hb_buffer_t { { return len - idx; } inline unsigned int next_serial (void) { return serial++; } - HB_INTERNAL void allocate_var (unsigned int byte_i, unsigned int count, const char *owner); - HB_INTERNAL void deallocate_var (unsigned int byte_i, unsigned int count, const char *owner); - HB_INTERNAL void assert_var (unsigned int byte_i, unsigned int count, const char *owner); - HB_INTERNAL void deallocate_var_all (void); - HB_INTERNAL void add (hb_codepoint_t codepoint, unsigned int cluster); HB_INTERNAL void add_info (const hb_glyph_info_t &glyph_info); @@ -256,12 +260,18 @@ struct hb_buffer_t { #define HB_BUFFER_XALLOCATE_VAR(b, func, var, owner) \ b->func (offsetof (hb_glyph_info_t, var) - offsetof(hb_glyph_info_t, var1), \ sizeof (b->info[0].var), owner) +#ifndef NDEBUG #define HB_BUFFER_ALLOCATE_VAR(b, var) \ HB_BUFFER_XALLOCATE_VAR (b, allocate_var, var (), #var) #define HB_BUFFER_DEALLOCATE_VAR(b, var) \ HB_BUFFER_XALLOCATE_VAR (b, deallocate_var, var (), #var) #define HB_BUFFER_ASSERT_VAR(b, var) \ HB_BUFFER_XALLOCATE_VAR (b, assert_var, var (), #var) +#else +#define HB_BUFFER_ALLOCATE_VAR(b, var) +#define HB_BUFFER_DEALLOCATE_VAR(b, var) +#define HB_BUFFER_ASSERT_VAR(b, var) +#endif #endif /* HB_BUFFER_PRIVATE_HH */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc index 5f320bd7eb6..ea2a70d5b07 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-buffer.cc @@ -242,11 +242,11 @@ hb_buffer_t::clear (void) out_info = info; serial = 0; - memset (allocated_var_bytes, 0, sizeof allocated_var_bytes); - memset (allocated_var_owner, 0, sizeof allocated_var_owner); memset (context, 0, sizeof context); memset (context_len, 0, sizeof context_len); + + deallocate_var_all (); } void @@ -661,6 +661,7 @@ hb_buffer_t::guess_segment_properties (void) } +#ifndef NDEBUG static inline void dump_var_allocation (const hb_buffer_t *buffer) { @@ -728,6 +729,7 @@ void hb_buffer_t::deallocate_var_all (void) memset (allocated_var_bytes, 0, sizeof (allocated_var_bytes)); memset (allocated_var_owner, 0, sizeof (allocated_var_owner)); } +#endif /* NDEBUG */ /* Public API */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-deprecated.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-deprecated.h index 30ae4b1caf7..0398dfae60b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-deprecated.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-deprecated.h @@ -44,6 +44,16 @@ HB_BEGIN_DECLS #define HB_BUFFER_FLAGS_DEFAULT HB_BUFFER_FLAG_DEFAULT #define HB_BUFFER_SERIALIZE_FLAGS_DEFAULT HB_BUFFER_SERIALIZE_FLAG_DEFAULT +typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data, + hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data); + +HB_EXTERN void +hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_func_t func, + void *user_data, hb_destroy_func_t destroy); + #endif HB_END_DECLS diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-fallback-shape.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-fallback-shape.cc index b5ebfc04666..e2ad2400167 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-fallback-shape.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-fallback-shape.cc @@ -106,7 +106,7 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED, */ hb_codepoint_t space; - bool has_space = (bool) font->get_glyph (' ', 0, &space); + bool has_space = (bool) font->get_nominal_glyph (' ', &space); buffer->clear_positions (); @@ -123,7 +123,7 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED, pos[i].y_advance = 0; continue; } - font->get_glyph (info[i].codepoint, 0, &info[i].codepoint); + font->get_nominal_glyph (info[i].codepoint, &info[i].codepoint); font->get_glyph_advance_for_direction (info[i].codepoint, direction, &pos[i].x_advance, diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font-private.hh index 9138c236dd6..8da40a992e9 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font-private.hh @@ -44,7 +44,8 @@ #define HB_FONT_FUNCS_IMPLEMENT_CALLBACKS \ HB_FONT_FUNC_IMPLEMENT (font_h_extents) \ HB_FONT_FUNC_IMPLEMENT (font_v_extents) \ - HB_FONT_FUNC_IMPLEMENT (glyph) \ + HB_FONT_FUNC_IMPLEMENT (nominal_glyph) \ + 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_origin) \ @@ -180,16 +181,25 @@ struct hb_font_t { inline bool has_glyph (hb_codepoint_t unicode) { hb_codepoint_t glyph; - return get_glyph (unicode, 0, &glyph); + return get_nominal_glyph (unicode, &glyph); } - inline hb_bool_t get_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) + inline hb_bool_t get_nominal_glyph (hb_codepoint_t unicode, + hb_codepoint_t *glyph) { *glyph = 0; - return klass->get.f.glyph (this, user_data, - unicode, variation_selector, glyph, - klass->user_data.glyph); + return klass->get.f.nominal_glyph (this, user_data, + unicode, glyph, + klass->user_data.nominal_glyph); + } + + inline hb_bool_t get_variation_glyph (hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph) + { + *glyph = 0; + return klass->get.f.variation_glyph (this, user_data, + unicode, variation_selector, glyph, + klass->user_data.variation_glyph); } inline hb_position_t get_glyph_h_advance (hb_codepoint_t glyph) @@ -487,7 +497,7 @@ struct hb_font_t { hb_codepoint_t unichar; if (0 == strncmp (s, "uni", 3) && hb_codepoint_parse (s + 3, len - 3, 16, &unichar) && - get_glyph (unichar, 0, glyph)) + get_nominal_glyph (unichar, glyph)) return true; } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc index c038b108775..4953d00f245 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.cc @@ -93,27 +93,48 @@ hb_font_get_font_v_extents_parent (hb_font_t *font, } static hb_bool_t -hb_font_get_glyph_nil (hb_font_t *font HB_UNUSED, - 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_nominal_glyph_nil (hb_font_t *font HB_UNUSED, + void *font_data HB_UNUSED, + hb_codepoint_t unicode, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) +{ + *glyph = 0; + 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) +{ + return font->parent->get_nominal_glyph (unicode, glyph); +} + +static hb_bool_t +hb_font_get_variation_glyph_nil (hb_font_t *font HB_UNUSED, + void *font_data HB_UNUSED, + hb_codepoint_t unicode, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) { *glyph = 0; return false; } static hb_bool_t -hb_font_get_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_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) { - return font->parent->get_glyph (unicode, variation_selector, glyph); + return font->parent->get_variation_glyph (unicode, variation_selector, glyph); } + static hb_position_t hb_font_get_glyph_h_advance_nil (hb_font_t *font HB_UNUSED, void *font_data HB_UNUSED, @@ -622,7 +643,50 @@ hb_font_get_glyph (hb_font_t *font, hb_codepoint_t unicode, hb_codepoint_t variation_selector, hb_codepoint_t *glyph) { - return font->get_glyph (unicode, variation_selector, glyph); + if (unlikely (variation_selector)) + return font->get_variation_glyph (unicode, variation_selector, glyph); + return font->get_nominal_glyph (unicode, glyph); +} + +/** + * hb_font_get_nominal_glyph: + * @font: a font. + * @unicode: + * @glyph: (out): + * + * + * + * Return value: + * + * Since: 1.2.3 + **/ +hb_bool_t +hb_font_get_nominal_glyph (hb_font_t *font, + hb_codepoint_t unicode, + hb_codepoint_t *glyph) +{ + return font->get_nominal_glyph (unicode, glyph); +} + +/** + * hb_font_get_variation_glyph: + * @font: a font. + * @unicode: + * @variation_selector: + * @glyph: (out): + * + * + * + * Return value: + * + * Since: 1.2.3 + **/ +hb_bool_t +hb_font_get_variation_glyph (hb_font_t *font, + hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph) +{ + return font->get_variation_glyph (unicode, variation_selector, glyph); } /** @@ -1472,3 +1536,127 @@ hb_font_get_ppem (hb_font_t *font, if (x_ppem) *x_ppem = font->x_ppem; if (y_ppem) *y_ppem = font->y_ppem; } + + +/* + * Deprecated get_glyph_func(): + */ + +struct hb_trampoline_closure_t +{ + void *user_data; + hb_destroy_func_t destroy; + unsigned int ref_count; +}; + +template <typename FuncType> +struct hb_trampoline_t +{ + hb_trampoline_closure_t closure; /* Must be first. */ + FuncType func; +}; + +template <typename FuncType> +static hb_trampoline_t<FuncType> * +trampoline_create (FuncType func, + void *user_data, + hb_destroy_func_t destroy) +{ + typedef hb_trampoline_t<FuncType> trampoline_t; + + trampoline_t *trampoline = (trampoline_t *) calloc (1, sizeof (trampoline_t)); + + if (unlikely (!trampoline)) + return NULL; + + trampoline->closure.user_data = user_data; + trampoline->closure.destroy = destroy; + trampoline->closure.ref_count = 1; + trampoline->func = func; + + return trampoline; +} + +static void +trampoline_reference (hb_trampoline_closure_t *closure) +{ + closure->ref_count++; +} + +static void +trampoline_destroy (void *user_data) +{ + hb_trampoline_closure_t *closure = (hb_trampoline_closure_t *) user_data; + + if (--closure->ref_count) + return; + + if (closure->destroy) + closure->destroy (closure->user_data); + free (closure); +} + +typedef hb_trampoline_t<hb_font_get_glyph_func_t> hb_font_get_glyph_trampoline_t; + +static hb_bool_t +hb_font_get_nominal_glyph_trampoline (hb_font_t *font, + void *font_data, + hb_codepoint_t unicode, + hb_codepoint_t *glyph, + void *user_data) +{ + hb_font_get_glyph_trampoline_t *trampoline = (hb_font_get_glyph_trampoline_t *) user_data; + return trampoline->func (font, font_data, unicode, 0, glyph, trampoline->closure.user_data); +} + +static hb_bool_t +hb_font_get_variation_glyph_trampoline (hb_font_t *font, + void *font_data, + hb_codepoint_t unicode, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data) +{ + hb_font_get_glyph_trampoline_t *trampoline = (hb_font_get_glyph_trampoline_t *) user_data; + return trampoline->func (font, font_data, unicode, variation_selector, glyph, trampoline->closure.user_data); +} + +/** + * hb_font_funcs_set_glyph_func: + * @ffuncs: font functions. + * @func: (closure user_data) (destroy destroy) (scope notified): + * @user_data: + * @destroy: + * + * Deprecated. Use hb_font_funcs_set_nominal_glyph_func() and + * hb_font_funcs_set_variation_glyph_func() instead. + * + * Since: 0.9.2 + * Deprecated: 1.2.3 + **/ +void +hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs, + hb_font_get_glyph_func_t func, + void *user_data, hb_destroy_func_t destroy) +{ + hb_font_get_glyph_trampoline_t *trampoline; + + trampoline = trampoline_create (func, user_data, destroy); + if (unlikely (!trampoline)) + { + if (destroy) + destroy (user_data); + return; + } + + hb_font_funcs_set_nominal_glyph_func (ffuncs, + hb_font_get_nominal_glyph_trampoline, + trampoline, + trampoline_destroy); + + trampoline_reference (&trampoline->closure); + hb_font_funcs_set_variation_glyph_func (ffuncs, + hb_font_get_variation_glyph_trampoline, + trampoline, + trampoline_destroy); +} diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h index 82d056c0136..2b6ab50883f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-font.h @@ -116,10 +116,14 @@ typedef hb_font_get_font_extents_func_t hb_font_get_font_h_extents_func_t; typedef hb_font_get_font_extents_func_t hb_font_get_font_v_extents_func_t; -typedef hb_bool_t (*hb_font_get_glyph_func_t) (hb_font_t *font, void *font_data, - hb_codepoint_t unicode, hb_codepoint_t variation_selector, - hb_codepoint_t *glyph, - void *user_data); +typedef hb_bool_t (*hb_font_get_nominal_glyph_func_t) (hb_font_t *font, void *font_data, + hb_codepoint_t unicode, + hb_codepoint_t *glyph, + void *user_data); +typedef hb_bool_t (*hb_font_get_variation_glyph_func_t) (hb_font_t *font, void *font_data, + hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data); typedef hb_position_t (*hb_font_get_glyph_advance_func_t) (hb_font_t *font, void *font_data, @@ -197,7 +201,7 @@ hb_font_funcs_set_font_v_extents_func (hb_font_funcs_t *ffuncs, void *user_data, hb_destroy_func_t destroy); /** - * hb_font_funcs_set_glyph_func: + * hb_font_funcs_set_nominal_glyph_func: * @ffuncs: font functions. * @func: (closure user_data) (destroy destroy) (scope notified): * @user_data: @@ -205,12 +209,28 @@ hb_font_funcs_set_font_v_extents_func (hb_font_funcs_t *ffuncs, * * * - * Since: 0.9.2 + * Since: 1.2.3 + **/ +HB_EXTERN void +hb_font_funcs_set_nominal_glyph_func (hb_font_funcs_t *ffuncs, + hb_font_get_nominal_glyph_func_t func, + void *user_data, hb_destroy_func_t destroy); + +/** + * hb_font_funcs_set_variation_glyph_func: + * @ffuncs: font functions. + * @func: (closure user_data) (destroy destroy) (scope notified): + * @user_data: + * @destroy: + * + * + * + * Since: 1.2.3 **/ HB_EXTERN void -hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs, - hb_font_get_glyph_func_t func, - void *user_data, hb_destroy_func_t destroy); +hb_font_funcs_set_variation_glyph_func (hb_font_funcs_t *ffuncs, + hb_font_get_variation_glyph_func_t func, + void *user_data, hb_destroy_func_t destroy); /** * hb_font_funcs_set_glyph_h_advance_func: @@ -382,9 +402,13 @@ hb_font_get_v_extents (hb_font_t *font, hb_font_extents_t *extents); HB_EXTERN hb_bool_t -hb_font_get_glyph (hb_font_t *font, - hb_codepoint_t unicode, hb_codepoint_t variation_selector, - hb_codepoint_t *glyph); +hb_font_get_nominal_glyph (hb_font_t *font, + hb_codepoint_t unicode, + hb_codepoint_t *glyph); +HB_EXTERN hb_bool_t +hb_font_get_variation_glyph (hb_font_t *font, + hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph); HB_EXTERN hb_position_t hb_font_get_glyph_h_advance (hb_font_t *font, @@ -431,6 +455,13 @@ hb_font_get_glyph_from_name (hb_font_t *font, /* high-level funcs, with fallback */ +/* Calls either hb_font_get_nominal_glyph() if variation_selector is 0, + * otherwise callse hb_font_get_variation_glyph(). */ +HB_EXTERN hb_bool_t +hb_font_get_glyph (hb_font_t *font, + hb_codepoint_t unicode, hb_codepoint_t variation_selector, + hb_codepoint_t *glyph); + HB_EXTERN void hb_font_get_extents_for_direction (hb_font_t *font, hb_direction_t direction, diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc index eed1787dadd..2cad8c26495 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ft.cc @@ -155,21 +155,32 @@ hb_ft_font_get_face (hb_font_t *font) static hb_bool_t -hb_ft_get_glyph (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t unicode, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) - +hb_ft_get_nominal_glyph (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t unicode, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) { const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; - unsigned int g; + unsigned int g = FT_Get_Char_Index (ft_font->ft_face, unicode); + + if (unlikely (!g)) + return false; + + *glyph = g; + return true; +} - if (likely (!variation_selector)) - g = FT_Get_Char_Index (ft_font->ft_face, unicode); - else - g = FT_Face_GetCharVariantIndex (ft_font->ft_face, unicode, variation_selector); +static hb_bool_t +hb_ft_get_variation_glyph (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t unicode, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) +{ + const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data; + unsigned int g = FT_Face_GetCharVariantIndex (ft_font->ft_face, unicode, variation_selector); if (unlikely (!g)) return false; @@ -408,7 +419,8 @@ retry: hb_font_funcs_set_font_h_extents_func (funcs, hb_ft_get_font_h_extents, NULL, NULL); //hb_font_funcs_set_font_v_extents_func (funcs, hb_ft_get_font_v_extents, NULL, NULL); - hb_font_funcs_set_glyph_func (funcs, hb_ft_get_glyph, NULL, NULL); + hb_font_funcs_set_nominal_glyph_func (funcs, hb_ft_get_nominal_glyph, NULL, NULL); + hb_font_funcs_set_variation_glyph_func (funcs, hb_ft_get_variation_glyph, NULL, NULL); hb_font_funcs_set_glyph_h_advance_func (funcs, hb_ft_get_glyph_h_advance, NULL, NULL); hb_font_funcs_set_glyph_v_advance_func (funcs, hb_ft_get_glyph_v_advance, NULL, NULL); //hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ft_get_glyph_h_origin, NULL, NULL); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh index c9161f0ef4c..d7a94a1ef0f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-cmap-table.hh @@ -69,61 +69,78 @@ struct CmapSubtableFormat0 struct CmapSubtableFormat4 { - inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const + struct accelerator_t { - unsigned int segCount; - const USHORT *endCount; - const USHORT *startCount; - const USHORT *idDelta; - const USHORT *idRangeOffset; - const USHORT *glyphIdArray; - unsigned int glyphIdArrayLength; + inline void init (const CmapSubtableFormat4 *subtable) + { + segCount = subtable->segCountX2 / 2; + endCount = subtable->values; + startCount = endCount + segCount + 1; + idDelta = startCount + segCount; + idRangeOffset = idDelta + segCount; + glyphIdArray = idRangeOffset + segCount; + glyphIdArrayLength = (subtable->length - 16 - 8 * segCount) / 2; + } - segCount = this->segCountX2 / 2; - endCount = this->values; - startCount = endCount + segCount + 1; - idDelta = startCount + segCount; - idRangeOffset = idDelta + segCount; - glyphIdArray = idRangeOffset + segCount; - glyphIdArrayLength = (this->length - 16 - 8 * segCount) / 2; - - /* Custom two-array bsearch. */ - int min = 0, max = (int) segCount - 1; - unsigned int i; - while (min <= max) + static inline bool get_glyph_func (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph) { - int mid = (min + max) / 2; - if (codepoint < startCount[mid]) - max = mid - 1; - else if (codepoint > endCount[mid]) - min = mid + 1; + const accelerator_t *thiz = (const accelerator_t *) obj; + + /* Custom two-array bsearch. */ + int min = 0, max = (int) thiz->segCount - 1; + const USHORT *startCount = thiz->startCount; + const USHORT *endCount = thiz->endCount; + unsigned int i; + while (min <= max) + { + int mid = (min + max) / 2; + if (codepoint < startCount[mid]) + max = mid - 1; + else if (codepoint > endCount[mid]) + min = mid + 1; + else + { + i = mid; + goto found; + } + } + return false; + + found: + hb_codepoint_t gid; + unsigned int rangeOffset = thiz->idRangeOffset[i]; + if (rangeOffset == 0) + gid = codepoint + thiz->idDelta[i]; else { - i = mid; - goto found; + /* Somebody has been smoking... */ + unsigned int index = rangeOffset / 2 + (codepoint - thiz->startCount[i]) + i - thiz->segCount; + if (unlikely (index >= thiz->glyphIdArrayLength)) + return false; + gid = thiz->glyphIdArray[index]; + if (unlikely (!gid)) + return false; + gid += thiz->idDelta[i]; } - } - return false; - - found: - hb_codepoint_t gid; - unsigned int rangeOffset = idRangeOffset[i]; - if (rangeOffset == 0) - gid = codepoint + idDelta[i]; - else - { - /* Somebody has been smoking... */ - unsigned int index = rangeOffset / 2 + (codepoint - startCount[i]) + i - segCount; - if (unlikely (index >= glyphIdArrayLength)) - return false; - gid = glyphIdArray[index]; - if (unlikely (!gid)) - return false; - gid += idDelta[i]; + + *glyph = gid & 0xFFFFu; + return true; } - *glyph = gid & 0xFFFFu; - return true; + const USHORT *endCount; + const USHORT *startCount; + const USHORT *idDelta; + const USHORT *idRangeOffset; + const USHORT *glyphIdArray; + unsigned int segCount; + unsigned int glyphIdArrayLength; + }; + + inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const + { + accelerator_t accel; + accel.init (this); + return accel.get_glyph_func (&accel, codepoint, glyph); } inline bool sanitize (hb_sanitize_context_t *c) const @@ -388,7 +405,7 @@ struct CmapSubtableFormat14 } protected: - USHORT format; /* Format number is set to 0. */ + USHORT format; /* Format number is set to 14. */ ULONG lengthZ; /* Byte length of this subtable. */ SortedArrayOf<VariationSelectorRecord, ULONG> record; /* Variation selector records; sorted @@ -416,16 +433,6 @@ struct CmapSubtable } } - inline glyph_variant_t get_glyph_variant (hb_codepoint_t codepoint, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) const - { - switch (u.format) { - case 14: return u.format14.get_glyph_variant(codepoint, variation_selector, glyph); - default: return GLYPH_VARIANT_NOT_FOUND; - } - } - inline bool sanitize (hb_sanitize_context_t *c) const { TRACE_SANITIZE (this); @@ -442,7 +449,7 @@ struct CmapSubtable } } - protected: + public: union { USHORT format; /* Format identifier */ CmapSubtableFormat0 format0; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc index e7b57b88ac8..61c703655f9 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc @@ -201,10 +201,26 @@ struct hb_ot_face_glyf_accelerator_t } }; +typedef bool (*hb_cmap_get_glyph_func_t) (const void *obj, + hb_codepoint_t codepoint, + hb_codepoint_t *glyph); + +template <typename Type> +static inline bool get_glyph_from (const void *obj, + hb_codepoint_t codepoint, + hb_codepoint_t *glyph) +{ + const Type *typed_obj = (const Type *) obj; + return typed_obj->get_glyph (codepoint, glyph); +} + struct hb_ot_face_cmap_accelerator_t { - const OT::CmapSubtable *table; - const OT::CmapSubtable *uvs_table; + hb_cmap_get_glyph_func_t get_glyph_func; + const void *get_glyph_data; + OT::CmapSubtableFormat4::accelerator_t format4_accel; + + const OT::CmapSubtableFormat14 *uvs_table; hb_blob_t *blob; inline void init (hb_face_t *face) @@ -212,7 +228,7 @@ struct hb_ot_face_cmap_accelerator_t this->blob = OT::Sanitizer<OT::cmap>::sanitize (face->reference_table (HB_OT_TAG_cmap)); const OT::cmap *cmap = OT::Sanitizer<OT::cmap>::lock_instance (this->blob); const OT::CmapSubtable *subtable = NULL; - const OT::CmapSubtable *subtable_uvs = NULL; + const OT::CmapSubtableFormat14 *subtable_uvs = NULL; /* 32-bit subtables. */ if (!subtable) subtable = cmap->find_subtable (3, 10); @@ -229,12 +245,30 @@ struct hb_ot_face_cmap_accelerator_t if (!subtable) subtable = &OT::Null(OT::CmapSubtable); /* UVS subtable. */ - if (!subtable_uvs) subtable_uvs = cmap->find_subtable (0, 5); + if (!subtable_uvs) + { + const OT::CmapSubtable *st = cmap->find_subtable (0, 5); + if (st && st->u.format == 14) + subtable_uvs = &st->u.format14; + } /* Meh. */ - if (!subtable_uvs) subtable_uvs = &OT::Null(OT::CmapSubtable); + if (!subtable_uvs) subtable_uvs = &OT::Null(OT::CmapSubtableFormat14); - this->table = subtable; this->uvs_table = subtable_uvs; + + this->get_glyph_data = subtable; + switch (subtable->u.format) { + /* Accelerate format 4 and format 12. */ + default: this->get_glyph_func = get_glyph_from<OT::CmapSubtable>; break; + case 12: this->get_glyph_func = get_glyph_from<OT::CmapSubtableFormat12>; break; + case 4: + { + this->format4_accel.init (&subtable->u.format4); + this->get_glyph_data = &this->format4_accel; + this->get_glyph_func = this->format4_accel.get_glyph_func; + } + break; + } } inline void fini (void) @@ -242,23 +276,26 @@ struct hb_ot_face_cmap_accelerator_t hb_blob_destroy (this->blob); } - inline bool get_glyph (hb_codepoint_t unicode, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph) const + inline bool get_nominal_glyph (hb_codepoint_t unicode, + hb_codepoint_t *glyph) const + { + return this->get_glyph_func (this->get_glyph_data, unicode, glyph); + } + + inline bool get_variation_glyph (hb_codepoint_t unicode, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph) const { - if (unlikely (variation_selector)) + switch (this->uvs_table->get_glyph_variant (unicode, + variation_selector, + glyph)) { - switch (this->uvs_table->get_glyph_variant (unicode, - variation_selector, - glyph)) - { - case OT::GLYPH_VARIANT_NOT_FOUND: return false; - case OT::GLYPH_VARIANT_FOUND: return true; - case OT::GLYPH_VARIANT_USE_DEFAULT: break; - } + case OT::GLYPH_VARIANT_NOT_FOUND: return false; + case OT::GLYPH_VARIANT_FOUND: return true; + case OT::GLYPH_VARIANT_USE_DEFAULT: break; } - return this->table->get_glyph (unicode, glyph); + return get_nominal_glyph (unicode, glyph); } }; @@ -301,16 +338,27 @@ _hb_ot_font_destroy (hb_ot_font_t *ot_font) static hb_bool_t -hb_ot_get_glyph (hb_font_t *font HB_UNUSED, - void *font_data, - hb_codepoint_t unicode, - hb_codepoint_t variation_selector, - hb_codepoint_t *glyph, - void *user_data HB_UNUSED) +hb_ot_get_nominal_glyph (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t unicode, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) + +{ + const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; + return ot_font->cmap.get_nominal_glyph (unicode, glyph); +} +static hb_bool_t +hb_ot_get_variation_glyph (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t unicode, + hb_codepoint_t variation_selector, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) { const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; - return ot_font->cmap.get_glyph (unicode, variation_selector, glyph); + return ot_font->cmap.get_variation_glyph (unicode, variation_selector, glyph); } static hb_position_t @@ -397,7 +445,8 @@ retry: hb_font_funcs_set_font_h_extents_func (funcs, hb_ot_get_font_h_extents, NULL, NULL); hb_font_funcs_set_font_v_extents_func (funcs, hb_ot_get_font_v_extents, NULL, NULL); - hb_font_funcs_set_glyph_func (funcs, hb_ot_get_glyph, NULL, NULL); + hb_font_funcs_set_nominal_glyph_func (funcs, hb_ot_get_nominal_glyph, NULL, NULL); + hb_font_funcs_set_variation_glyph_func (funcs, hb_ot_get_variation_glyph, NULL, NULL); hb_font_funcs_set_glyph_h_advance_func (funcs, hb_ot_get_glyph_h_advance, NULL, NULL); hb_font_funcs_set_glyph_v_advance_func (funcs, hb_ot_get_glyph_v_advance, NULL, NULL); //hb_font_funcs_set_glyph_h_origin_func (funcs, hb_ot_get_glyph_h_origin, NULL, NULL); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh index 59dddcf73cb..bbe390cf7d2 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout-gpos-table.hh @@ -437,22 +437,6 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde o.attach_type() = ATTACH_TYPE_MARK; o.attach_chain() = (int) glyph_pos - (int) buffer->idx; buffer->scratch_flags |= HB_BUFFER_SCRATCH_FLAG_HAS_GPOS_ATTACHMENT; - { - unsigned int i = buffer->idx; - unsigned int j = glyph_pos; - hb_glyph_position_t *pos = buffer->pos; - assert (j < i); - if (HB_DIRECTION_IS_FORWARD (c->direction)) - for (unsigned int k = j; k < i; k++) { - pos[i].x_offset -= pos[k].x_advance; - pos[i].y_offset -= pos[k].y_advance; - } - else - for (unsigned int k = j + 1; k < i + 1; k++) { - pos[i].x_offset += pos[k].x_advance; - pos[i].y_offset += pos[k].y_advance; - } - } buffer->idx++; return_trace (true); @@ -1593,6 +1577,18 @@ propagate_attachment_offsets (hb_glyph_position_t *pos, unsigned int i, hb_direc { pos[i].x_offset += pos[j].x_offset; pos[i].y_offset += pos[j].y_offset; + + assert (j < i); + if (HB_DIRECTION_IS_FORWARD (direction)) + for (unsigned int k = j; k < i; k++) { + pos[i].x_offset -= pos[k].x_advance; + pos[i].y_offset -= pos[k].y_advance; + } + else + for (unsigned int k = j + 1; k < i + 1; k++) { + pos[i].x_offset += pos[k].x_advance; + pos[i].y_offset += pos[k].y_advance; + } } } diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc index adf232bf119..1071d073b83 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-layout.cc @@ -60,6 +60,33 @@ _hb_ot_layout_create (hb_face_t *face) layout->gpos_blob = OT::Sanitizer<OT::GPOS>::sanitize (face->reference_table (HB_OT_TAG_GPOS)); layout->gpos = OT::Sanitizer<OT::GPOS>::lock_instance (layout->gpos_blob); + { + /* + * 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 = hb_blob_get_length (layout->gdef_blob); + unsigned int gsub_len = hb_blob_get_length (layout->gsub_blob); + unsigned int gpos_len = hb_blob_get_length (layout->gpos_blob); + if (0 + || (442 == gdef_len && 42038 == gpos_len && 2874 == gsub_len) /* Windows 7 timesi.ttf */ + || (430 == gdef_len && 40662 == gpos_len && 2874 == gsub_len) /* Windows 7 timesbi.ttf */ + || (490 == gdef_len && 41638 == gpos_len && 3046 == gsub_len) /* OS X 10.11.3 Times New Roman Italic.ttf */ + || (478 == gdef_len && 41902 == gpos_len && 3046 == gsub_len) /* OS X 10.11.3 Times New Roman Bold Italic.ttf */ + ) + { + /* 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 = &OT::Null(OT::GDEF); + } + } + layout->gsub_lookup_count = layout->gsub->get_lookup_count (); layout->gpos_lookup_count = layout->gpos->get_lookup_count (); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc index 21256dec517..c8fc2b5b675 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-indic.cc @@ -493,12 +493,12 @@ struct indic_shape_plan_t hb_codepoint_t glyph = virama_glyph; if (unlikely (virama_glyph == (hb_codepoint_t) -1)) { - if (!config->virama || !font->get_glyph (config->virama, 0, &glyph)) + if (!config->virama || !font->get_nominal_glyph (config->virama, &glyph)) glyph = 0; /* Technically speaking, the spec says we should apply 'locl' to virama too. * Maybe one day... */ - /* Our get_glyph() function needs a font, so we can't get the virama glyph + /* Our get_nominal_glyph() function needs a font, so we can't get the virama glyph * during shape planning... Instead, overwrite it here. It's safe. Don't worry! */ (const_cast<indic_shape_plan_t *> (this))->virama_glyph = glyph; } @@ -1219,7 +1219,7 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, hb_codepoint_t dottedcircle_glyph; - if (!font->get_glyph (0x25CCu, 0, &dottedcircle_glyph)) + if (!font->get_nominal_glyph (0x25CCu, &dottedcircle_glyph)) return; hb_glyph_info_t dottedcircle = {0}; @@ -1803,7 +1803,7 @@ decompose_indic (const hb_ot_shape_normalize_context_t *c, hb_codepoint_t glyph; if (hb_options ().uniscribe_bug_compatible || - (c->font->get_glyph (ab, 0, &glyph) && + (c->font->get_nominal_glyph (ab, &glyph) && indic_plan->pstf.would_substitute (&glyph, 1, c->font->face))) { /* Ok, safe to use Uniscribe-style decomposition. */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-myanmar.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-myanmar.cc index 7b043440e8a..545765d5f1d 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-myanmar.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-myanmar.cc @@ -439,7 +439,7 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, hb_codepoint_t dottedcircle_glyph; - if (!font->get_glyph (0x25CCu, 0, &dottedcircle_glyph)) + if (!font->get_nominal_glyph (0x25CCu, &dottedcircle_glyph)) return; hb_glyph_info_t dottedcircle = {0}; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use.cc index 6fbfe2b5eac..d2b6e63bd3f 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-complex-use.cc @@ -499,7 +499,7 @@ insert_dotted_circles (const hb_ot_shape_plan_t *plan HB_UNUSED, return; hb_glyph_info_t dottedcircle = {0}; - if (!font->get_glyph (0x25CCu, 0, &dottedcircle.codepoint)) + if (!font->get_nominal_glyph (0x25CCu, &dottedcircle.codepoint)) return; dottedcircle.use_category() = hb_use_get_categories (0x25CC); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc index c9cf737f486..ea8312b223b 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-fallback.cc @@ -526,7 +526,7 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan, case t::SPACE_FIGURE: for (char u = '0'; u <= '9'; u++) - if (font->get_glyph (u, 0, &glyph)) + if (font->get_nominal_glyph (u, &glyph)) { pos[i].x_advance = font->get_glyph_h_advance (glyph); break; @@ -534,9 +534,9 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan, break; case t::SPACE_PUNCTUATION: - if (font->get_glyph ('.', 0, &glyph)) + if (font->get_nominal_glyph ('.', &glyph)) pos[i].x_advance = font->get_glyph_h_advance (glyph); - else if (font->get_glyph (',', 0, &glyph)) + else if (font->get_nominal_glyph (',', &glyph)) pos[i].x_advance = font->get_glyph_h_advance (glyph); break; diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-normalize.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-normalize.cc index 3f00b8ee692..107617e81ca 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-normalize.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape-normalize.cc @@ -91,7 +91,7 @@ compose_unicode (const hb_ot_shape_normalize_context_t *c, static inline void set_glyph (hb_glyph_info_t &info, hb_font_t *font) { - font->get_glyph (info.codepoint, 0, &info.glyph_index()); + font->get_nominal_glyph (info.codepoint, &info.glyph_index()); } static inline void @@ -124,10 +124,10 @@ decompose (const hb_ot_shape_normalize_context_t *c, bool shortest, hb_codepoint hb_font_t * const font = c->font; if (!c->decompose (c, ab, &a, &b) || - (b && !font->get_glyph (b, 0, &b_glyph))) + (b && !font->get_nominal_glyph (b, &b_glyph))) return 0; - bool has_a = (bool) font->get_glyph (a, 0, &a_glyph); + bool has_a = (bool) font->get_nominal_glyph (a, &a_glyph); if (shortest && has_a) { /* Output a and b */ output_char (buffer, a, a_glyph); @@ -166,7 +166,7 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor hb_codepoint_t u = buffer->cur().codepoint; hb_codepoint_t glyph; - if (shortest && c->font->get_glyph (u, 0, &glyph)) + if (shortest && c->font->get_nominal_glyph (u, &glyph)) { next_char (buffer, glyph); return; @@ -178,7 +178,7 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor return; } - if (!shortest && c->font->get_glyph (u, 0, &glyph)) + if (!shortest && c->font->get_nominal_glyph (u, &glyph)) { next_char (buffer, glyph); return; @@ -188,7 +188,7 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor { hb_codepoint_t space_glyph; hb_unicode_funcs_t::space_t space_type = buffer->unicode->space_fallback_type (u); - if (space_type != hb_unicode_funcs_t::NOT_SPACE && c->font->get_glyph (0x0020u, 0, &space_glyph)) + if (space_type != hb_unicode_funcs_t::NOT_SPACE && c->font->get_nominal_glyph (0x0020u, &space_glyph)) { _hb_glyph_info_set_unicode_space_fallback_type (&buffer->cur(), space_type); next_char (buffer, space_glyph); @@ -202,7 +202,7 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor /* U+2011 is the only sensible character that is a no-break version of another character * and not a space. The space ones are handled already. Handle this lone one. */ hb_codepoint_t other_glyph; - if (c->font->get_glyph (0x2010u, 0, &other_glyph)) + if (c->font->get_nominal_glyph (0x2010u, &other_glyph)) { next_char (buffer, other_glyph); return; @@ -221,7 +221,7 @@ handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, uns for (; buffer->idx < end - 1 && !buffer->in_error;) { if (unlikely (buffer->unicode->is_variation_selector (buffer->cur(+1).codepoint))) { /* The next two lines are some ugly lines... But work. */ - if (font->get_glyph (buffer->cur().codepoint, buffer->cur(+1).codepoint, &buffer->cur().glyph_index())) + if (font->get_variation_glyph (buffer->cur().codepoint, buffer->cur(+1).codepoint, &buffer->cur().glyph_index())) { buffer->replace_glyphs (2, 1, &buffer->cur().codepoint); } @@ -388,7 +388,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan, buffer->cur().codepoint, &composed) && /* And the font has glyph for the composite. */ - font->get_glyph (composed, 0, &glyph)) + font->get_nominal_glyph (composed, &glyph)) { /* Composes. */ buffer->next_glyph (); /* Copy to out-buffer. */ diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc index 42b921c6e53..2ba9b78a321 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-shape.cc @@ -456,7 +456,7 @@ hb_ot_hide_default_ignorables (hb_ot_shape_context_t *c) return; hb_codepoint_t space; - if (c->font->get_glyph (' ', 0, &space)) + if (c->font->get_nominal_glyph (' ', &space)) { /* Replace default-ignorables with a zero-advance space glyph. */ for (/*continue*/; i < count; i++) @@ -848,12 +848,12 @@ add_char (hb_font_t *font, hb_set_t *glyphs) { hb_codepoint_t glyph; - if (font->get_glyph (u, 0, &glyph)) + if (font->get_nominal_glyph (u, &glyph)) glyphs->add (glyph); if (mirror) { hb_codepoint_t m = unicode->mirroring (u); - if (m != u && font->get_glyph (m, 0, &glyph)) + if (m != u && font->get_nominal_glyph (m, &glyph)) glyphs->add (glyph); } } |