Darwin: get rid of Harfbuzz/CoreText specific code

once CoreText shaper in Harfbuzz has been disabled, we do not need
the hack-ish enablers to support it

Follows-up 21c242f9fd

Change-Id: I40d598b2c9b57ca7953716a56e4e119b2fc06a9b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
bb10
Konstantin Ritt 2020-03-18 05:36:49 +03:00
parent 1ab2e4baef
commit 7c3700c070
2 changed files with 7 additions and 58 deletions

View File

@ -1642,20 +1642,6 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si,
hb_buffer_clear_contents(buffer);
hb_buffer_add_utf16(buffer, reinterpret_cast<const uint16_t *>(string) + item_pos, item_length, 0, item_length);
#if defined(Q_OS_DARWIN)
// ### temporary workaround for QTBUG-38113
// CoreText throws away the PDF token, while the OpenType backend will replace it with
// a zero-advance glyph. This becomes a real issue when PDF is the last character,
// since it gets treated like if it were a grapheme extender, so we
// temporarily replace it with some visible grapheme starter.
bool endsWithPDF = actualFontEngine->type() == QFontEngine::Mac && string[item_pos + item_length - 1] == 0x202c;
if (Q_UNLIKELY(endsWithPDF)) {
uint num_glyphs;
hb_glyph_info_t *infos = hb_buffer_get_glyph_infos(buffer, &num_glyphs);
infos[num_glyphs - 1].codepoint = '.';
}
#endif
hb_buffer_set_segment_properties(buffer, &props);
uint buffer_flags = HB_BUFFER_FLAG_DEFAULT;
@ -1686,21 +1672,13 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si,
{ HB_TAG('h','l','i','g'), !dontLigate, 0, uint(-1) } };
const int num_features = dontLigate ? 5 : 1;
const char *const *shaper_list = nullptr;
#if defined(Q_OS_DARWIN)
// What's behind QFontEngine::FaceData::user_data isn't compatible between different font engines
// - specifically functions in hb-coretext.cc would run into undefined behavior with data
// from non-CoreText engine. The other shapers works with that engine just fine.
if (actualFontEngine->type() != QFontEngine::Mac) {
static const char *s_shaper_list_without_coretext[] = {
"graphite2",
"ot",
"fallback",
nullptr
};
shaper_list = s_shaper_list_without_coretext;
}
#endif
// whitelist cross-platforms shapers only
static const char *shaper_list[] = {
"graphite2",
"ot",
"fallback",
nullptr
};
bool shapedOk = hb_shape_full(hb_font, buffer, features, num_features, shaper_list);
if (Q_UNLIKELY(!shapedOk)) {
@ -1752,35 +1730,11 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si,
while (str_pos < item_length)
log_clusters[str_pos++] = last_glyph_pos;
#if defined(Q_OS_DARWIN)
if (Q_UNLIKELY(endsWithPDF)) {
int last_glyph_idx = num_glyphs - 1;
g.glyphs[last_glyph_idx] = 0xffff;
g.advances[last_glyph_idx] = QFixed();
g.offsets[last_glyph_idx].x = QFixed();
g.offsets[last_glyph_idx].y = QFixed();
g.attributes[last_glyph_idx].clusterStart = true;
g.attributes[last_glyph_idx].dontPrint = true;
log_clusters[item_length - 1] = glyphs_shaped + last_glyph_idx;
}
#endif
if (Q_UNLIKELY(engineIdx != 0)) {
for (quint32 i = 0; i < num_glyphs; ++i)
g.glyphs[i] |= (engineIdx << 24);
}
#ifdef Q_OS_DARWIN
if (actualFontEngine->type() == QFontEngine::Mac) {
if (actualFontEngine->fontDef.stretch != 100 && actualFontEngine->fontDef.stretch != QFont::AnyStretch) {
QFixed stretch = QFixed(int(actualFontEngine->fontDef.stretch)) / QFixed(100);
for (uint i = 0; i < num_glyphs; ++i)
g.advances[i] *= stretch;
}
}
#endif
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
if (!actualFontEngine->supportsSubPixelPositions() || (actualFontEngine->fontDef.styleStrategy & QFont::ForceIntegerMetrics)) {

View File

@ -282,11 +282,6 @@ void QCoreTextFontEngine::init()
cache_cost = (CTFontGetAscent(ctfont) + CTFontGetDescent(ctfont)) * avgCharWidth.toInt() * 2000;
// HACK hb_coretext requires both CTFont and CGFont but user_data is only void*
Q_ASSERT((void *)(&ctfont + 1) == (void *)&cgFont);
faceData.user_data = &ctfont;
faceData.get_font_table = ct_getSfntTable;
kerningPairsLoaded = false;
}