summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>2014-04-07 13:22:12 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-08 09:49:04 +0200
commit118494aeda916a63dd94474442f9dbf7b2ad7ff5 (patch)
tree88704b4d05b034abf01872bd837bec6eb212fe74
parent30e6d442ff6fd140e18fca7c5b203b87507854c8 (diff)
HB-NG on Mac: Fix PDF in end of string
The CoreText engine will remove the PDF token from the end of the string (instead of producing a zero-width glyph for it), thus the output will be different from the OpenType backend and Qt will get confused. To fix this, we emulate the expected behavior by molding the output in a special case. This is a port of e45c4387ae16627d61e30a58ae901d888d375aa7 from Qt 4. Task-number: QTBUG-38113 Change-Id: Ia0a078e3a60317981d4d5a4ee7e575a1714a1d75 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
-rw-r--r--src/3rdparty/harfbuzz-ng/src/hb-coretext.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc
index 40c06371bd..09f3171b30 100644
--- a/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc
+++ b/src/3rdparty/harfbuzz-ng/src/hb-coretext.cc
@@ -691,11 +691,12 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
CFDictionaryRef attributes = CTRunGetAttributes (run);
CTFontRef run_ct_font = static_cast<CTFontRef>(CFDictionaryGetValue (attributes, kCTFontAttributeName));
CGFontRef run_cg_font = CTFontCopyGraphicsFont (run_ct_font, 0);
+
+ CFRange range = CTRunGetStringRange (run);
if (!CFEqual (run_cg_font, face_data->cg_font))
{
CFRelease (run_cg_font);
- CFRange range = CTRunGetStringRange (run);
buffer->ensure (buffer->len + range.length);
if (buffer->in_error)
FAIL ("Buffer resize failed");
@@ -732,11 +733,16 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
}
CFRelease (run_cg_font);
+ /* CoreText throws away the PDF token, while the OpenType backend will add a zero-advance
+ * glyph for this. We need to make sure the two produce the same output. */
+ UniChar endGlyph = CFStringGetCharacterAtIndex(string_ref, range.location + range.length - 1);
+ bool endWithPDF = endGlyph == 0x202c;
+
unsigned int num_glyphs = CTRunGetGlyphCount (run);
if (num_glyphs == 0)
continue;
- buffer->ensure (buffer->len + num_glyphs);
+ buffer->ensure (buffer->len + num_glyphs + (endWithPDF ? 1 : 0));
scratch = buffer->get_scratch_buffer (&scratch_size);
@@ -783,6 +789,20 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
buffer->len++;
}
+
+ if (endWithPDF) {
+ hb_glyph_info_t *info = &buffer->info[buffer->len];
+
+ info->codepoint = 0xffff;
+ info->cluster = range.location + range.length - 1;
+
+ /* Currently, we do all x-positioning by setting the advance, we never use x-offset. */
+ info->mask = 0;
+ info->var1.u32 = 0;
+ info->var2.u32 = 0;
+
+ buffer->len++;
+ }
}
buffer->clear_positions ();