path: root/src/gui/text/qfontengine_ft.cpp
diff options
authorAllan Sandfeld Jensen <>2014-12-02 17:20:48 +0100
committerAllan Sandfeld Jensen <>2014-12-04 20:30:55 +0100
commit30772c7270aeae784bebe20fe68fad93ea332fb0 (patch)
treef5025c83d620b3fddea1dfd6b34e561611019dac /src/gui/text/qfontengine_ft.cpp
parent82d54a6593321d5aaae223ed8aba34847725c942 (diff)
Fix loading of web fonts with broken hinting bytecode
The Fira Sans font by the Mozilla Foundation has bytecode that goes into an infinite loop. Fortunately FreeType catches the case, but we fail to render any glyphs and spends too long trying the bytecode on every glyph. This patch instead switches the font to auto-hinting when this error is encountered. Task-number: QTBUG-41034 Change-Id: Icd044b41396a06fb435bc189cdbd71d703107de6 Reviewed-by: Konstantin Ritt <> Reviewed-by: Eskil Abrahamsen Blomfeldt <>
Diffstat (limited to 'src/gui/text/qfontengine_ft.cpp')
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 0a8be67e43..8b6c9a192c 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -891,6 +891,13 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph,
// this is an error in the bytecode interpreter, just try to run without it
err = FT_Load_Glyph(face, glyph, load_flags);
+ } else if (err == FT_Err_Execution_Too_Long) {
+ // This is an error in the bytecode, probably a web font made by someone who
+ // didn't test bytecode hinting at all so disable for it for all glyphs.
+ qWarning("load glyph failed due to broken hinting bytecode in font, switching to auto hinting");
+ default_load_flags |= FT_LOAD_FORCE_AUTOHINT;
+ load_flags |= FT_LOAD_FORCE_AUTOHINT;
+ err = FT_Load_Glyph(face, glyph, load_flags);
if (err != FT_Err_Ok) {
qWarning("load glyph failed err=%x face=%p, glyph=%d", err, face, glyph);