Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: third_party/harfbuzz-ng/src/hb-coretext.cc

Issue 1580513002: Roll HarfBuzz to 1.1.3 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-coretext.h ('k') | third_party/harfbuzz-ng/src/hb-face.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/harfbuzz-ng/src/hb-coretext.cc
diff --git a/third_party/harfbuzz-ng/src/hb-coretext.cc b/third_party/harfbuzz-ng/src/hb-coretext.cc
index 316d281eacf40337148e785f1605005d4b91f0a2..04cf0570f042807d411f0c28395dc7a446bca6d2 100644
--- a/third_party/harfbuzz-ng/src/hb-coretext.cc
+++ b/third_party/harfbuzz-ng/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
*/
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-coretext.h ('k') | third_party/harfbuzz-ng/src/hb-face.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698