Qt 4.8
Classes | Macros | Typedefs | Enumerations | Functions | Variables
qfontengine_win.cpp File Reference
#include "qfontengine_p.h"
#include "qtextengine_p.h"
#include <qglobal.h>
#include "qt_windows.h"
#include <private/qapplication_p.h>
#include <private/qsystemlibrary_p.h>
#include <qpaintdevice.h>
#include <qpainter.h>
#include <limits.h>
#include <qendian.h>
#include <qmath.h>
#include <qthreadstorage.h>
#include <private/qunicodetables_p.h>
#include <qbitmap.h>
#include <private/qpainter_p.h>
#include "qpaintengine.h"
#include "qvarlengtharray.h"
#include <private/qpaintengine_raster_p.h>
#include <private/qnativeimage_p.h>
#include "qguifunctions_wince.h"
#include <qdebug.h>

Go to the source code of this file.

Classes

class  QtHDC
 

Macros

#define _WIN32_WINNT   0x0500
 
#define GGO_UNHINTED   0x0100
 
#define MAKE_TAG(ch1, ch2, ch3, ch4)
 
#define SPI_GETFONTSMOOTHINGCONTRAST   0x200C
 
#define SPI_SETFONTSMOOTHINGCONTRAST   0x200D
 
#define TT_PRIM_CSPLINE   3
 

Typedefs

typedef HRESULT(WINAPI * fScriptFreeCache) (SCRIPT_CACHE *)
 
typedef void * SCRIPT_CACHE
 

Enumerations

enum  { max_font_count = 256 }
 

Functions

static bool addGlyphToPath (glyph_t glyph, const QFixedPoint &position, HDC hdc, QPainterPath *path, bool ttf, glyph_metrics_t *metric=0, qreal scale=1)
 
void calculateTTFGlyphWidth (HDC hdc, UINT glyph, int &width)
 
unsigned int getChar (const QChar *str, int &i, const int len)
 
static OUTLINETEXTMETRIC * getOutlineTextMetric (HDC hdc)
 
static quint32 getUInt (unsigned char *p)
 
static quint16 getUShort (unsigned char *p)
 
static double qt_fixed_to_double (const FIXED &p)
 
QFontEngineqt_load_font_engine_win (const QFontDef &request)
 
static QPointF qt_to_qpointf (const POINTFX &pt, qreal scale)
 
HDC shared_dc ()
 

Variables

static const ushort char_table []
 
static const int char_table_entries = sizeof(char_table)/sizeof(ushort)
 
bool qt_cleartype_enabled
 
uint qt_pow_gamma [256]
 
fScriptFreeCache ScriptFreeCache
 

Macro Definition Documentation

◆ _WIN32_WINNT

#define _WIN32_WINNT   0x0500

Definition at line 44 of file qfontengine_win.cpp.

◆ GGO_UNHINTED

#define GGO_UNHINTED   0x0100

Definition at line 834 of file qfontengine_win.cpp.

◆ MAKE_TAG

#define MAKE_TAG (   ch1,
  ch2,
  ch3,
  ch4 
)
Value:
(\
(((quint32)(ch4)) << 24) | \
(((quint32)(ch3)) << 16) | \
(((quint32)(ch2)) << 8) | \
((quint32)(ch1)) \
)
unsigned int quint32
Definition: qglobal.h:938

Definition at line 84 of file qfontengine_win.cpp.

Referenced by QFontEngineWin::getCMap(), and QFontEngineWin::synthesized().

◆ SPI_GETFONTSMOOTHINGCONTRAST

#define SPI_GETFONTSMOOTHINGCONTRAST   0x200C

Definition at line 1251 of file qfontengine_win.cpp.

Referenced by QFontEngineWin::alphaRGBMapForGlyph().

◆ SPI_SETFONTSMOOTHINGCONTRAST

#define SPI_SETFONTSMOOTHINGCONTRAST   0x200D

Definition at line 1252 of file qfontengine_win.cpp.

Referenced by QFontEngineWin::alphaRGBMapForGlyph().

◆ TT_PRIM_CSPLINE

#define TT_PRIM_CSPLINE   3

Definition at line 77 of file qfontengine_win.cpp.

Referenced by addGlyphToPath().

Typedef Documentation

◆ fScriptFreeCache

typedef HRESULT(WINAPI * fScriptFreeCache) (SCRIPT_CACHE *)

Definition at line 151 of file qfontengine_win.cpp.

◆ SCRIPT_CACHE

typedef void* SCRIPT_CACHE

Definition at line 150 of file qfontengine_win.cpp.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
max_font_count 

Definition at line 631 of file qfontengine_win.cpp.

Function Documentation

◆ addGlyphToPath()

static bool addGlyphToPath ( glyph_t  glyph,
const QFixedPoint position,
HDC  hdc,
QPainterPath path,
bool  ttf,
glyph_metrics_t metric = 0,
qreal  scale = 1 
)
static

Definition at line 837 of file qfontengine_win.cpp.

Referenced by QFontEngineWin::addGlyphsToPath(), and QFontEngineWin::getUnscaledGlyph().

839 {
840 #if defined(Q_WS_WINCE)
841  Q_UNUSED(glyph);
842  Q_UNUSED(hdc);
843 #endif
844  MAT2 mat;
845  mat.eM11.value = mat.eM22.value = 1;
846  mat.eM11.fract = mat.eM22.fract = 0;
847  mat.eM21.value = mat.eM12.value = 0;
848  mat.eM21.fract = mat.eM12.fract = 0;
849  uint glyphFormat = GGO_NATIVE;
850 
851  if (ttf)
852  glyphFormat |= GGO_GLYPH_INDEX;
853 
854  GLYPHMETRICS gMetric;
855  memset(&gMetric, 0, sizeof(GLYPHMETRICS));
856  int bufferSize = GDI_ERROR;
857 #if !defined(Q_WS_WINCE)
858  bufferSize = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, 0, 0, &mat);
859 #endif
860  if ((DWORD)bufferSize == GDI_ERROR) {
861  return false;
862  }
863 
864  void *dataBuffer = new char[bufferSize];
865  DWORD ret = GDI_ERROR;
866 #if !defined(Q_WS_WINCE)
867  ret = GetGlyphOutline(hdc, glyph, glyphFormat, &gMetric, bufferSize, dataBuffer, &mat);
868 #endif
869  if (ret == GDI_ERROR) {
870  delete [](char *)dataBuffer;
871  return false;
872  }
873 
874  if(metric) {
875  // #### obey scale
876  *metric = glyph_metrics_t(gMetric.gmptGlyphOrigin.x, -gMetric.gmptGlyphOrigin.y,
877  (int)gMetric.gmBlackBoxX, (int)gMetric.gmBlackBoxY,
878  gMetric.gmCellIncX, gMetric.gmCellIncY);
879  }
880 
881  int offset = 0;
882  int headerOffset = 0;
883  TTPOLYGONHEADER *ttph = 0;
884 
885  QPointF oset = position.toPointF();
886  while (headerOffset < bufferSize) {
887  ttph = (TTPOLYGONHEADER*)((char *)dataBuffer + headerOffset);
888 
889  QPointF lastPoint(qt_to_qpointf(ttph->pfxStart, scale));
890  path->moveTo(lastPoint + oset);
891  offset += sizeof(TTPOLYGONHEADER);
892  TTPOLYCURVE *curve;
893  while (offset<int(headerOffset + ttph->cb)) {
894  curve = (TTPOLYCURVE*)((char*)(dataBuffer) + offset);
895  switch (curve->wType) {
896  case TT_PRIM_LINE: {
897  for (int i=0; i<curve->cpfx; ++i) {
898  QPointF p = qt_to_qpointf(curve->apfx[i], scale) + oset;
899  path->lineTo(p);
900  }
901  break;
902  }
903  case TT_PRIM_QSPLINE: {
904  const QPainterPath::Element &elm = path->elementAt(path->elementCount()-1);
905  QPointF prev(elm.x, elm.y);
906  QPointF endPoint;
907  for (int i=0; i<curve->cpfx - 1; ++i) {
908  QPointF p1 = qt_to_qpointf(curve->apfx[i], scale) + oset;
909  QPointF p2 = qt_to_qpointf(curve->apfx[i+1], scale) + oset;
910  if (i < curve->cpfx - 2) {
911  endPoint = QPointF((p1.x() + p2.x()) / 2, (p1.y() + p2.y()) / 2);
912  } else {
913  endPoint = p2;
914  }
915 
916  path->quadTo(p1, endPoint);
917  prev = endPoint;
918  }
919 
920  break;
921  }
922  case TT_PRIM_CSPLINE: {
923  for (int i=0; i<curve->cpfx; ) {
924  QPointF p2 = qt_to_qpointf(curve->apfx[i++], scale) + oset;
925  QPointF p3 = qt_to_qpointf(curve->apfx[i++], scale) + oset;
926  QPointF p4 = qt_to_qpointf(curve->apfx[i++], scale) + oset;
927  path->cubicTo(p2, p3, p4);
928  }
929  break;
930  }
931  default:
932  qWarning("QFontEngineWin::addOutlineToPath, unhandled switch case");
933  }
934  offset += sizeof(TTPOLYCURVE) + (curve->cpfx-1) * sizeof(POINTFX);
935  }
936  path->closeSubpath();
937  headerOffset += ttph->cb;
938  }
939  delete [] (char*)dataBuffer;
940 
941  return true;
942 }
The QPainterPath::Element class specifies the position and type of a subpath.
Definition: qpainterpath.h:77
static QPointF qt_to_qpointf(const POINTFX &pt, qreal scale)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void closeSubpath()
Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting ...
qreal y
the y coordinate of the element&#39;s position.
Definition: qpainterpath.h:80
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
const QPainterPath::Element & elementAt(int i) const
Returns the element at the given index in the painter path.
Definition: qpainterpath.h:402
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
struct tagTTPOLYCURVE TTPOLYCURVE
#define GGO_NATIVE
Q_CORE_EXPORT void qWarning(const char *,...)
unsigned int uint
Definition: qglobal.h:996
struct tagTTPOLYGONHEADER TTPOLYGONHEADER
QPointF toPointF() const
Definition: qfixed_p.h:194
#define TT_PRIM_CSPLINE
#define TT_PRIM_QSPLINE
#define TT_PRIM_LINE
void quadTo(const QPointF &ctrlPt, const QPointF &endPt)
Adds a quadratic Bezier curve between the current position and the given endPoint with the control po...
qreal x
the x coordinate of the element&#39;s position.
Definition: qpainterpath.h:79
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
void cubicTo(const QPointF &ctrlPt1, const QPointF &ctrlPt2, const QPointF &endPt)
Adds a cubic Bezier curve between the current position and the given endPoint using the control point...
int elementCount() const
Returns the number of path elements in the painter path.
Definition: qpainterpath.h:397
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
#define GGO_GLYPH_INDEX
struct tagPOINTFX POINTFX

◆ calculateTTFGlyphWidth()

void calculateTTFGlyphWidth ( HDC  hdc,
UINT  glyph,
int &  width 
)
inline

Definition at line 396 of file qfontengine_win.cpp.

Referenced by QFontEngineWin::recalcAdvances().

397 {
398 #if defined(Q_WS_WINCE)
399  GetCharWidth32(hdc, glyph, glyph, &width);
400 #else
401  if (ptrGetCharWidthI)
402  ptrGetCharWidthI(hdc, glyph, 1, 0, &width);
403 #endif
404 }

◆ getChar()

unsigned int getChar ( const QChar str,
int &  i,
const int  len 
)
inline

Definition at line 228 of file qfontengine_win.cpp.

Referenced by QFontEngineWin::canRender(), and QFontEngineWin::getGlyphIndexes().

229 {
230  uint ucs4 = str[i].unicode();
231  if (str[i].isHighSurrogate() && i < len-1 && str[i+1].isLowSurrogate()) {
232  ++i;
233  ucs4 = QChar::surrogateToUcs4(ucs4, str[i].unicode());
234  }
235  return ucs4;
236 }
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: qchar.h:251
unsigned int uint
Definition: qglobal.h:996
static uint surrogateToUcs4(ushort high, ushort low)
Converts a UTF16 surrogate pair with the given high and low values to its UCS-4 code point...
Definition: qchar.h:297

◆ getOutlineTextMetric()

static OUTLINETEXTMETRIC* getOutlineTextMetric ( HDC  hdc)
static

Definition at line 184 of file qfontengine_win.cpp.

Referenced by QFontEngineWin::getCMap(), and QFontEngineWin::properties().

185 {
186  int size;
187  size = GetOutlineTextMetrics(hdc, 0, 0);
188  OUTLINETEXTMETRIC *otm = (OUTLINETEXTMETRIC *)malloc(size);
189  GetOutlineTextMetrics(hdc, size, otm);
190  return otm;
191 }

◆ getUInt()

static quint32 getUInt ( unsigned char *  p)
inlinestatic

Definition at line 154 of file qfontengine_win.cpp.

155 {
156  quint32 val;
157  val = *p++ << 24;
158  val |= *p++ << 16;
159  val |= *p++ << 8;
160  val |= *p;
161 
162  return val;
163 }
unsigned int quint32
Definition: qglobal.h:938

◆ getUShort()

static quint16 getUShort ( unsigned char *  p)
inlinestatic

Definition at line 165 of file qfontengine_win.cpp.

Referenced by QFontEngineWin::synthesized().

166 {
167  quint16 val;
168  val = *p++ << 8;
169  val |= *p;
170 
171  return val;
172 }
unsigned short quint16
Definition: qglobal.h:936

◆ qt_fixed_to_double()

static double qt_fixed_to_double ( const FIXED p)
inlinestatic

Definition at line 825 of file qfontengine_win.cpp.

Referenced by qt_to_qpointf().

825  {
826  return ((p.value << 16) + p.fract) / 65536.0;
827 }

◆ qt_load_font_engine_win()

QFontEngine* qt_load_font_engine_win ( const QFontDef request)

Definition at line 998 of file qfontdatabase_win.cpp.

Referenced by QFontEngineWin::alphaRGBMapForGlyph().

999 {
1000  // From qfont.cpp
1001  extern int qt_defaultDpi();
1002 
1005  if (fe != 0)
1006  return fe;
1007  else
1008  return loadEngine(QUnicodeTables::Common, request, 0, qt_defaultDpi(), false, 0,
1009  QStringList());
1010 }
static QFontCache * instance()
Definition: qfont.cpp:2919
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static QFontEngine * loadEngine(int script, const QFontDef &request, HDC fontHdc, int dpi, bool rawMode, const QtFontDesc *desc, const QStringList &family_list)
Q_GUI_EXPORT int qt_defaultDpi()
Definition: qfont.cpp:240
int key
QFontEngine * findEngine(const Key &key)
Definition: qfont.cpp:3054

◆ qt_to_qpointf()

static QPointF qt_to_qpointf ( const POINTFX pt,
qreal  scale 
)
inlinestatic

Definition at line 829 of file qfontengine_win.cpp.

Referenced by addGlyphToPath().

829  {
830  return QPointF(qt_fixed_to_double(pt.x) * scale, -qt_fixed_to_double(pt.y) * scale);
831 }
static double qt_fixed_to_double(const FIXED &p)
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214

◆ shared_dc()

HDC shared_dc ( )

Variable Documentation

◆ char_table

const ushort char_table[]
static
Initial value:
= {
40,
67,
70,
75,
86,
88,
89,
91,
102,
114,
124,
127,
205,
645,
884,
922,
1070,
12386,
0
}

Definition at line 632 of file qfontengine_win.cpp.

◆ char_table_entries

const int char_table_entries = sizeof(char_table)/sizeof(ushort)
static

Definition at line 654 of file qfontengine_win.cpp.

Referenced by QFontEngineWin::minRightBearing().

◆ qt_cleartype_enabled

bool qt_cleartype_enabled

Definition at line 241 of file qapplication_win.cpp.

Referenced by QFontEngineWin::getSfntTableData().

◆ qt_pow_gamma

uint qt_pow_gamma[256]

Definition at line 7029 of file qdrawhelper.cpp.

Referenced by QFontEngineWin::drawGDIGlyph().

◆ ScriptFreeCache

fScriptFreeCache ScriptFreeCache