[HarfBuzz] harfbuzz: Branch 'master'
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon Jan 11 04:28:58 PST 2016
src/hb-coretext.cc | 45 ++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 40 insertions(+), 5 deletions(-)
New commits:
commit a39ff95fce39226e80850ff251cb34a7aad12bd7
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Jan 11 12:28:37 2016 +0000
[coretext] Speed up CoreText font fallback
Fixes https://code.google.com/p/chromium/issues/detail?id=547912
diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 316d281..04cf057 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -176,6 +176,43 @@ _hb_coretext_shaper_font_data_create (hb_font_t *font)
return NULL;
}
+ /* Create font copy with cascade list that has LastResort first; this speeds up CoreText
+ * font fallback which we don't need anyway. */
+ {
+ // TODO Handle allocation failures?
+ CTFontDescriptorRef last_resort = CTFontDescriptorCreateWithNameAndSize(CFSTR("LastResort"), 0);
+ CFArrayRef cascade_list = CFArrayCreate (kCFAllocatorDefault,
+ (const void **) &last_resort,
+ 1,
+ &kCFTypeArrayCallBacks);
+ CFRelease (last_resort);
+ CFDictionaryRef attributes = CFDictionaryCreate (kCFAllocatorDefault,
+ (const void **) &kCTFontCascadeListAttribute,
+ (const void **) &cascade_list,
+ 1,
+ &kCFTypeDictionaryKeyCallBacks,
+ &kCFTypeDictionaryValueCallBacks);
+ CFRelease (cascade_list);
+
+ CTFontDescriptorRef new_font_desc = CTFontDescriptorCreateWithAttributes (attributes);
+ CFRelease (attributes);
+
+ CTFontRef new_ct_font = CTFontCreateCopyWithAttributes (data->ct_font, 0.0, NULL, new_font_desc);
+ if (new_ct_font)
+ {
+ CFRelease (data->ct_font);
+ data->ct_font = new_ct_font;
+ }
+ else
+ DEBUG_MSG (CORETEXT, font, "Font copy with empty cascade list failed");
+ }
+
+ if (unlikely (!data->ct_font)) {
+ DEBUG_MSG (CORETEXT, font, "Font CTFontCreateWithGraphicsFont() failed");
+ free (data);
+ return NULL;
+ }
+
return data;
}
@@ -847,11 +884,9 @@ resize_and_retry:
* However, even that wouldn't work if we were passed in the CGFont to
* begin with.
*
- * Webkit uses a slightly different approach: it installs LastResort
- * as fallback chain, and then checks PS name of used font against
- * LastResort. That one is safe for any font except for LastResort,
- * as opposed to ours, which can fail if we are using any uninstalled
- * font that has the same name as an installed font.
+ * We might switch to checking PS name against "LastResort". That would
+ * be safe for all fonts except for those named "Last Resort". Might be
+ * better than what we have right now.
*
* See: http://github.com/behdad/harfbuzz/pull/36
*/
More information about the HarfBuzz
mailing list