[HarfBuzz] harfbuzz: Branch 'master' - 4 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Fri Nov 29 16:02:24 PST 2013
src/hb-coretext.cc | 35 +++++++++++++++++++++++++++++++++++
src/hb-fallback-shape.cc | 10 ++++++++++
src/hb-ot-layout-common-private.hh | 3 ++-
3 files changed, 47 insertions(+), 1 deletion(-)
New commits:
commit c8213c6198abff97822e29a6d565722cfbb43832
Author: Khaled Hosny <khaledhosny.eglug.org>
Date: Fri Nov 29 19:01:56 2013 -0500
[coretext] 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.
diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index ba80136..951fc82 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -651,6 +651,41 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
for (unsigned int i = 0; i < num_runs; i++) {
CTRunRef run = (CTRunRef) CFArrayGetValueAtIndex (glyph_runs, i);
+ /* 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.
+ */
+ CFRange range = CTRunGetStringRange (run);
+ CFDictionaryRef attributes = CTRunGetAttributes (run);
+ CTFontRef run_ct_font = static_cast<CTFontRef>(CFDictionaryGetValue (attributes, kCTFontAttributeName));
+ CGFontRef run_cg_font = CTFontCopyGraphicsFont (run_ct_font, 0);
+ CGFontRef cg_font = CTFontCopyGraphicsFont (font_data->ct_font, 0);
+ if (!CFEqual (run_cg_font, cg_font)) {
+ CFRelease (run_cg_font);
+ CFRelease (cg_font);
+ for (CFIndex j = 0; j < range.length; 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 = range.location + j;
+
+ info->mask = advance;
+ info->var1.u32 = 0;
+ info->var2.u32 = 0;
+
+ buffer->len++;
+ }
+ continue;
+ }
+
+ CFRelease (run_cg_font);
+ CFRelease (cg_font);
+
unsigned int num_glyphs = CTRunGetGlyphCount (run);
if (num_glyphs == 0)
continue;
commit 63bae73aefb0e5988ef6975f1ed38e040e50e91d
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 26 22:57:24 2013 -0500
[fallback] Add TODO note
diff --git a/src/hb-fallback-shape.cc b/src/hb-fallback-shape.cc
index 1a1fcfb..b894a4a 100644
--- a/src/hb-fallback-shape.cc
+++ b/src/hb-fallback-shape.cc
@@ -95,6 +95,16 @@ _hb_fallback_shape (hb_shape_plan_t *shape_plan HB_UNUSED,
const hb_feature_t *features HB_UNUSED,
unsigned int num_features HB_UNUSED)
{
+ /* TODO
+ *
+ * - Apply fallback kern.
+ * - Handle Variation Selectors?
+ * - Apply normalization?
+ *
+ * This will make the fallback shaper into a dumb "TrueType"
+ * shaper which many people unfortunately still request.
+ */
+
hb_codepoint_t space;
font->get_glyph (' ', 0, &space);
commit e1ebf01d0cf3df55bb9137136e2d0c9630e7bd78
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 26 18:00:35 2013 -0500
Minor
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 2fd1193..02d0d0f 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -377,7 +377,7 @@ struct FeatureParamsStylisticSet
return TRACE_RETURN (c->check_struct (this));
}
- USHORT minorVersion; /* (set to 0): This corresponds to a âminorâ
+ USHORT version; /* (set to 0): This corresponds to a âminorâ
* version number. Additional data may be
* added to the end of this Feature Parameters
* table in the future. */
commit a182dbc9e4e51fa7990c4aea3eaa425a061b29c7
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Tue Nov 26 17:53:41 2013 -0500
Minor
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index 367db95..2fd1193 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -400,6 +400,7 @@ struct FeatureParamsStylisticSet
DEFINE_SIZE_STATIC (4);
};
+/* http://www.microsoft.com/typography/otspec/features_ae.htm#cv01-cv99 */
struct FeatureParamsCharacterVariants
{
inline bool sanitize (hb_sanitize_context_t *c) {
More information about the HarfBuzz
mailing list