diff options
author | Mike FABIAN <mike.fabian@basyskom.de> | 2010-06-02 13:51:45 (GMT) |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2010-06-02 13:51:45 (GMT) |
commit | 889e13652e00ba64060e7b62ed3377ea04d44faa (patch) | |
tree | a1facc76e4c2788fb39774869e4f3b2300497380 | |
parent | 85695ff1643be61eb0ef0dbae89c46ebad06c84d (diff) | |
download | Qt-889e13652e00ba64060e7b62ed3377ea04d44faa.zip Qt-889e13652e00ba64060e7b62ed3377ea04d44faa.tar.gz Qt-889e13652e00ba64060e7b62ed3377ea04d44faa.tar.bz2 |
Changes: add patch for artificial emboldening
Details:
Fixes http://bugreports.qt.nokia.com/browse/QTBUG-10596
Patch taken from
https://bugzilla.novell.com/show_bug.cgi?id=374066
https://bugzillafiles.novell.org/attachment.cgi?id=232442
and
http://code.google.com/p/gentoo-taiwan/source/browse/trunk/x11-libs/qt-gui/files/synthetic-bold-4.5.diff?spec=svn298&r=298
and slightly edited.
Moving the two lines concerning the underlining is unrelated to the
emboldening but seems to make sense anyway, the comment "//underline
metrics" seems to be misplaced before the "if (FT_IS_SCALABLE(face)) {|
The hunk:
@@ -789,6 +794,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph
}
FT_GlyphSlot slot = face->glyph;
+ if (embolden) FT_GlyphSlot_Embolden(slot);
int left = slot->metrics.horiBearingX;
int right = slot->metrics.horiBearingX + slot->metrics.width;
int top = slot->metrics.horiBearingY;
seems to be logical but it is apparently not used when running
my test program, i.e. synthetic emboldening in my test program
works even without this hunk.
Merge-request: 635
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
-rw-r--r-- | src/gui/text/qfontengine_ft.cpp | 15 | ||||
-rw-r--r-- | src/gui/text/qfontengine_ft_p.h | 1 |
2 files changed, 13 insertions, 3 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 449dffd..9056012 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -58,6 +58,7 @@ #include <ft2build.h> #include FT_FREETYPE_H #include FT_OUTLINE_H +#include FT_SYNTHESIS_H #include FT_TRUETYPE_TABLES_H #include FT_TYPE1_TABLES_H #include FT_GLYPH_H @@ -617,6 +618,7 @@ QFontEngineFT::QFontEngineFT(const QFontDef &fd) cache_cost = 100; kerning_pairs_loaded = false; transform = false; + embolden = false; antialias = true; freetype = 0; default_load_flags = FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH; @@ -679,10 +681,7 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format) FT_Face face = lockFace(); - //underline metrics if (FT_IS_SCALABLE(face)) { - line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale)); - underline_position = QFixed::fromFixed(-FT_MulFix(face->underline_position, face->size->metrics.y_scale)); bool fake_oblique = (fontDef.style != QFont::StyleNormal) && !(face->style_flags & FT_STYLE_FLAG_ITALIC); if (fake_oblique) matrix.xy = 0x10000*3/10; @@ -690,6 +689,12 @@ bool QFontEngineFT::init(FaceId faceId, bool antialias, GlyphFormat format) freetype->matrix = matrix; if (fake_oblique) transform = true; + // fake bold + if ((fontDef.weight == QFont::Bold) && !(face->style_flags & FT_STYLE_FLAG_BOLD)) + embolden = true; + // underline metrics + line_thickness = QFixed::fromFixed(FT_MulFix(face->underline_thickness, face->size->metrics.y_scale)); + underline_position = QFixed::fromFixed(-FT_MulFix(face->underline_position, face->size->metrics.y_scale)); } else { // copied from QFontEngineQPF // ad hoc algorithm @@ -789,6 +794,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyphMetrics(QGlyphSet *set, uint glyph } FT_GlyphSlot slot = face->glyph; + if (embolden) FT_GlyphSlot_Embolden(slot); int left = slot->metrics.horiBearingX; int right = slot->metrics.horiBearingX + slot->metrics.width; int top = slot->metrics.horiBearingY; @@ -934,6 +940,7 @@ QFontEngineFT::Glyph *QFontEngineFT::loadGlyph(QGlyphSet *set, uint glyph, Glyph return 0; FT_GlyphSlot slot = face->glyph; + if (embolden) FT_GlyphSlot_Embolden(slot); FT_Library library = qt_getFreetype(); info.xOff = TRUNC(ROUND(slot->advance.x)); @@ -1209,6 +1216,8 @@ int QFontEngineFT::synthesized() const int s = 0; if ((fontDef.style != QFont::StyleNormal) && !(freetype->face->style_flags & FT_STYLE_FLAG_ITALIC)) s = SynthesizedItalic; + if ((fontDef.weight == QFont::Bold) && !(freetype->face->style_flags & FT_STYLE_FLAG_BOLD)) + s |= SynthesizedBold; if (fontDef.stretch != 100 && FT_IS_SCALABLE(freetype->face)) s |= SynthesizedStretch; return s; diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index 12b7da8..2f05a8b 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -304,6 +304,7 @@ protected: bool antialias; bool transform; + bool embolden; SubpixelAntialiasingType subpixelType; int lcdFilterType; bool canUploadGlyphsToServer; |