Disable ligatures using existing mechanism in HB, not workaround
This is a partial revert of fef629cd91.
When doing the original fix, I didn't realize that there was a
mechanism for disabling specific OpenType features in Harfbuzz.
This commit reverts the hack to disable GSUB completely and disables
the ligature features instead.
Task-number: QTBUG-44393
Change-Id: I30f0080eb3897f37219df7f2d50843f3a4556e13
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
bb10
parent
bf44f002ca
commit
63b5f5cb98
|
|
@ -573,27 +573,17 @@ _hb_qt_font_get_glyph_from_name(hb_font_t * /*font*/, void * /*font_data*/,
|
|||
|
||||
|
||||
static hb_user_data_key_t _useDesignMetricsKey;
|
||||
static hb_user_data_key_t _ignoreGSUB;
|
||||
|
||||
void hb_qt_font_set_use_design_metrics(hb_font_t *font, uint value)
|
||||
{
|
||||
hb_font_set_user_data(font, &_useDesignMetricsKey, (void *)quintptr(value), NULL, true);
|
||||
}
|
||||
|
||||
void hb_qt_face_set_ignore_gsub(hb_face_t *face, uint value)
|
||||
{
|
||||
hb_face_set_user_data(face, &_ignoreGSUB, (void *)quintptr(value), NULL, true);
|
||||
}
|
||||
|
||||
uint hb_qt_font_get_use_design_metrics(hb_font_t *font)
|
||||
{
|
||||
return quintptr(hb_font_get_user_data(font, &_useDesignMetricsKey));
|
||||
}
|
||||
|
||||
uint hb_qt_face_get_ignore_gsub(hb_face_t *face)
|
||||
{
|
||||
return quintptr(hb_face_get_user_data(face, &_ignoreGSUB));
|
||||
}
|
||||
|
||||
struct _hb_qt_font_funcs_t {
|
||||
_hb_qt_font_funcs_t()
|
||||
|
|
@ -628,14 +618,11 @@ hb_font_funcs_t *hb_qt_get_font_funcs()
|
|||
|
||||
|
||||
static hb_blob_t *
|
||||
_hb_qt_reference_table(hb_face_t *face, hb_tag_t tag, void *user_data)
|
||||
_hb_qt_reference_table(hb_face_t * /*face*/, hb_tag_t tag, void *user_data)
|
||||
{
|
||||
QFontEngine::FaceData *data = static_cast<QFontEngine::FaceData *>(user_data);
|
||||
Q_ASSERT(data);
|
||||
|
||||
if (hb_qt_face_get_ignore_gsub(face) && tag == HB_TAG('G','S','U','B'))
|
||||
return hb_blob_get_empty();
|
||||
|
||||
qt_get_font_table_func_t get_font_table = data->get_font_table;
|
||||
Q_ASSERT(get_font_table);
|
||||
|
||||
|
|
|
|||
|
|
@ -72,9 +72,6 @@ Q_GUI_EXPORT hb_font_t *hb_qt_font_get_for_engine(QFontEngine *fe);
|
|||
Q_GUI_EXPORT void hb_qt_font_set_use_design_metrics(hb_font_t *font, uint value);
|
||||
Q_GUI_EXPORT uint hb_qt_font_get_use_design_metrics(hb_font_t *font);
|
||||
|
||||
Q_GUI_EXPORT void hb_qt_face_set_ignore_gsub(hb_face_t *font, uint value);
|
||||
Q_GUI_EXPORT uint hb_qt_face_get_ignore_gsub(hb_face_t *font);
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QHARFBUZZNG_P_H
|
||||
|
|
|
|||
|
|
@ -1175,16 +1175,19 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si,
|
|||
Q_ASSERT(hb_font);
|
||||
hb_qt_font_set_use_design_metrics(hb_font, option.useDesignMetrics() ? uint(QFontEngine::DesignMetrics) : 0); // ###
|
||||
|
||||
// Ligatures are incompatible with custom letter spacing, so when a letter spacing is set,
|
||||
// we disable them for writing systems where they are purely cosmetic.
|
||||
bool scriptRequiresOpenType = ((script >= QChar::Script_Syriac && script <= QChar::Script_Sinhala)
|
||||
|| script == QChar::Script_Khmer || script == QChar::Script_Nko);
|
||||
hb_face_t *hb_face = hb_font_get_face(hb_font);
|
||||
Q_ASSERT(hb_face);
|
||||
hb_qt_face_set_ignore_gsub(hb_face, hasLetterSpacing && !scriptRequiresOpenType);
|
||||
|
||||
const hb_feature_t features[1] = {
|
||||
{ HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) }
|
||||
};
|
||||
const int num_features = 1;
|
||||
bool dontLigate = hasLetterSpacing && !scriptRequiresOpenType;
|
||||
const hb_feature_t features[5] = {
|
||||
{ HB_TAG('k','e','r','n'), !!kerningEnabled, 0, uint(-1) },
|
||||
{ HB_TAG('l','i','g','a'), !dontLigate, 0, uint(-1) },
|
||||
{ HB_TAG('c','l','i','g'), !dontLigate, 0, uint(-1) },
|
||||
{ HB_TAG('d','l','i','g'), !dontLigate, 0, uint(-1) },
|
||||
{ HB_TAG('h','l','i','g'), !dontLigate, 0, uint(-1) } };
|
||||
const int num_features = dontLigate ? 5 : 1;
|
||||
|
||||
const char *const *shaper_list = Q_NULLPTR;
|
||||
#if defined(Q_OS_DARWIN)
|
||||
|
|
|
|||
Loading…
Reference in New Issue