diff options
author | Stefan Wildemann <gta04@metalstrolche.de> | 2019-07-18 22:41:30 +0200 |
---|---|---|
committer | Stefan Wildemann <gta04@metalstrolche.de> | 2019-07-18 22:41:30 +0200 |
commit | ee01a9b3f06dacb3cbf7933564aa7768cd48c9be (patch) | |
tree | 8ee7a7b2fb4387c52d6421b770fea6c736640a0f | |
parent | a75b445e25c2ff936d3d6cbe67aa76c5be12c145 (diff) | |
download | navit-ee01a9b3f06dacb3cbf7933564aa7768cd48c9be.tar.gz |
Fix qt5 font size handlng.
Btw. I found out the navit font size miracle
-rw-r--r-- | navit/graphics/qt5/graphics_qt5.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/navit/graphics/qt5/graphics_qt5.cpp b/navit/graphics/qt5/graphics_qt5.cpp index 343d28a95..79a50976e 100644 --- a/navit/graphics/qt5/graphics_qt5.cpp +++ b/navit/graphics/qt5/graphics_qt5.cpp @@ -174,7 +174,10 @@ static const char* fontfamilies[] = { * @param gr own private context * @param meth fill this structure with correct functions to be called with handle as interface to font * @param font font family e.g. "Arial" - * @param size Font size in ??? + * @param size Font size in 16.6 fractional points @ 300dpi. This is bullsh***. The encoding is freetypes + * 16.6 fixed point format usually giving points. One point is usually 72th part of an inch. But + * navit does not honor dpi correct. It's traditionally used freetype backend is fixed to 300 dpi. + * So this value is (300/72) pixels * @param flags Font flags (currently 1 if bold and 0 if not) * * @return font handle @@ -207,8 +210,9 @@ static struct graphics_font_priv* font_new(struct graphics_priv* gr, struct grap dbg(lvl_debug, "No matching font. Resort to: %s", font_priv->font->family().toUtf8().data()); } - /* No clue why factor 20. Found this by comparing to Freetype rendering. */ - font_priv->font->setPointSize(size / 20); + /* Convert silly font size to pixels. by 64 is to convert fixpoint to int. */ + dbg(lvl_error, "(font %s, %d=%f, %d)", font, size,((float)size)/64.0, ((size * 300) / 72) / 64); + font_priv->font->setPixelSize(((size * 300) / 72) / 64); //font_priv->font->setStyleStrategy(QFont::NoSubpixelAntialias); /* Check for bold font */ if (flags) { |