Fix font fallback handling with Harfbuzz and CoreText

Comparing CGFontRefs is not reliable it seems, CFEqual on them appears
to compare pointers and there's no guarantee that CTFontCopyGraphicsFont
returns the same pointer all the time.

So instead let's compare CTFontRefs, which we keep around and also provide
as input to CoreText shaping.

Task-number: 38363
Change-Id: I6073ea88f0c9f5ebf49d17cba0d76041ade32570
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
Simon Hausmann 2014-04-25 13:12:20 +02:00 committed by The Qt Project
parent 9ab4142551
commit 40b195d0f9

View File

@ -690,13 +690,10 @@ _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))
if (!CFEqual (run_ct_font, font_data->ct_font))
{
CFRelease (run_cg_font);
buffer->ensure (buffer->len + range.length);
if (buffer->in_error)
FAIL ("Buffer resize failed");
@ -731,7 +728,6 @@ _hb_coretext_shape (hb_shape_plan_t *shape_plan,
}
continue;
}
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. */