From 9d2edfe5248fce8b16693fad8304f94a1f101bab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Sat, 29 Nov 2014 21:15:07 +0000 Subject: Fix build due to source incompatible change with FreeType 2.5.4 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit http://git.savannah.gnu.org/cgit/freetype/freetype2.git/commit/?id=b3500af717010137046ec4076d1e1c0641e33727 ../gui/text/qfontengine_ft.cpp: In member function ‘QFontEngineFT::Glyph* QFontEngineFT::loadGlyph(QFontEngineFT::QGlyphSet*, uint, QFixed, QFontEngine::GlyphFormat, bool) const’: ../gui/text/qfontengine_ft.cpp:1126:39: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] for (int x = 0; x < slot->bitmap.width; x++) { Change-Id: Idb58f9e5895aac8c02163870d7c7d4a49237086b Reviewed-by: Konstantin Ritt Reviewed-by: Thiago Macieira Reviewed-by: Shawn Rutledge --- src/gui/text/qfontengine_ft.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/gui/text/qfontengine_ft.cpp') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 8191629003..44c0a50bfc 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1123,7 +1123,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, while (h--) { uint *dd = (uint *)dst; *dd++ = 0; - for (int x = 0; x < slot->bitmap.width; x++) { + for (int x = 0; x < static_cast(slot->bitmap.width); x++) { uint a = ((src[x >> 3] & (0x80 >> (x & 7))) ? 0xffffff : 0x000000); *dd++ = a; } @@ -1134,7 +1134,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, } else if (vfactor != 1) { while (h--) { uint *dd = (uint *)dst; - for (int x = 0; x < slot->bitmap.width; x++) { + for (int x = 0; x < static_cast(slot->bitmap.width); x++) { uint a = ((src[x >> 3] & (0x80 >> (x & 7))) ? 0xffffff : 0x000000); *dd++ = a; } @@ -1143,7 +1143,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, } } else { while (h--) { - for (int x = 0; x < slot->bitmap.width; x++) { + for (int x = 0; x < static_cast(slot->bitmap.width); x++) { unsigned char a = ((src[x >> 3] & (0x80 >> (x & 7))) ? 0xff : 0x00); dst[x] = a; } -- cgit v1.2.3 From e7e6d6f95a029abb52dcbb541bc333fa05cc4929 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Tue, 2 Dec 2014 13:28:08 +0000 Subject: QFontEngine_FT: Don't check for null after dereferencing. Must have been a copy paste mistake, the check is used in other places to make sure we don't unlockFace() without a lockFace(), but here we're certain lockFace() was called first. Makes Coverity happy. Change-Id: I679129727b29a40d780f4fa903f44f7cbc9ec8cf Reviewed-by: Friedemann Kleint Reviewed-by: Konstantin Ritt --- src/gui/text/qfontengine_ft.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/gui/text/qfontengine_ft.cpp') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 44c0a50bfc..e2c8f905b9 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1771,8 +1771,7 @@ glyph_metrics_t QFontEngineFT::alphaMapBoundingBox(glyph_t glyph, QFixed subPixe overall.x = TRUNC(left); overall.y = -TRUNC(top); overall.xoff = TRUNC(ROUND(face->glyph->advance.x)); - if (face) - unlockFace(); + unlockFace(); } return overall; } -- cgit v1.2.3 From 1edc7554deb557e3045076336e4b036109906db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Martins?= Date: Wed, 26 Nov 2014 10:12:55 +0000 Subject: FreeType: Fix font rendering with fonts with embedded bitmaps Only reproduced with Windows font Calibri. This font has both outline (vector) and bitmap glyphs. QFontEngine_FT has an hack to get metrics from EBLC table, but this might fail, resulting in a 0 ascender and descender, meaning QFontMetrics::height() will be 0, meaning totally broken text. This patch checks for that failure, and fallbacks to the outline metrics instead of the bitmap ones. Task-number: QTBUG-42898 Change-Id: If33fc3404d0c7f84557f8c4a5ae71b30f78d60a7 Reviewed-by: Konstantin Ritt Reviewed-by: Friedemann Kleint Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qfontengine_ft.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/gui/text/qfontengine_ft.cpp') diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index e2c8f905b9..0a8be67e43 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -762,8 +762,10 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format, face->face_flags &= ~FT_FACE_FLAG_SCALABLE; FT_Select_Size(face, i); - metrics.ascender = face->size->metrics.ascender; - metrics.descender = face->size->metrics.descender; + if (face->size->metrics.ascender + face->size->metrics.descender > 0) { + metrics.ascender = face->size->metrics.ascender; + metrics.descender = face->size->metrics.descender; + } FT_Set_Char_Size(face, xsize, ysize, 0, 0); face->face_flags |= FT_FACE_FLAG_SCALABLE; -- cgit v1.2.3 From 30772c7270aeae784bebe20fe68fad93ea332fb0 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 2 Dec 2014 17:20:48 +0100 Subject: 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 --- src/gui/text/qfontengine_ft.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/gui/text/qfontengine_ft.cpp') 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 load_flags |= FT_LOAD_FORCE_AUTOHINT; 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); -- cgit v1.2.3