Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
QWindowsFontEngineDirectWrite Class Reference

Windows font engine using Direct Write. More...

#include <qwindowsfontenginedirectwrite_p.h>

+ Inheritance diagram for QWindowsFontEngineDirectWrite:
+ Collaboration diagram for QWindowsFontEngineDirectWrite:

Public Member Functions

 QWindowsFontEngineDirectWrite (IDWriteFontFace *directWriteFontFace, qreal pixelSize, const QSharedPointer< QWindowsFontEngineData > &d)
 
 ~QWindowsFontEngineDirectWrite () override
 
void initFontInfo (const QFontDef &request, int dpi)
 
QFixed lineThickness () const override
 
QFixed underlinePosition () const override
 
bool getSfntTableData (uint tag, uchar *buffer, uint *length) const override
 Returns true if the font table idetified by tag exists in the font; returns false otherwise.
 
QFixed emSquareSize () const override
 
glyph_t glyphIndex (uint ucs4) const override
 
bool stringToCMap (const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const override
 
void recalcAdvances (QGlyphLayout *glyphs, ShaperFlags) const override
 
void addGlyphsToPath (glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags) override
 
glyph_metrics_t boundingBox (const QGlyphLayout &glyphs) override
 
glyph_metrics_t boundingBox (glyph_t g) override
 
glyph_metrics_t alphaMapBoundingBox (glyph_t glyph, const QFixedPoint &, const QTransform &matrix, GlyphFormat) override
 
QFixed capHeight () const override
 
QFixed xHeight () const override
 
qreal maxCharWidth () const override
 
FaceId faceId () const override
 
bool supportsHorizontalSubPixelPositions () const override
 
HFONT createHFONT () const
 
QImage alphaMapForGlyph (glyph_t glyph, const QFixedPoint &subPixelPosition) override
 
QImage alphaMapForGlyph (glyph_t glyph, const QFixedPoint &subPixelPosition, const QTransform &t) override
 
QImage alphaRGBMapForGlyph (glyph_t t, const QFixedPoint &subPixelPosition, const QTransform &xform) override
 
QImage bitmapForGlyph (glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t, const QColor &color) override
 
QFontEnginecloneWithSize (qreal pixelSize) const override
 
Qt::HANDLE handle () const override
 
const QSharedPointer< QWindowsFontEngineData > & fontEngineData () const
 
IDWriteFontFace * directWriteFontFace () const
 
void setUniqueFamilyName (const QString &newName)
 
void initializeHeightMetrics () const override
 
Properties properties () const override
 
void getUnscaledGlyph (glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics) override
 
- Public Member Functions inherited from QFontEngine
virtual ~QFontEngine ()
 
Type type () const
 
virtual Properties properties () const
 
virtual void getUnscaledGlyph (glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics)
 
QByteArray getSfntTable (uint tag) const
 
virtual bool getSfntTableData (uint tag, uchar *buffer, uint *length) const
 Returns true if the font table idetified by tag exists in the font; returns false otherwise.
 
virtual FaceId faceId () const
 
virtual int synthesized () const
 
bool supportsSubPixelPositions () const
 
virtual bool supportsHorizontalSubPixelPositions () const
 
virtual bool supportsVerticalSubPixelPositions () const
 
virtual QFixedPoint subPixelPositionFor (const QFixedPoint &position) const
 
QFixed subPixelPositionForX (QFixed x) const
 
virtual QFixed emSquareSize () const
 
virtual glyph_t glyphIndex (uint ucs4) const =0
 
virtual bool stringToCMap (const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const =0
 
virtual void recalcAdvances (QGlyphLayout *, ShaperFlags) const
 
virtual void doKerning (QGlyphLayout *, ShaperFlags) const
 
virtual void addGlyphsToPath (glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags)
 
void getGlyphPositions (const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
 
virtual void addOutlineToPath (qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags)
 
void addBitmapFontToPath (qreal x, qreal y, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags)
 
virtual QImage alphaMapForGlyph (glyph_t)
 
virtual QImage alphaMapForGlyph (glyph_t glyph, const QFixedPoint &subPixelPosition)
 
virtual QImage alphaMapForGlyph (glyph_t, const QTransform &t)
 
virtual QImage alphaMapForGlyph (glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t)
 
virtual QImage alphaRGBMapForGlyph (glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t)
 
virtual QImage bitmapForGlyph (glyph_t, const QFixedPoint &subPixelPosition, const QTransform &t, const QColor &color=QColor())
 
virtual GlyphglyphData (glyph_t glyph, const QFixedPoint &subPixelPosition, GlyphFormat neededFormat, const QTransform &t)
 
virtual bool hasInternalCaching () const
 
virtual glyph_metrics_t alphaMapBoundingBox (glyph_t glyph, const QFixedPoint &, const QTransform &matrix, GlyphFormat)
 
virtual void removeGlyphFromCache (glyph_t)
 
virtual glyph_metrics_t boundingBox (const QGlyphLayout &glyphs)
 
virtual glyph_metrics_t boundingBox (glyph_t glyph)=0
 
virtual glyph_metrics_t boundingBox (glyph_t glyph, const QTransform &matrix)
 
glyph_metrics_t tightBoundingBox (const QGlyphLayout &glyphs)
 
virtual QFixed ascent () const
 
virtual QFixed capHeight () const =0
 
virtual QFixed descent () const
 
virtual QFixed leading () const
 
virtual QFixed xHeight () const
 
virtual QFixed averageCharWidth () const
 
virtual QFixed lineThickness () const
 
virtual QFixed underlinePosition () const
 
virtual qreal maxCharWidth () const =0
 
virtual qreal minLeftBearing () const
 
virtual qreal minRightBearing () const
 
virtual void getGlyphBearings (glyph_t glyph, qreal *leftBearing=nullptr, qreal *rightBearing=nullptr)
 
bool canRender (uint ucs4) const
 
virtual bool canRender (const QChar *str, int len) const
 
virtual bool supportsTransformation (const QTransform &transform) const
 
virtual int glyphCount () const
 
virtual int glyphMargin (GlyphFormat format)
 
virtual QFontEnginecloneWithSize (qreal) const
 
virtual Qt::HANDLE handle () const
 
voidharfbuzzFont () const
 
voidharfbuzzFace () const
 
bool supportsScript (QChar::Script script) const
 
virtual int getPointInOutline (glyph_t glyph, int flags, quint32 point, QFixed *xpos, QFixed *ypos, quint32 *nPoints)
 
void clearGlyphCache (const void *key)
 
void setGlyphCache (const void *key, QFontEngineGlyphCache *data)
 
QFontEngineGlyphCacheglyphCache (const void *key, GlyphFormat format, const QTransform &transform, const QColor &color=QColor()) const
 
virtual bool hasUnreliableGlyphOutline () const
 
virtual bool expectsGammaCorrectedBlending () const
 
virtual void setDefaultHintStyle (HintStyle)
 
void loadKerningPairs (QFixed scalingFactor)
 

Static Public Member Functions

static QString fontNameSubstitute (const QString &familyName)
 
- Static Public Member Functions inherited from QFontEngine
static bool scriptRequiresOpenType (QChar::Script script)
 
static const uchargetCMap (const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize)
 
static quint32 getTrueTypeGlyphIndex (const uchar *cmap, int cmapSize, uint unicode)
 
static QByteArray convertToPostscriptFontFamilyName (const QByteArray &fontFamily)
 

Additional Inherited Members

- Public Types inherited from QFontEngine
enum  Type {
  Box , Multi , Win , Mac ,
  Freetype , QPF1 , QPF2 , Proxy ,
  DirectWrite , TestFontEngine = 0x1000
}
 
enum  GlyphFormat {
  Format_None , Format_Render = Format_None , Format_Mono , Format_A8 ,
  Format_A32 , Format_ARGB
}
 
enum  ShaperFlag { DesignMetrics = 0x0002 , GlyphIndicesOnly = 0x0004 }
 
enum  SynthesizedFlags { SynthesizedItalic = 0x1 , SynthesizedBold = 0x2 , SynthesizedStretch = 0x4 }
 
enum  HintStyle { HintNone , HintLight , HintMedium , HintFull }
 
enum  SubpixelAntialiasingType {
  Subpixel_None , Subpixel_RGB , Subpixel_BGR , Subpixel_VRGB ,
  Subpixel_VBGR
}
 
- Public Attributes inherited from QFontEngine
QAtomicInt ref
 
QFontDef fontDef
 
Holder font_
 
Holder face_
 
struct QFontEngine::FaceData faceData
 
uint cache_cost
 
uint fsType: 16
 
bool symbol
 
bool isSmoothlyScalable
 
QList< KernPairkerning_pairs
 
GlyphFormat glyphFormat
 
int m_subPixelPositionCount
 
- Protected Member Functions inherited from QFontEngine
 QFontEngine (Type type)
 
QFixed firstLeftBearing (const QGlyphLayout &glyphs)
 
QFixed lastRightBearing (const QGlyphLayout &glyphs)
 
QFixed calculatedCapHeight () const
 
virtual void initializeHeightMetrics () const
 
bool processHheaTable () const
 
bool processOS2Table () const
 
- Protected Attributes inherited from QFontEngine
QFixed m_ascent
 
QFixed m_descent
 
QFixed m_leading
 
bool m_heightMetricsQueried
 

Detailed Description

Windows font engine using Direct Write.

Font engine for subpixel positioned text on Windows Vista (with platform update) and later. If selected during configuration, the engine will be selected only when the hinting preference of a font is set to None or Vertical hinting, or when fontengine=directwrite is selected as platform option.

Definition at line 38 of file qwindowsfontenginedirectwrite_p.h.

Constructor & Destructor Documentation

◆ QWindowsFontEngineDirectWrite()

QWindowsFontEngineDirectWrite::QWindowsFontEngineDirectWrite ( IDWriteFontFace *  directWriteFontFace,
qreal  pixelSize,
const QSharedPointer< QWindowsFontEngineData > &  d 
)
explicit

Definition at line 194 of file qwindowsfontenginedirectwrite.cpp.

References QFontEngine::cache_cost, QFontEngine::fontDef, QFontEngine::m_ascent, QFontEngine::m_descent, QFontDef::pixelSize, Q_ASSERT, qCDebug, and QFixed::toInt().

+ Here is the call graph for this function:

◆ ~QWindowsFontEngineDirectWrite()

QWindowsFontEngineDirectWrite::~QWindowsFontEngineDirectWrite ( )
override

Definition at line 218 of file qwindowsfontenginedirectwrite.cpp.

References QPlatformIntegration::fontDatabase(), QString::isEmpty(), QGuiApplicationPrivate::platformIntegration(), and qCDebug.

+ Here is the call graph for this function:

Member Function Documentation

◆ addGlyphsToPath()

void QWindowsFontEngineDirectWrite::addGlyphsToPath ( glyph_t glyphs,
QFixedPoint positions,
int  nglyphs,
QPainterPath path,
QTextItem::RenderFlags  flags 
)
overridevirtual

Reimplemented from QFontEngine.

Definition at line 550 of file qwindowsfontenginedirectwrite.cpp.

References QVarLengthArray< T, Prealloc >::data(), QFontEngine::fontDef, i, QFontDef::pixelSize, positions, Q_UNUSED, and qErrnoWarning().

+ Here is the call graph for this function:

◆ alphaMapBoundingBox()

glyph_metrics_t QWindowsFontEngineDirectWrite::alphaMapBoundingBox ( glyph_t  glyph,
const QFixedPoint ,
const QTransform matrix,
GlyphFormat   
)
overridevirtual

Reimplemented from QFontEngine.

◆ alphaMapForGlyph() [1/2]

QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph ( glyph_t  glyph,
const QFixedPoint subPixelPosition 
)
overridevirtual

Reimplemented from QFontEngine.

Definition at line 662 of file qwindowsfontenginedirectwrite.cpp.

References alphaMapForGlyph().

Referenced by alphaMapForGlyph().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ alphaMapForGlyph() [2/2]

QImage QWindowsFontEngineDirectWrite::alphaMapForGlyph ( glyph_t  glyph,
const QFixedPoint subPixelPosition,
const QTransform t 
)
overridevirtual

Reimplemented from QFontEngine.

Definition at line 641 of file qwindowsfontenginedirectwrite.cpp.

References QImage::constScanLine(), QFontEngine::Format_A8, QImage::Format_Alpha8, QFontEngine::glyphMargin(), QImage::height(), QWindowsFontEngineData::pow_gamma, qGray(), QImage::scanLine(), and QImage::width().

+ Here is the call graph for this function:

◆ alphaRGBMapForGlyph()

QImage QWindowsFontEngineDirectWrite::alphaRGBMapForGlyph ( glyph_t  t,
const QFixedPoint subPixelPosition,
const QTransform xform 
)
overridevirtual

Reimplemented from QFontEngine.

Definition at line 967 of file qwindowsfontenginedirectwrite.cpp.

References QFontEngine::Format_A32, QImage::Format_RGB32, QFontEngine::glyphMargin(), and xform.

+ Here is the call graph for this function:

◆ bitmapForGlyph()

QImage QWindowsFontEngineDirectWrite::bitmapForGlyph ( glyph_t  ,
const QFixedPoint subPixelPosition,
const QTransform t,
const QColor color 
)
overridevirtual

Reimplemented from QFontEngine.

◆ boundingBox() [1/2]

glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox ( const QGlyphLayout glyphs)
overridevirtual

Reimplemented from QFontEngine.

Definition at line 581 of file qwindowsfontenginedirectwrite.cpp.

References QFontEngine::ascent(), QFontEngine::descent(), QGlyphLayout::effectiveAdvance(), QFontEngine::firstLeftBearing(), i, QFontEngine::lastRightBearing(), and QGlyphLayout::numGlyphs.

+ Here is the call graph for this function:

◆ boundingBox() [2/2]

glyph_metrics_t QWindowsFontEngineDirectWrite::boundingBox ( glyph_t  g)
overridevirtual

Implements QFontEngine.

Definition at line 594 of file qwindowsfontenginedirectwrite.cpp.

References DESIGN_TO_LOGICAL, glyphIndex(), and qErrnoWarning().

+ Here is the call graph for this function:

◆ capHeight()

QFixed QWindowsFontEngineDirectWrite::capHeight ( ) const
overridevirtual

Implements QFontEngine.

Definition at line 623 of file qwindowsfontenginedirectwrite.cpp.

References QFontEngine::calculatedCapHeight().

+ Here is the call graph for this function:

◆ cloneWithSize()

QFontEngine * QWindowsFontEngineDirectWrite::cloneWithSize ( qreal  pixelSize) const
overridevirtual

Reimplemented from QFontEngine.

Definition at line 981 of file qwindowsfontenginedirectwrite.cpp.

References QPlatformIntegration::fontDatabase(), QFontEngine::fontDef, QString::isEmpty(), QFontDef::pixelSize, QGuiApplicationPrivate::platformIntegration(), and setUniqueFamilyName().

+ Here is the call graph for this function:

◆ createHFONT()

HFONT QWindowsFontEngineDirectWrite::createHFONT ( ) const

Definition at line 310 of file qwindowsfontenginedirectwrite.cpp.

References QFontEngine::fontDef, QFontDef::pixelSize, and qRound().

Referenced by draw_text_item_win(), and QWin32PrintEngine::drawTextItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ directWriteFontFace()

IDWriteFontFace * QWindowsFontEngineDirectWrite::directWriteFontFace ( ) const
inline

Definition at line 95 of file qwindowsfontenginedirectwrite_p.h.

◆ emSquareSize()

QFixed QWindowsFontEngineDirectWrite::emSquareSize ( ) const
overridevirtual

Reimplemented from QFontEngine.

Definition at line 408 of file qwindowsfontenginedirectwrite.cpp.

References QFontEngine::emSquareSize().

+ Here is the call graph for this function:

◆ faceId()

QFontEngine::FaceId QWindowsFontEngineDirectWrite::faceId ( ) const
overridevirtual

Reimplemented from QFontEngine.

Definition at line 464 of file qwindowsfontenginedirectwrite.cpp.

◆ fontEngineData()

const QSharedPointer< QWindowsFontEngineData > & QWindowsFontEngineDirectWrite::fontEngineData ( ) const
inline

Definition at line 91 of file qwindowsfontenginedirectwrite_p.h.

◆ fontNameSubstitute()

QString QWindowsFontEngineDirectWrite::fontNameSubstitute ( const QString familyName)
static

Definition at line 1014 of file qwindowsfontenginedirectwrite.cpp.

References QString::isEmpty(), and QWinRegistryKey::stringValue().

Referenced by QWindowsFontDatabase::createEngine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSfntTableData()

bool QWindowsFontEngineDirectWrite::getSfntTableData ( uint  tag,
uchar buffer,
uint length 
) const
overridevirtual

Returns true if the font table idetified by tag exists in the font; returns false otherwise.

If buffer is \nullptr, stores the size of the buffer required for the font table data, in bytes, in length. If buffer is not \nullptr and the capacity of the buffer, passed in length, is sufficient to store the font table data, also copies the font table data to buffer.

Note: returning false when the font table exists could lead to an undefined behavior.

Reimplemented from QFontEngine.

Definition at line 381 of file qwindowsfontenginedirectwrite.cpp.

References Q_ASSERT, qErrnoWarning(), ret, and tag.

+ Here is the call graph for this function:

◆ getUnscaledGlyph()

void QWindowsFontEngineDirectWrite::getUnscaledGlyph ( glyph_t  glyph,
QPainterPath path,
glyph_metrics_t metrics 
)
overridevirtual

Reimplemented from QFontEngine.

Definition at line 503 of file qwindowsfontenginedirectwrite.cpp.

References qErrnoWarning().

+ Here is the call graph for this function:

◆ glyphIndex()

glyph_t QWindowsFontEngineDirectWrite::glyphIndex ( uint  ucs4) const
overridevirtual

Implements QFontEngine.

Definition at line 416 of file qwindowsfontenginedirectwrite.cpp.

References glyphIndex(), and qErrnoWarning().

Referenced by boundingBox(), and glyphIndex().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handle()

Qt::HANDLE QWindowsFontEngineDirectWrite::handle ( ) const
overridevirtual

Reimplemented from QFontEngine.

Definition at line 998 of file qwindowsfontenginedirectwrite.cpp.

◆ initFontInfo()

void QWindowsFontEngineDirectWrite::initFontInfo ( const QFontDef request,
int  dpi 
)

Definition at line 1003 of file qwindowsfontenginedirectwrite.cpp.

References QFontEngine::fontDef, QFontDef::pixelSize, QFontDef::pointSize, qRound(), and request.

Referenced by QWindowsFontDatabase::createEngine().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initializeHeightMetrics()

void QWindowsFontEngineDirectWrite::initializeHeightMetrics ( ) const
overridevirtual

Reimplemented from QFontEngine.

Definition at line 326 of file qwindowsfontenginedirectwrite.cpp.

References DESIGN_TO_LOGICAL, QFontEngine::initializeHeightMetrics(), QFontEngine::m_ascent, QFontEngine::m_descent, and QFontEngine::m_leading.

+ Here is the call graph for this function:

◆ lineThickness()

QFixed QWindowsFontEngineDirectWrite::lineThickness ( ) const
overridevirtual

Reimplemented from QFontEngine.

Definition at line 373 of file qwindowsfontenginedirectwrite.cpp.

References QFontEngine::lineThickness().

+ Here is the call graph for this function:

◆ maxCharWidth()

qreal QWindowsFontEngineDirectWrite::maxCharWidth ( ) const
overridevirtual

Implements QFontEngine.

Definition at line 636 of file qwindowsfontenginedirectwrite.cpp.

References QFixed::toReal().

+ Here is the call graph for this function:

◆ properties()

QFontEngine::Properties QWindowsFontEngineDirectWrite::properties ( ) const
overridevirtual

Reimplemented from QFontEngine.

Definition at line 673 of file qwindowsfontenginedirectwrite.cpp.

References QFontEngine::properties().

+ Here is the call graph for this function:

◆ recalcAdvances()

void QWindowsFontEngineDirectWrite::recalcAdvances ( QGlyphLayout glyphs,
ShaperFlags   
) const
overridevirtual

Reimplemented from QFontEngine.

Definition at line 469 of file qwindowsfontenginedirectwrite.cpp.

References QGlyphLayout::advances, QFont::AnyStretch, QVarLengthArray< T, Prealloc >::data(), DESIGN_TO_LOGICAL, QFontEngine::fontDef, QGlyphLayout::glyphs, hintingPreferenceToRenderingMode(), i, QGlyphLayout::numGlyphs, QFontDef::pixelSize, qErrnoWarning(), QVLABaseBase::size(), and QFontDef::stretch.

Referenced by stringToCMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setUniqueFamilyName()

void QWindowsFontEngineDirectWrite::setUniqueFamilyName ( const QString newName)
inline

Definition at line 97 of file qwindowsfontenginedirectwrite_p.h.

Referenced by cloneWithSize().

+ Here is the caller graph for this function:

◆ stringToCMap()

bool QWindowsFontEngineDirectWrite::stringToCMap ( const QChar str,
int  len,
QGlyphLayout glyphs,
int *  nglyphs,
ShaperFlags  flags 
) const
overridevirtual

Implements QFontEngine.

Definition at line 429 of file qwindowsfontenginedirectwrite.cpp.

References QVarLengthArray< T, Prealloc >::at(), QVarLengthArray< T, Prealloc >::data(), QFontEngine::GlyphIndicesOnly, QGlyphLayout::glyphs, i, it, QGlyphLayout::numGlyphs, Q_ASSERT, qErrnoWarning(), recalcAdvances(), and str.

+ Here is the call graph for this function:

◆ supportsHorizontalSubPixelPositions()

bool QWindowsFontEngineDirectWrite::supportsHorizontalSubPixelPositions ( ) const
overridevirtual

Reimplemented from QFontEngine.

Definition at line 668 of file qwindowsfontenginedirectwrite.cpp.

◆ underlinePosition()

QFixed QWindowsFontEngineDirectWrite::underlinePosition ( ) const
overridevirtual

Reimplemented from QFontEngine.

Definition at line 365 of file qwindowsfontenginedirectwrite.cpp.

References QFontEngine::underlinePosition().

+ Here is the call graph for this function:

◆ xHeight()

QFixed QWindowsFontEngineDirectWrite::xHeight ( ) const
overridevirtual

Reimplemented from QFontEngine.

Definition at line 631 of file qwindowsfontenginedirectwrite.cpp.


The documentation for this class was generated from the following files: