[HarfBuzz] harfbuzz: Branch 'master' - 2 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Thu Feb 25 02:11:59 UTC 2016
src/hb-font.cc | 41 +++++++++++++++++++++++++++--------------
src/hb-ot-layout.cc | 25 +++++++++++++++++++++++++
2 files changed, 52 insertions(+), 14 deletions(-)
New commits:
commit e23cf902e91142a10229e3514be4ceee69efde04
Author: Behdad Esfahbod <behdad at 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
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index adf232b..2be4b20 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -60,6 +60,31 @@ _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 */
+ )
+ {
+ /* 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 ();
commit c335fd7986fe360ab8e1c032c9b988d0d30511eb
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Thu Feb 25 09:16:05 2016 +0900
In trampoline implementation of get_glyph(), don't destroy user data twice!
diff --git a/src/hb-font.cc b/src/hb-font.cc
index 6742b49..4953d00 100644
--- a/src/hb-font.cc
+++ b/src/hb-font.cc
@@ -1546,6 +1546,7 @@ struct hb_trampoline_closure_t
{
void *user_data;
hb_destroy_func_t destroy;
+ unsigned int ref_count;
};
template <typename FuncType>
@@ -1566,23 +1567,30 @@ trampoline_create (FuncType func,
trampoline_t *trampoline = (trampoline_t *) calloc (1, sizeof (trampoline_t));
if (unlikely (!trampoline))
- {
- if (destroy)
- destroy (user_data);
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);
@@ -1634,16 +1642,21 @@ hb_font_funcs_set_glyph_func (hb_font_funcs_t *ffuncs,
hb_font_get_glyph_trampoline_t *trampoline;
trampoline = trampoline_create (func, user_data, destroy);
- if (likely (trampoline))
- hb_font_funcs_set_nominal_glyph_func (ffuncs,
- hb_font_get_nominal_glyph_trampoline,
+ 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);
-
- trampoline = trampoline_create (func, user_data, destroy);
- if (likely (trampoline))
- hb_font_funcs_set_variation_glyph_func (ffuncs,
- hb_font_get_variation_glyph_trampoline,
- trampoline,
- trampoline_destroy);
}
More information about the HarfBuzz
mailing list