Changeset View
Changeset View
Standalone View
Standalone View
kcms/fonts/previewrenderengine.cpp
Show All 18 Lines | |||||
19 | 19 | | |||
20 | 20 | | |||
21 | 21 | | |||
22 | #include "kxftconfig.h" | 22 | #include "kxftconfig.h" | ||
23 | #include "previewrenderengine.h" | 23 | #include "previewrenderengine.h" | ||
24 | #include "Fc.h" | 24 | #include "Fc.h" | ||
25 | 25 | | |||
26 | #include <QApplication> | 26 | #include <QApplication> | ||
27 | #include <QDesktopWidget> | | |||
28 | #include <QX11Info> | 27 | #include <QX11Info> | ||
28 | #include <QScreen> | ||||
29 | 29 | | |||
30 | #include <X11/Xft/Xft.h> | 30 | #include <X11/Xft/Xft.h> | ||
31 | 31 | | |||
32 | #ifdef HAVE_FONTCONFIG | 32 | #ifdef HAVE_FONTCONFIG | ||
33 | 33 | | |||
34 | 34 | | |||
35 | static int qtToFcWeight(int weight) | 35 | static int qtToFcWeight(int weight) | ||
36 | { | 36 | { | ||
▲ Show 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | |||||
123 | } | 123 | } | ||
124 | 124 | | |||
125 | QImage PreviewRenderEngine::drawAutoSize(const QFont &font, const QColor &txt, const QColor &bgnd, const QString &text) | 125 | QImage PreviewRenderEngine::drawAutoSize(const QFont &font, const QColor &txt, const QColor &bgnd, const QString &text) | ||
126 | { | 126 | { | ||
127 | const QString& name = font.family(); | 127 | const QString& name = font.family(); | ||
128 | const quint32 style = qtToFcStyle(font); | 128 | const quint32 style = qtToFcStyle(font); | ||
129 | int faceNo = 0; | 129 | int faceNo = 0; | ||
130 | 130 | | |||
131 | double ratio = QApplication::desktop()->screen()->devicePixelRatio(); | 131 | double ratio = QGuiApplication::primaryScreen()->devicePixelRatio(); | ||
132 | double dpi = QX11Info::appDpiY(); | 132 | double dpi = QX11Info::appDpiY(); | ||
133 | 133 | | |||
134 | int fSize((int)(((font.pointSizeF()*dpi*ratio)/72.0)+0.5)); | 134 | int fSize((int)(((font.pointSizeF()*dpi*ratio)/72.0)+0.5)); | ||
135 | 135 | | |||
136 | QImage image(draw(name, style, faceNo, txt, bgnd, fSize, text)); | 136 | QImage image(draw(name, style, faceNo, txt, bgnd, fSize, text)); | ||
137 | image.setDevicePixelRatio(ratio); | 137 | image.setDevicePixelRatio(ratio); | ||
138 | return image; | 138 | return image; | ||
139 | } | 139 | } | ||
140 | 140 | | |||
141 | #endif // HAVE_FONTCONFIG | 141 | #endif // HAVE_FONTCONFIG |