summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrançois Andriot <francois.andriot@free.fr>2014-09-16 03:35:26 +0200
committerSlávek Banko <slavek.banko@axis.cz>2015-12-15 19:54:02 +0100
commitfd6922e60b548c4beddc29acedab72563148382b (patch)
tree7dc7442ce50c3e78b91c25fb962374a30af1d971 /src
parentccee6e310341021bcf873ee512ae32b0b2a75c0c (diff)
downloadqt3-fd6922e60b548c4beddc29acedab72563148382b.tar.gz
qt3-fd6922e60b548c4beddc29acedab72563148382b.zip
Fix dpi detection when using xft2
(cherry picked from commit e4b05c8f30bfa0a01adc00a7157bfc41acaaf4a0)
Diffstat (limited to 'src')
-rw-r--r--src/kernel/qfontdatabase_x11.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/kernel/qfontdatabase_x11.cpp b/src/kernel/qfontdatabase_x11.cpp
index 05bdbb8..5b865e6 100644
--- a/src/kernel/qfontdatabase_x11.cpp
+++ b/src/kernel/qfontdatabase_x11.cpp
@@ -1513,13 +1513,25 @@ static double addPatternProps(XftPattern *pattern, const QtFontStyle::Key &key,
convert the pixel size to a point size and request that.
*/
double size_value = request.pixelSize;
+ double dpi = QPaintDevice::x11AppDpiY(fp->screen);
double scale = 1.;
if ( size_value > MAXFONTSIZE_XFT ) {
scale = (double)size_value/(double)MAXFONTSIZE_XFT;
size_value = MAXFONTSIZE_XFT;
}
- size_value = size_value*72./QPaintDevice::x11AppDpiY(fp->screen);
+#ifdef QT_XFT2
+ /*
+ 2006-12-28 If QT is not compiled against xft1, there is no need
+ for the workaround above (confirmed). Thus, in addition, add
+ font pixelsize to the pattern to avoid fontconfig making wrong
+ guesses. Also provide a DPI value for fontconfig so it never
+ attempts to fallback to its default.
+ */
+ XftPatternAddDouble(pattern, XFT_PIXEL_SIZE, size_value);
+ XftPatternAddDouble(pattern, XFT_DPI, dpi);
+#endif
+ size_value = size_value*72./dpi;
XftPatternAddDouble( pattern, XFT_SIZE, size_value );
#ifdef XFT_MATRIX
@@ -1877,6 +1889,11 @@ static QFontEngine *loadFontConfigFont(const QFontPrivate *fp, const QFontDef &r
FcResult result;
FcFontSet *fs = 0;
FcPattern *fsp = 0;
+
+ // Properly conform to fontconfig API. We need to call FcDefaultSubstitute()
+ // before FcFontSort()/FcFontMatch().
+ FcDefaultSubstitute(pattern);
+
if( use_fontsort ) {
fs = FcFontSort(0, pattern, FcFalse, 0, &result);
if (!fs)