Qt 4.8
Functions
qfont_win.cpp File Reference
#include "qfont.h"
#include "qfont_p.h"
#include "qfontengine_p.h"
#include "qtextengine_p.h"
#include "qfontmetrics.h"
#include "qfontinfo.h"
#include "qwidget.h"
#include "qpainter.h"
#include <limits.h>
#include "qt_windows.h"
#include <private/qapplication_p.h>
#include "qapplication.h"
#include <private/qunicodetables_p.h>
#include <qfontdatabase.h>

Go to the source code of this file.

Functions

static float pixelSize (const QFontDef &request, int dpi)
 
static float pointSize (const QFontDef &fd, int dpi)
 
QFont qt_LOGFONTtoQFont (LOGFONT &lf, bool)
 
HDC shared_dc ()
 
QFont::Weight weightFromInteger (int weight)
 

Function Documentation

◆ pixelSize()

static float pixelSize ( const QFontDef request,
int  dpi 
)
inlinestatic

◆ pointSize()

static float pointSize ( const QFontDef fd,
int  dpi 
)
inlinestatic

Definition at line 90 of file qfont_win.cpp.

Referenced by QPlastiqueStyle::drawControl(), QFontFamilyDelegate::paint(), QFontDatabase::pointSizes(), qfontForCocoaFont(), qt_set_x11_resources(), QTextFormatPrivate::resolveFont(), QTextCharFormat::setFont(), QFontFamilyDelegate::sizeHint(), QFontPrivate::smallCapsFontPrivate(), and QFontDatabase::smoothSizes().

91 {
92  float pSize;
93  if (fd.pointSize < 0)
94  pSize = fd.pixelSize * 72. / ((float)dpi);
95  else
96  pSize = fd.pointSize;
97  return pSize;
98 }
qreal pointSize
Definition: qfont_p.h:89
qreal pixelSize
Definition: qfont_p.h:90

◆ qt_LOGFONTtoQFont()

QFont qt_LOGFONTtoQFont ( LOGFONT &  lf,
bool   
)

Definition at line 64 of file qfont_win.cpp.

Referenced by QETWidget::forceUpdate(), qt_init(), and qt_set_windows_font_resources().

65 {
66  QString family = QString::fromWCharArray(lf.lfFaceName);
67  QFont qf(family);
68  qf.setItalic(lf.lfItalic);
69  if (lf.lfWeight != FW_DONTCARE)
70  qf.setWeight(weightFromInteger(lf.lfWeight));
71  int lfh = qAbs(lf.lfHeight);
72  qf.setPointSizeF(lfh * 72.0 / GetDeviceCaps(shared_dc(),LOGPIXELSY));
73  qf.setUnderline(false);
74  qf.setOverline(false);
75  qf.setStrikeOut(false);
76  return qf;
77 }
static QString fromWCharArray(const wchar_t *, int size=-1)
Returns a copy of the string, where the encoding of string depends on the size of wchar...
Definition: qstring.cpp:1019
QFont::Weight weightFromInteger(int weight)
The QString class provides a Unicode character string.
Definition: qstring.h:83
Q_DECL_CONSTEXPR T qAbs(const T &t)
Definition: qglobal.h:1201
The QFont class specifies a font used for drawing text.
Definition: qfont.h:64
HDC shared_dc()

◆ shared_dc()

HDC shared_dc ( )

Definition at line 118 of file qfontengine_win.cpp.

Referenced by qt_LOGFONTtoQFont().

119 {
120  QtHDC *&hdc = local_shared_dc()->localData();
121  if (!hdc)
122  hdc = new QtHDC;
123  return hdc->hdc();
124 }
HDC hdc() const

◆ weightFromInteger()

QFont::Weight weightFromInteger ( int  weight)

Definition at line 142 of file qfontdatabase.cpp.

Referenced by qt_LOGFONTtoQFont().

143 {
144  if (weight < 400)
145  return QFont::Light;
146  else if (weight < 600)
147  return QFont::Normal;
148  else if (weight < 700)
149  return QFont::DemiBold;
150  else if (weight < 800)
151  return QFont::Bold;
152  else
153  return QFont::Black;
154 }