Resending a patch that actually applies!
>From 35500b9c8fe3ae7b71abb6574ff0bfe08883f991 Mon Sep 17 00:00:00 2001
From: Khaled Hosny <[email protected]>
Date: Mon, 25 Nov 2013 15:28:10 +0200
Subject: [PATCH] Avoid font fallback with CoreText shaper
CoreText does automatic font fallback (AKA "cascading") for characters
not supported by the requested font, and provides no way to turn it off,
so detect if the returned run uses a font other than the requested one
and fill in the buffer with .notdef glyphs instead of random indices
glyph from a different font.
---
src/hb-coretext.cc | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index ba80136..7a726fe 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -685,6 +685,32 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
#undef ALLOCATE_ARRAY
+ /* CoreText does automatic font fallback (AKA "cascading") for characters
+ * not supported by the requested font, and provides no way to turn it off,
+ * so we detect if the returned run uses a font other than the requested
+ * one and fill in the buffer with .notdef glyphs instead of random glyph
+ * indices from a different font.
+ */
+ CFDictionaryRef attributes = CTRunGetAttributes(run);
+ if (!CFEqual(CFDictionaryGetValue(attributes, kCTFontAttributeName), font_data->ct_font)) {
+ for (unsigned int j = 0; j < num_glyphs; j++) {
+ CGGlyph notdef = 0;
+ double advance = CTFontGetAdvancesForGlyphs(font_data->ct_font, kCTFontHorizontalOrientation, ¬def, NULL, 1);
+
+ hb_glyph_info_t *info = &buffer->info[buffer->len];
+
+ info->codepoint = notdef;
+ info->cluster = string_indices[0] + j;
+
+ info->mask = advance;
+ info->var1.u32 = 0;
+ info->var2.u32 = 0;
+
+ buffer->len++;
+ }
+ continue;
+ }
+
double run_width = CTRunGetTypographicBounds (run, range_all, NULL, NULL, NULL);
for (unsigned int j = 0; j < num_glyphs; j++) {
--
1.8.4.1
_______________________________________________
HarfBuzz mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/harfbuzz