path: root/src/gui
diff options
authorEskil Abrahamsen Blomfeldt <>2019-11-18 12:15:48 +0100
committerEskil Abrahamsen Blomfeldt <>2019-11-18 13:34:25 +0100
commite19345987714f4f76c8d7075355980b154adbc44 (patch)
tree727c1a33502230784edcebe5f95ba41393797c5d /src/gui
parent8e8b50b06165903a6d0e3d08737e67be47d5ec3b (diff)
Fix kerning with fractional pixel size
Since most of our APIs for pixel size are integer-based, we would assume it was when passing it to Harfbuzz. But QRawFont (and the internal APIs in Qt and Harfbuzz) support floating point pixel sizes. The result would be that setting e.g. pixel size 20.25 would give the same glyph positions as 20.75, but the glyphs would be some fraction of a pixel larger. Using floats instead should have no impact on the common case where the pixel size is an integer, but it should also enable the other case, where QRawFont is used (or potentially future APIs that do not have the integer limitation.) [ChangeLog][QtGui][Text] Fixed a problem where pixel sizes would be truncated before calculating glyph positions. Fixes: QTBUG-67091 Change-Id: Ib066b1330ddcf52d4b344412e350aa9a60c847ff Reviewed-by: Konstantin Ritt <>
Diffstat (limited to 'src/gui')
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gui/text/qharfbuzzng.cpp b/src/gui/text/qharfbuzzng.cpp
index 9c8582b43d..397e6cc49f 100644
--- a/src/gui/text/qharfbuzzng.cpp
+++ b/src/gui/text/qharfbuzzng.cpp
@@ -695,12 +695,12 @@ _hb_qt_font_create(QFontEngine *fe)
return NULL;
- const int y_ppem = fe->fontDef.pixelSize;
- const int x_ppem = (fe->fontDef.pixelSize * fe->fontDef.stretch) / 100;
+ const qreal y_ppem = fe->fontDef.pixelSize;
+ const qreal x_ppem = (fe->fontDef.pixelSize * fe->fontDef.stretch) / 100.0;
hb_font_set_funcs(font, hb_qt_get_font_funcs(), (void *)fe, NULL);
- hb_font_set_scale(font, QFixed(x_ppem).value(), -QFixed(y_ppem).value());
- hb_font_set_ppem(font, x_ppem, y_ppem);
+ hb_font_set_scale(font, QFixed::fromReal(x_ppem).value(), -QFixed::fromReal(y_ppem).value());
+ hb_font_set_ppem(font, int(x_ppem), int(y_ppem));
hb_font_set_ptem(font, fe->fontDef.pointSize);