Qt 4.8
Classes | Public Types | Public Functions | Static Public Functions | Public Variables | Protected Functions | Static Protected Functions | Properties | List of all members
QFontEngine Class Referenceabstract

#include <qfontengine_p.h>

Inheritance diagram for QFontEngine:
QObject QCoreTextFontEngine QFontEngineBox QFontEngineDirectWrite QFontEngineFT QFontEngineMac QFontEngineMulti QFontEngineQPA QFontEngineQPF QFontEngineQPF1 QFontEngineWin QFontEngineXLFD QProxyFontEngine

Classes

struct  FaceId
 
struct  GlyphCacheEntry
 
struct  KernPair
 
struct  Properties
 

Public Types

enum  GlyphFormat {
  Format_None, Format_Render = Format_None, Format_Mono, Format_A8,
  Format_A32
}
 
enum  SynthesizedFlags { SynthesizedItalic = 0x1, SynthesizedBold = 0x2, SynthesizedStretch = 0x4 }
 
enum  Type {
  Box, Multi, XLFD, Win,
  Mac, Freetype, QPF1, QPF2,
  Proxy, S60FontEngine, DirectWrite, TestFontEngine = 0x1000
}
 

Public Functions

void addBitmapFontToPath (qreal x, qreal y, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags)
 
virtual void addGlyphsToPath (glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags)
 
virtual void addOutlineToPath (qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags)
 
virtual glyph_metrics_t alphaMapBoundingBox (glyph_t glyph, QFixed, const QTransform &matrix, GlyphFormat)
 
virtual QImage alphaMapForGlyph (glyph_t)
 
virtual QImage alphaMapForGlyph (glyph_t glyph, QFixed subPixelPosition)
 
virtual QImage alphaMapForGlyph (glyph_t, const QTransform &t)
 
virtual QImage alphaMapForGlyph (glyph_t, QFixed subPixelPosition, const QTransform &t)
 
virtual QImage alphaRGBMapForGlyph (glyph_t, QFixed subPixelPosition, int margin, const QTransform &t)
 
virtual QFixed ascent () const =0
 
virtual QFixed averageCharWidth () const
 
virtual glyph_metrics_t boundingBox (const QGlyphLayout &glyphs)=0
 
virtual glyph_metrics_t boundingBox (glyph_t glyph)=0
 
virtual glyph_metrics_t boundingBox (glyph_t glyph, const QTransform &matrix)
 
virtual bool canRender (const QChar *string, int len)=0
 
virtual QFontEnginecloneWithSize (qreal) const
 
virtual QFixed descent () const =0
 
virtual void doKerning (QGlyphLayout *, QTextEngine::ShaperFlags) const
 
virtual QFixed emSquareSize () const
 
virtual FaceId faceId () const
 
virtual void getGlyphBearings (glyph_t glyph, qreal *leftBearing=0, qreal *rightBearing=0)
 
void getGlyphPositions (const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
 
virtual HB_Error getPointInOutline (HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints)
 
QByteArray getSfntTable (uint) const
 
virtual bool getSfntTableData (uint, uchar *, uint *) const
 
virtual void getUnscaledGlyph (glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics)
 
QFontEngineGlyphCacheglyphCache (void *key, QFontEngineGlyphCache::Type type, const QTransform &transform) const
 
virtual int glyphCount () const
 
HB_Face harfbuzzFace () const
 
HB_Font harfbuzzFont () const
 
virtual QFixed leading () const =0
 
virtual QFixed lineThickness () const
 
void loadKerningPairs (QFixed scalingFactor)
 
virtual qreal maxCharWidth () const =0
 
virtual qreal minLeftBearing () const
 
virtual qreal minRightBearing () const
 
virtual const char * name () const =0
 
virtual Properties properties () const
 
 QFontEngine ()
 
virtual void recalcAdvances (QGlyphLayout *, QTextEngine::ShaperFlags) const
 
virtual void removeGlyphFromCache (glyph_t)
 
void setGlyphCache (void *key, QFontEngineGlyphCache *data)
 
virtual bool stringToCMap (const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const =0
 
virtual bool supportsSubPixelPositions () const
 
virtual int synthesized () const
 
glyph_metrics_t tightBoundingBox (const QGlyphLayout &glyphs)
 
virtual Type type () const =0
 
virtual QFixed underlinePosition () const
 
virtual QFixed xHeight () const
 
virtual ~QFontEngine ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Static Public Functions

static QByteArray convertToPostscriptFontFamilyName (const QByteArray &fontFamily)
 
static const uchargetCMap (const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize)
 
static quint32 getTrueTypeGlyphIndex (const uchar *cmap, uint unicode)
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 

Public Variables

uint cache_cost
 
int cache_count
 
QFontDef fontDef
 
uint fsType: 16
 
int glyphFormat
 
HB_Face hbFace
 
HB_FontRec hbFont
 
QVector< KernPairkerning_pairs
 
QAtomicInt ref
 
bool symbol
 

Protected Functions

QFixed lastRightBearing (const QGlyphLayout &glyphs, bool round=false)
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Static Protected Functions

static const QVector< QRgb > & grayPalette ()
 

Properties

QLinkedList< GlyphCacheEntrym_glyphCaches
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 95 of file qfontengine_p.h.

Enumerations

◆ GlyphFormat

Enumerator
Format_None 
Format_Render 
Format_Mono 
Format_A8 
Format_A32 

Definition at line 125 of file qfontengine_p.h.

◆ SynthesizedFlags

Enumerator
SynthesizedItalic 
SynthesizedBold 
SynthesizedStretch 

Definition at line 163 of file qfontengine_p.h.

◆ Type

Enumerator
Box 
Multi 
XLFD 
Win 
Mac 
Freetype 
QPF1 
QPF2 
Proxy 
S60FontEngine 
DirectWrite 
TestFontEngine 

Definition at line 98 of file qfontengine_p.h.

98  {
99  Box,
100  Multi,
101 
102  // X11 types
103  XLFD,
104 
105  // MS Windows types
106  Win,
107 
108  // Apple Mac OS types
109  Mac,
110 
111  // QWS types
112  Freetype,
113  QPF1,
114  QPF2,
115  Proxy,
116 
117  // S60 types
118  S60FontEngine, // Cannot be simply called "S60". Reason is qt_s60Data.h
119 
120  DirectWrite,
121 
122  TestFontEngine = 0x1000
123  };

Constructors and Destructors

◆ QFontEngine()

QFontEngine::QFontEngine ( )

Definition at line 176 of file qfontengine.cpp.

177  : QObject()
178 {
179  ref = 0;
180  cache_count = 0;
181  fsType = 0;
182  symbol = false;
183  memset(&hbFont, 0, sizeof(hbFont));
184  hbFont.klass = &hb_fontClass;
185  hbFont.userData = this;
186 
187  hbFace = 0;
188  glyphFormat = -1;
189 }
QAtomicInt ref
HB_FontRec hbFont
static const HB_FontClass hb_fontClass
HB_Face hbFace
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ ~QFontEngine()

QFontEngine::~QFontEngine ( )
virtual

Definition at line 191 of file qfontengine.cpp.

192 {
193  m_glyphCaches.clear();
195 }
void qHBFreeFace(HB_Face face)
Definition: qharfbuzz.cpp:128
QLinkedList< GlyphCacheEntry > m_glyphCaches
HB_Face hbFace

Functions

◆ addBitmapFontToPath()

void QFontEngine::addBitmapFontToPath ( qreal  x,
qreal  y,
const QGlyphLayout glyphs,
QPainterPath path,
QTextItem::RenderFlags  flags 
)

Definition at line 526 of file qfontengine.cpp.

Referenced by addGlyphsToPath(), QFontEngineWin::addOutlineToPath(), QFontEngineQPA::addOutlineToPath(), and QFontEngineQPF::addOutlineToPath().

528 {
529 // TODO what to do with 'flags' ??
530  Q_UNUSED(flags);
531  QFixed advanceX = QFixed::fromReal(x);
532  QFixed advanceY = QFixed::fromReal(y);
533  for (int i=0; i < glyphs.numGlyphs; ++i) {
534  glyph_metrics_t metrics = boundingBox(glyphs.glyphs[i]);
535  if (metrics.width.value() == 0 || metrics.height.value() == 0) {
536  advanceX += glyphs.advances_x[i];
537  advanceY += glyphs.advances_y[i];
538  continue;
539  }
540  const QImage alphaMask = alphaMapForGlyph(glyphs.glyphs[i]);
541 
542  const int w = alphaMask.width();
543  const int h = alphaMask.height();
544  const int srcBpl = alphaMask.bytesPerLine();
545  QImage bitmap;
546  if (alphaMask.depth() == 1) {
547  bitmap = alphaMask;
548  } else {
549  bitmap = QImage(w, h, QImage::Format_Mono);
550  const uchar *imageData = alphaMask.bits();
551  const int destBpl = bitmap.bytesPerLine();
552  uchar *bitmapData = bitmap.bits();
553 
554  for (int yi = 0; yi < h; ++yi) {
555  const uchar *src = imageData + yi*srcBpl;
556  uchar *dst = bitmapData + yi*destBpl;
557  for (int xi = 0; xi < w; ++xi) {
558  const int byte = xi / 8;
559  const int bit = xi % 8;
560  if (bit == 0)
561  dst[byte] = 0;
562  if (src[xi])
563  dst[byte] |= 128 >> bit;
564  }
565  }
566  }
567  const uchar *bitmap_data = bitmap.bits();
568  QFixedPoint offset = glyphs.offsets[i];
569  advanceX += offset.x;
570  advanceY += offset.y;
571  qt_addBitmapToPath((advanceX + metrics.x).toReal(), (advanceY + metrics.y).toReal(), bitmap_data, bitmap.bytesPerLine(), w, h, path);
572  advanceX += glyphs.advances_x[i];
573  advanceY += glyphs.advances_y[i];
574  }
575 }
QFixed * advances_y
virtual QImage alphaMapForGlyph(glyph_t)
int value() const
Definition: qfixed_p.h:73
QFixed * advances_x
HB_Glyph * glyphs
int bytesPerLine() const
Returns the number of bytes per image scanline.
Definition: qimage.cpp:1812
Q_GUI_EXPORT void qt_addBitmapToPath(qreal x0, qreal y0, const uchar *image_data, int bpl, int w, int h, QPainterPath *path)
static QFixed fromReal(qreal r)
Definition: qfixed_p.h:70
unsigned char uchar
Definition: qglobal.h:994
QFixed y
Definition: qfixed_p.h:191
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
QFixed x
Definition: qfixed_p.h:190
uchar * bits()
Returns a pointer to the first pixel data.
Definition: qimage.cpp:1946
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
QFixedPoint * offsets
#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
static qreal toReal(Register *reg, int type, bool *ok=0)

◆ addGlyphsToPath()

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

Reimplemented in QFontEngineFT, QFontEngineDirectWrite, QCoreTextFontEngine, QFontEngineWin, QProxyFontEngine, and QFontEngineMac.

Definition at line 577 of file qfontengine.cpp.

Referenced by QProxyFontEngine::addGlyphsToPath(), addOutlineToPath(), alphaMapForGlyph(), alphaMapFromPath(), QTextureGlyphCache::calculateSubPixelPositionCount(), QPaintEngineEx::drawStaticTextItem(), getUnscaledGlyph(), and QRawFont::pathForGlyph().

579 {
580  qreal x = positions[0].x.toReal();
581  qreal y = positions[0].y.toReal();
582  QVarLengthGlyphLayoutArray g(nGlyphs);
583 
584  for (int i = 0; i < nGlyphs; ++i) {
585  g.glyphs[i] = glyphs[i];
586  if (i < nGlyphs - 1) {
587  g.advances_x[i] = positions[i+1].x - positions[i].x;
588  g.advances_y[i] = positions[i+1].y - positions[i].y;
589  } else {
590  g.advances_x[i] = QFixed::fromReal(maxCharWidth());
591  g.advances_y[i] = 0;
592  }
593  }
594 
595  addBitmapFontToPath(x, y, g, path, flags);
596 }
double qreal
Definition: qglobal.h:1193
static QFixed fromReal(qreal r)
Definition: qfixed_p.h:70
virtual qreal maxCharWidth() const =0
QFixed y
Definition: qfixed_p.h:191
QFixed x
Definition: qfixed_p.h:190
qreal toReal() const
Definition: qfixed_p.h:77
void addBitmapFontToPath(qreal x, qreal y, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags)

◆ addOutlineToPath()

void QFontEngine::addOutlineToPath ( qreal  x,
qreal  y,
const QGlyphLayout glyphs,
QPainterPath path,
QTextItem::RenderFlags  flags 
)
virtual

Reimplemented in QFontEngineMulti, QFontEngineBox, QFontEngineQPF1, QFontEngineFT, QFontEngineQPF, QFontEngineQPA, QFontEngineXLFD, and QFontEngineWin.

Definition at line 419 of file qfontengine.cpp.

Referenced by QFontEngineWin::addOutlineToPath(), QFontEngineQPF::addOutlineToPath(), QFontEngineFT::addOutlineToPath(), QPainterPath::addText(), and QPaintEngine::drawTextItem().

421 {
422  if (!glyphs.numGlyphs)
423  return;
424 
426  QVarLengthArray<glyph_t> positioned_glyphs;
427  QTransform matrix = QTransform::fromTranslate(x, y);
428  getGlyphPositions(glyphs, matrix, flags, positioned_glyphs, positions);
429  addGlyphsToPath(positioned_glyphs.data(), positions.data(), positioned_glyphs.size(), path, flags);
430 }
static const QCssKnownValue positions[NumKnownPositionModes - 1]
Definition: qcssparser.cpp:329
void getGlyphPositions(const QGlyphLayout &glyphs, const QTransform &matrix, QTextItem::RenderFlags flags, QVarLengthArray< glyph_t > &glyphs_out, QVarLengthArray< QFixedPoint > &positions)
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags)
static QTransform fromTranslate(qreal dx, qreal dy)
Creates a matrix which corresponds to a translation of dx along the x axis and dy along the y axis...
Definition: qtransform.cpp:462
int size() const
The QTransform class specifies 2D transformations of a coordinate system.
Definition: qtransform.h:65

◆ alphaMapBoundingBox()

virtual glyph_metrics_t QFontEngine::alphaMapBoundingBox ( glyph_t  glyph,
QFixed  ,
const QTransform matrix,
GlyphFormat   
)
inlinevirtual

Reimplemented in QFontEngineFT, and QFontEngineDirectWrite.

Definition at line 204 of file qfontengine_p.h.

Referenced by QTextureGlyphCache::populate().

205  {
206  return boundingBox(glyph, matrix);
207  }
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0

◆ alphaMapForGlyph() [1/4]

QImage QFontEngine::alphaMapForGlyph ( glyph_t  glyph)
virtual

Create a qimage with the alpha values for the glyph. Returns an image indexed_8 with index values ranging from 0=fully transparent to 255=opaque

Reimplemented in QFontEngineMulti, QFontEngineBox, QFontEngineQPF1, QFontEngineFT, QFontEngineQPF, QFontEngineQPA, QFontEngineXLFD, QFontEngineWin, QFontEngineMac, and QProxyFontEngine.

Definition at line 645 of file qfontengine.cpp.

Referenced by addBitmapFontToPath(), QRawFont::alphaMapForGlyph(), alphaMapForGlyph(), QFontEngineFT::alphaMapForGlyph(), alphaRGBMapForGlyph(), QGLGlyphCache::cacheGlyphs(), QRasterPaintEngine::drawTextItem(), QVGFontEngineCleaner::fontEngineDestroyed(), QFontEngineQPF::loadGlyph(), and QTextureGlyphCache::textureMapForGlyph().

646 {
647  glyph_metrics_t gm = boundingBox(glyph);
648  int glyph_x = qFloor(gm.x.toReal());
649  int glyph_y = qFloor(gm.y.toReal());
650  int glyph_width = qCeil((gm.x + gm.width).toReal()) - glyph_x;
651  int glyph_height = qCeil((gm.y + gm.height).toReal()) - glyph_y;
652 
653  if (glyph_width <= 0 || glyph_height <= 0)
654  return QImage();
655  QFixedPoint pt;
656  pt.x = -glyph_x;
657  pt.y = -glyph_y; // the baseline
658  QPainterPath path;
659  QImage im(glyph_width + 4, glyph_height, QImage::Format_ARGB32_Premultiplied);
660  im.fill(Qt::transparent);
661  QPainter p(&im);
662  p.setRenderHint(QPainter::Antialiasing);
663  addGlyphsToPath(&glyph, &pt, 1, &path, 0);
664  p.setPen(Qt::NoPen);
665  p.setBrush(Qt::black);
666  p.drawPath(path);
667  p.end();
668 
669  QImage indexed(im.width(), im.height(), QImage::Format_Indexed8);
670  QVector<QRgb> colors(256);
671  for (int i=0; i<256; ++i)
672  colors[i] = qRgba(0, 0, 0, i);
673  indexed.setColorTable(colors);
674 
675  for (int y=0; y<im.height(); ++y) {
676  uchar *dst = (uchar *) indexed.scanLine(y);
677  uint *src = (uint *) im.scanLine(y);
678  for (int x=0; x<im.width(); ++x)
679  dst[x] = qAlpha(src[x]);
680  }
681 
682  return indexed;
683 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
int qCeil(qreal v)
Definition: qmath.h:63
Q_GUI_EXPORT_INLINE int qAlpha(QRgb rgb)
Definition: qrgb.h:66
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
int qFloor(qreal v)
Definition: qmath.h:73
unsigned char uchar
Definition: qglobal.h:994
Q_GUI_EXPORT_INLINE QRgb qRgba(int r, int g, int b, int a)
Definition: qrgb.h:72
QFixed y
Definition: qfixed_p.h:191
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
unsigned int uint
Definition: qglobal.h:996
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags)
QFixed x
Definition: qfixed_p.h:190
qreal toReal() const
Definition: qfixed_p.h:77

◆ alphaMapForGlyph() [2/4]

QImage QFontEngine::alphaMapForGlyph ( glyph_t  glyph,
QFixed  subPixelPosition 
)
virtual

Reimplemented in QFontEngineFT, and QCoreTextFontEngine.

Definition at line 598 of file qfontengine.cpp.

599 {
600  // For font engines don't support subpixel positioning
601  return alphaMapForGlyph(glyph);
602 }
virtual QImage alphaMapForGlyph(glyph_t)

◆ alphaMapForGlyph() [3/4]

QImage QFontEngine::alphaMapForGlyph ( glyph_t  glyph,
const QTransform t 
)
virtual

Reimplemented in QFontEngineWin.

Definition at line 604 of file qfontengine.cpp.

605 {
606  QImage i = alphaMapForGlyph(glyph);
607  if (t.type() > QTransform::TxTranslate)
609  Q_ASSERT(i.depth() <= 8); // To verify that transformed didn't change the format...
610 
611  return i;
612 }
virtual QImage alphaMapForGlyph(glyph_t)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
TransformationType type() const
Returns the transformation type of this matrix.
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
QImage transformed(const QMatrix &matrix, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a copy of the image that is transformed using the given transformation matrix and transformat...
Definition: qimage.cpp:4698
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966

◆ alphaMapForGlyph() [4/4]

QImage QFontEngine::alphaMapForGlyph ( glyph_t  glyph,
QFixed  subPixelPosition,
const QTransform t 
)
virtual

Reimplemented in QFontEngineDirectWrite.

Definition at line 614 of file qfontengine.cpp.

615 {
617  return alphaMapForGlyph(glyph, t);
618 
619  QImage i = alphaMapForGlyph(glyph, subPixelPosition);
620  if (t.type() > QTransform::TxTranslate)
622  Q_ASSERT(i.depth() <= 8); // To verify that transformed didn't change the format...
623 
624  return i;
625 }
virtual QImage alphaMapForGlyph(glyph_t)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
TransformationType type() const
Returns the transformation type of this matrix.
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
int depth() const
Returns the depth of the image.
Definition: qimage.cpp:1620
QImage transformed(const QMatrix &matrix, Qt::TransformationMode mode=Qt::FastTransformation) const
Returns a copy of the image that is transformed using the given transformation matrix and transformat...
Definition: qimage.cpp:4698
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
Definition: qimage.cpp:3966
virtual bool supportsSubPixelPositions() const

◆ alphaRGBMapForGlyph()

QImage QFontEngine::alphaRGBMapForGlyph ( glyph_t  glyph,
QFixed  subPixelPosition,
int  margin,
const QTransform t 
)
virtual

Reimplemented in QFontEngineFT, QFontEngineWin, QFontEngineDirectWrite, QCoreTextFontEngine, and QFontEngineMac.

Definition at line 627 of file qfontengine.cpp.

Referenced by QRawFont::alphaMapForGlyph(), QFontEngineFT::alphaRGBMapForGlyph(), and QTextureGlyphCache::textureMapForGlyph().

628 {
629  QImage alphaMask = alphaMapForGlyph(glyph, t);
630  QImage rgbMask(alphaMask.width(), alphaMask.height(), QImage::Format_RGB32);
631 
632  QVector<QRgb> colorTable = alphaMask.colorTable();
633  for (int y=0; y<alphaMask.height(); ++y) {
634  uint *dst = (uint *) rgbMask.scanLine(y);
635  uchar *src = (uchar *) alphaMask.scanLine(y);
636  for (int x=0; x<alphaMask.width(); ++x) {
637  int val = qAlpha(colorTable.at(src[x]));
638  dst[x] = qRgb(val, val, val);
639  }
640  }
641 
642  return rgbMask;
643 }
virtual QImage alphaMapForGlyph(glyph_t)
Q_GUI_EXPORT_INLINE int qAlpha(QRgb rgb)
Definition: qrgb.h:66
unsigned char uchar
Definition: qglobal.h:994
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87
unsigned int uint
Definition: qglobal.h:996
int width() const
Returns the width of the image.
Definition: qimage.cpp:1557
Q_GUI_EXPORT_INLINE QRgb qRgb(int r, int g, int b)
Definition: qrgb.h:69
int height() const
Returns the height of the image.
Definition: qimage.cpp:1572
QVector< QRgb > colorTable() const
Returns a list of the colors contained in the image&#39;s color table, or an empty list if the image does...
Definition: qimage.cpp:1770
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
Definition: qimage.cpp:1886

◆ ascent()

virtual QFixed QFontEngine::ascent ( ) const
pure virtual

◆ averageCharWidth()

QFixed QFontEngine::averageCharWidth ( ) const
virtual

Reimplemented in QFontEngineMulti, QFontEngineFT, QFontEngineWin, QProxyFontEngine, QCoreTextFontEngine, and QFontEngineMac.

Definition at line 257 of file qfontengine.cpp.

Referenced by QFontMetrics::averageCharWidth(), QRawFont::averageCharWidth(), QFontMetricsF::averageCharWidth(), QFontEngineFT::averageCharWidth(), and QTextLine::layout_helper().

258 {
259  QGlyphLayoutArray<8> glyphs;
260  int nglyphs = 7;
261  QChar x((ushort)'x');
262  stringToCMap(&x, 1, &glyphs, &nglyphs, QTextEngine::GlyphIndicesOnly);
263 
264  glyph_metrics_t bb = const_cast<QFontEngine *>(this)->boundingBox(glyphs.glyphs[0]);
265  return bb.xoff;
266 }
HB_Glyph * glyphs
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const =0
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
unsigned short ushort
Definition: qglobal.h:995

◆ boundingBox() [1/3]

virtual glyph_metrics_t QFontEngine::boundingBox ( const QGlyphLayout glyphs)
pure virtual

◆ boundingBox() [2/3]

virtual glyph_metrics_t QFontEngine::boundingBox ( glyph_t  glyph)
pure virtual

◆ boundingBox() [3/3]

glyph_metrics_t QFontEngine::boundingBox ( glyph_t  glyph,
const QTransform matrix 
)
virtual

Reimplemented in QFontEngineFT, and QFontEngineWin.

Definition at line 236 of file qfontengine.cpp.

237 {
238  glyph_metrics_t metrics = boundingBox(glyph);
239 
240  if (matrix.type() > QTransform::TxTranslate) {
241  return metrics.transformed(matrix);
242  }
243  return metrics;
244 }
TransformationType type() const
Returns the transformation type of this matrix.
glyph_metrics_t transformed(const QTransform &xform) const
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0

◆ canRender()

virtual bool QFontEngine::canRender ( const QChar string,
int  len 
)
pure virtual

◆ cloneWithSize()

virtual QFontEngine* QFontEngine::cloneWithSize ( qreal  ) const
inlinevirtual

◆ convertToPostscriptFontFamilyName()

QByteArray QFontEngine::convertToPostscriptFontFamilyName ( const QByteArray fontFamily)
static

Definition at line 1104 of file qfontengine.cpp.

Referenced by QFontEngineWin::properties(), QFontEngineMac::properties(), properties(), and QFontEngineFT::properties().

1105 {
1106  QByteArray f = family;
1107  f.replace(' ', "");
1108  f.replace('(', "");
1109  f.replace(')', "");
1110  f.replace('<', "");
1111  f.replace('>', "");
1112  f.replace('[', "");
1113  f.replace(']', "");
1114  f.replace('{', "");
1115  f.replace('}', "");
1116  f.replace('/', "");
1117  f.replace('%', "");
1118  return f;
1119 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QByteArray & replace(int index, int len, const char *s)
This is an overloaded member function, provided for convenience. It differs from the above function o...

◆ descent()

virtual QFixed QFontEngine::descent ( ) const
pure virtual

◆ doKerning()

void QFontEngine::doKerning ( QGlyphLayout glyphs,
QTextEngine::ShaperFlags  flags 
) const
virtual

Reimplemented in QFontEngineMulti, QFontEngineFT, QFontEngineQPF, and QFontEngineMacMulti.

Definition at line 785 of file qfontengine.cpp.

Referenced by QFontEngineQPF::doKerning(), QFontEngineFT::doKerning(), loadKerningPairs(), and QTextEngine::shapeTextWithHarfbuzz().

786 {
787  int numPairs = kerning_pairs.size();
788  if(!numPairs)
789  return;
790 
791  const KernPair *pairs = kerning_pairs.constData();
792 
793  if(flags & QTextEngine::DesignMetrics) {
794  for(int i = 0; i < glyphs->numGlyphs - 1; ++i)
795  glyphs->advances_x[i] += kerning(glyphs->glyphs[i], glyphs->glyphs[i+1] , pairs, numPairs);
796  } else {
797  for(int i = 0; i < glyphs->numGlyphs - 1; ++i)
798  glyphs->advances_x[i] += qRound(kerning(glyphs->glyphs[i], glyphs->glyphs[i+1] , pairs, numPairs));
799  }
800 }
QFixed * advances_x
HB_Glyph * glyphs
QVector< KernPair > kerning_pairs
static QFixed kerning(int left, int right, const QFontEngine::KernPair *pairs, int numPairs)
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ emSquareSize()

virtual QFixed QFontEngine::emSquareSize ( ) const
inlinevirtual

◆ faceId()

virtual FaceId QFontEngine::faceId ( ) const
inlinevirtual

Reimplemented in QFontEngineFT, QFontEngineQPF, QFontEngineQPA, QCoreTextFontEngine, QFontEngineXLFD, QFontEngineMac, and QFontEngineWin.

Definition at line 162 of file qfontengine_p.h.

Referenced by QPdfBaseEnginePrivate::drawTextItem().

162 { return FaceId(); }

◆ getCMap()

const uchar * QFontEngine::getCMap ( const uchar table,
uint  tableSize,
bool *  isSymbolFont,
int *  cmapSize 
)
static

Definition at line 878 of file qfontengine.cpp.

Referenced by QFontEngineWin::getCMap(), QFontEngineQPA::QFontEngineQPA(), QFontEngineQPF::QFontEngineQPF(), and QFontEngineMac::stringToCMap().

879 {
880  const uchar *header = table;
881  if (tableSize < 4)
882  return 0;
883 
884  const uchar *endPtr = table + tableSize;
885 
886  // version check
887  if (qFromBigEndian<quint16>(header) != 0)
888  return 0;
889 
890  unsigned short numTables = qFromBigEndian<quint16>(header + 2);
891  const uchar *maps = table + 4;
892  if (maps + 8 * numTables > endPtr)
893  return 0;
894 
895  enum {
896  Invalid,
897  AppleRoman,
898  Symbol,
899  Unicode11,
900  Unicode,
901  MicrosoftUnicode,
902  MicrosoftUnicodeExtended
903  };
904 
905  int symbolTable = -1;
906  int tableToUse = -1;
907  int score = Invalid;
908  for (int n = 0; n < numTables; ++n) {
909  const quint16 platformId = qFromBigEndian<quint16>(maps + 8 * n);
910  const quint16 platformSpecificId = qFromBigEndian<quint16>(maps + 8 * n + 2);
911  switch (platformId) {
912  case 0: // Unicode
913  if (score < Unicode &&
914  (platformSpecificId == 0 ||
915  platformSpecificId == 2 ||
916  platformSpecificId == 3)) {
917  tableToUse = n;
918  score = Unicode;
919  } else if (score < Unicode11 && platformSpecificId == 1) {
920  tableToUse = n;
921  score = Unicode11;
922  }
923  break;
924  case 1: // Apple
925  if (score < AppleRoman && platformSpecificId == 0) { // Apple Roman
926  tableToUse = n;
927  score = AppleRoman;
928  }
929  break;
930  case 3: // Microsoft
931  switch (platformSpecificId) {
932  case 0:
933  symbolTable = n;
934  if (score < Symbol) {
935  tableToUse = n;
936  score = Symbol;
937  }
938  break;
939  case 1:
940  if (score < MicrosoftUnicode) {
941  tableToUse = n;
942  score = MicrosoftUnicode;
943  }
944  break;
945  case 0xa:
946  if (score < MicrosoftUnicodeExtended) {
947  tableToUse = n;
948  score = MicrosoftUnicodeExtended;
949  }
950  break;
951  default:
952  break;
953  }
954  default:
955  break;
956  }
957  }
958  if(tableToUse < 0)
959  return 0;
960 
961 resolveTable:
962  *isSymbolFont = (symbolTable > -1);
963 
964  unsigned int unicode_table = qFromBigEndian<quint32>(maps + 8*tableToUse + 4);
965 
966  if (!unicode_table || unicode_table + 8 > tableSize)
967  return 0;
968 
969  // get the header of the unicode table
970  header = table + unicode_table;
971 
972  unsigned short format = qFromBigEndian<quint16>(header);
973  unsigned int length;
974  if(format < 8)
975  length = qFromBigEndian<quint16>(header + 2);
976  else
977  length = qFromBigEndian<quint32>(header + 4);
978 
979  if (table + unicode_table + length > endPtr)
980  return 0;
981  *cmapSize = length;
982 
983  // To support symbol fonts that contain a unicode table for the symbol area
984  // we check the cmap tables and fall back to symbol font unless that would
985  // involve losing information from the unicode table
986  if (symbolTable > -1 && ((score == Unicode) || (score == Unicode11))) {
987  const uchar *selectedTable = table + unicode_table;
988 
989  // Check that none of the latin1 range are in the unicode table
990  bool unicodeTableHasLatin1 = false;
991  for (int uc=0x00; uc<0x100; ++uc) {
992  if (getTrueTypeGlyphIndex(selectedTable, uc) != 0) {
993  unicodeTableHasLatin1 = true;
994  break;
995  }
996  }
997 
998  // Check that at least one symbol char is in the unicode table
999  bool unicodeTableHasSymbols = false;
1000  if (!unicodeTableHasLatin1) {
1001  for (int uc=0xf000; uc<0xf100; ++uc) {
1002  if (getTrueTypeGlyphIndex(selectedTable, uc) != 0) {
1003  unicodeTableHasSymbols = true;
1004  break;
1005  }
1006  }
1007  }
1008 
1009  // Fall back to symbol table
1010  if (!unicodeTableHasLatin1 && unicodeTableHasSymbols) {
1011  tableToUse = symbolTable;
1012  score = Symbol;
1013  goto resolveTable;
1014  }
1015  }
1016 
1017  return table + unicode_table;
1018 }
quint32 qFromBigEndian< quint32 >(const uchar *src)
Definition: qendian.h:239
static quint32 getTrueTypeGlyphIndex(const uchar *cmap, uint unicode)
unsigned char uchar
Definition: qglobal.h:994
unsigned short quint16
Definition: qglobal.h:936
quint16 qFromBigEndian< quint16 >(const uchar *src)
Definition: qendian.h:249

◆ getGlyphBearings()

void QFontEngine::getGlyphBearings ( glyph_t  glyph,
qreal leftBearing = 0,
qreal rightBearing = 0 
)
virtual

Reimplemented in QFontEngineMulti, and QFontEngineWin.

Definition at line 385 of file qfontengine.cpp.

Referenced by QFontEngineWin::getGlyphBearings(), QFontMetrics::leftBearing(), QFontMetricsF::leftBearing(), QFontMetrics::rightBearing(), and QFontMetricsF::rightBearing().

386 {
387  glyph_metrics_t gi = boundingBox(glyph);
388  bool isValid = gi.isValid();
389  if (leftBearing != 0)
390  *leftBearing = isValid ? gi.x.toReal() : qreal(0.0);
391  if (rightBearing != 0)
392  *rightBearing = isValid ? (gi.xoff - gi.x - gi.width).toReal() : qreal(0.0);
393 }
double qreal
Definition: qglobal.h:1193
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
bool isValid() const
qreal toReal() const
Definition: qfixed_p.h:77
static qreal toReal(Register *reg, int type, bool *ok=0)

◆ getGlyphPositions()

void QFontEngine::getGlyphPositions ( const QGlyphLayout glyphs,
const QTransform matrix,
QTextItem::RenderFlags  flags,
QVarLengthArray< glyph_t > &  glyphs_out,
QVarLengthArray< QFixedPoint > &  positions 
)

Definition at line 269 of file qfontengine.cpp.

Referenced by addOutlineToPath(), QFontEngineBox::addOutlineToPath(), QFontEngineBox::boundingBox(), QProxyFontEngine::canRender(), QFontEngineMac::draw(), QFontEngineQPF::draw(), draw_text_item_win(), QPaintEnginePrivate::drawBoxTextItem(), QRasterPaintEngine::drawCachedGlyphs(), QX11PaintEngine::drawFreetype(), QGL2PaintEngineEx::drawTextItem(), QOpenGLPaintEngine::drawTextItem(), QVGPaintEngine::drawTextItem(), QRasterPaintEngine::drawTextItem(), QPdfBaseEnginePrivate::drawTextItem(), QX11PaintEngine::drawXLFD(), QStaticTextPrivate::get(), and QTextLine::glyphs().

271 {
272  QFixed xpos;
273  QFixed ypos;
274 
275  const bool transform = matrix.m11() != 1.
276  || matrix.m12() != 0.
277  || matrix.m21() != 0.
278  || matrix.m22() != 1.;
279  if (!transform) {
280  xpos = QFixed::fromReal(matrix.dx());
281  ypos = QFixed::fromReal(matrix.dy());
282  }
283 
284  int current = 0;
285  if (flags & QTextItem::RightToLeft) {
286  int i = glyphs.numGlyphs;
287  int totalKashidas = 0;
288  while(i--) {
289  if (glyphs.attributes[i].dontPrint)
290  continue;
291  xpos += glyphs.advances_x[i] + QFixed::fromFixed(glyphs.justifications[i].space_18d6);
292  ypos += glyphs.advances_y[i];
293  totalKashidas += glyphs.justifications[i].nKashidas;
294  }
295  positions.resize(glyphs.numGlyphs+totalKashidas);
296  glyphs_out.resize(glyphs.numGlyphs+totalKashidas);
297 
298  i = 0;
299  while(i < glyphs.numGlyphs) {
300  if (glyphs.attributes[i].dontPrint) {
301  ++i;
302  continue;
303  }
304  xpos -= glyphs.advances_x[i];
305  ypos -= glyphs.advances_y[i];
306 
307  QFixed gpos_x = xpos + glyphs.offsets[i].x;
308  QFixed gpos_y = ypos + glyphs.offsets[i].y;
309  if (transform) {
310  QPointF gpos(gpos_x.toReal(), gpos_y.toReal());
311  gpos = gpos * matrix;
312  gpos_x = QFixed::fromReal(gpos.x());
313  gpos_y = QFixed::fromReal(gpos.y());
314  }
315  positions[current].x = gpos_x;
316  positions[current].y = gpos_y;
317  glyphs_out[current] = glyphs.glyphs[i];
318  ++current;
319  if (glyphs.justifications[i].nKashidas) {
320  QChar ch(0x640); // Kashida character
322  int nglyphs = 7;
323  stringToCMap(&ch, 1, &g, &nglyphs, 0);
324  for (uint k = 0; k < glyphs.justifications[i].nKashidas; ++k) {
325  xpos -= g.advances_x[0];
326  ypos -= g.advances_y[0];
327 
328  QFixed gpos_x = xpos + glyphs.offsets[i].x;
329  QFixed gpos_y = ypos + glyphs.offsets[i].y;
330  if (transform) {
331  QPointF gpos(gpos_x.toReal(), gpos_y.toReal());
332  gpos = gpos * matrix;
333  gpos_x = QFixed::fromReal(gpos.x());
334  gpos_y = QFixed::fromReal(gpos.y());
335  }
336  positions[current].x = gpos_x;
337  positions[current].y = gpos_y;
338  glyphs_out[current] = g.glyphs[0];
339  ++current;
340  }
341  } else {
342  xpos -= QFixed::fromFixed(glyphs.justifications[i].space_18d6);
343  }
344  ++i;
345  }
346  } else {
347  positions.resize(glyphs.numGlyphs);
348  glyphs_out.resize(glyphs.numGlyphs);
349  int i = 0;
350  if (!transform) {
351  while (i < glyphs.numGlyphs) {
352  if (!glyphs.attributes[i].dontPrint) {
353  positions[current].x = xpos + glyphs.offsets[i].x;
354  positions[current].y = ypos + glyphs.offsets[i].y;
355  glyphs_out[current] = glyphs.glyphs[i];
356  xpos += glyphs.advances_x[i] + QFixed::fromFixed(glyphs.justifications[i].space_18d6);
357  ypos += glyphs.advances_y[i];
358  ++current;
359  }
360  ++i;
361  }
362  } else {
363  while (i < glyphs.numGlyphs) {
364  if (!glyphs.attributes[i].dontPrint) {
365  QFixed gpos_x = xpos + glyphs.offsets[i].x;
366  QFixed gpos_y = ypos + glyphs.offsets[i].y;
367  QPointF gpos(gpos_x.toReal(), gpos_y.toReal());
368  gpos = gpos * matrix;
369  positions[current].x = QFixed::fromReal(gpos.x());
370  positions[current].y = QFixed::fromReal(gpos.y());
371  glyphs_out[current] = glyphs.glyphs[i];
372  xpos += glyphs.advances_x[i] + QFixed::fromFixed(glyphs.justifications[i].space_18d6);
373  ypos += glyphs.advances_y[i];
374  ++current;
375  }
376  ++i;
377  }
378  }
379  }
380  positions.resize(current);
381  glyphs_out.resize(current);
382  Q_ASSERT(positions.size() == glyphs_out.size());
383 }
void resize(int size)
qreal dy() const
Returns the vertical translation factor.
Definition: qtransform.h:277
QGlyphJustification * justifications
QFixed * advances_y
static QFixed fromFixed(int fixed)
Definition: qfixed_p.h:71
QFixed * advances_x
HB_Glyph * glyphs
qreal m21() const
Returns the horizontal shearing factor.
Definition: qtransform.h:249
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal m22() const
Returns the vertical scaling factor.
Definition: qtransform.h:253
static QFixed fromReal(qreal r)
Definition: qfixed_p.h:70
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const =0
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
qreal m12() const
Returns the vertical shearing factor.
Definition: qtransform.h:241
QFixed y
Definition: qfixed_p.h:191
unsigned int uint
Definition: qglobal.h:996
QFixed x
Definition: qfixed_p.h:190
qreal toReal() const
Definition: qfixed_p.h:77
qreal dx() const
Returns the horizontal translation factor.
Definition: qtransform.h:273
HB_GlyphAttributes * attributes
QFixedPoint * offsets
qreal m11() const
Returns the horizontal scaling factor.
Definition: qtransform.h:237
int size() const

◆ getPointInOutline()

HB_Error QFontEngine::getPointInOutline ( HB_Glyph  glyph,
int  flags,
hb_uint32  point,
HB_Fixed *  xpos,
HB_Fixed *  ypos,
hb_uint32 *  nPoints 
)
virtual

Reimplemented in QFontEngineFT, and QFontEngineQPF.

Definition at line 144 of file qfontengine.cpp.

Referenced by hb_getPointInOutline().

145 {
146  Q_UNUSED(glyph)
147  Q_UNUSED(flags)
148  Q_UNUSED(point)
149  Q_UNUSED(xpos)
150  Q_UNUSED(ypos)
151  Q_UNUSED(nPoints)
152  return HB_Err_Not_Covered;
153 }
#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

◆ getSfntTable()

QByteArray QFontEngine::getSfntTable ( uint  tag) const

Definition at line 719 of file qfontengine.cpp.

Referenced by QRawFont::fontTable(), glyphCount(), loadKerningPairs(), loadSingleEngine(), QFontEngineQPF::QFontEngineQPF(), and QFontSubset::toTruetype().

720 {
721  QByteArray table;
722  uint len = 0;
723  if (!getSfntTableData(tag, 0, &len))
724  return table;
725  if (!len)
726  return table;
727  table.resize(len);
728  if (!getSfntTableData(tag, reinterpret_cast<uchar *>(table.data()), &len))
729  return QByteArray();
730  return table;
731 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
unsigned int uint
Definition: qglobal.h:996
virtual bool getSfntTableData(uint, uchar *, uint *) const
void resize(int size)
Sets the size of the byte array to size bytes.

◆ getSfntTableData()

virtual bool QFontEngine::getSfntTableData ( uint  ,
uchar ,
uint  
) const
inlinevirtual

Reimplemented in QFontEngineFT, QFontEngineQPF, QFontEngineQPA, QCoreTextFontEngine, QFontEngineXLFD, QFontEngineDirectWrite, and QFontEngineWin.

Definition at line 153 of file qfontengine_p.h.

Referenced by getSfntTable(), and hb_getSFntTable().

153 { return false; }

◆ getTrueTypeGlyphIndex()

quint32 QFontEngine::getTrueTypeGlyphIndex ( const uchar cmap,
uint  unicode 
)
static

Definition at line 1020 of file qfontengine.cpp.

Referenced by QFontEngineQPA::canRender(), QFontEngineQPF::canRender(), getCMap(), QFontEngineMac::stringToCMap(), QFontEngineQPA::stringToCMap(), and QFontEngineQPF::stringToCMap().

1021 {
1022  unsigned short format = qFromBigEndian<quint16>(cmap);
1023  if (format == 0) {
1024  if (unicode < 256)
1025  return (int) *(cmap+6+unicode);
1026  } else if (format == 4) {
1027  /* some fonts come with invalid cmap tables, where the last segment
1028  specified end = start = rangeoffset = 0xffff, delta = 0x0001
1029  Since 0xffff is never a valid Unicode char anyway, we just get rid of the issue
1030  by returning 0 for 0xffff
1031  */
1032  if(unicode >= 0xffff)
1033  return 0;
1034  quint16 segCountX2 = qFromBigEndian<quint16>(cmap + 6);
1035  const unsigned char *ends = cmap + 14;
1036  int i = 0;
1037  for (; i < segCountX2/2 && qFromBigEndian<quint16>(ends + 2*i) < unicode; i++) {}
1038 
1039  const unsigned char *idx = ends + segCountX2 + 2 + 2*i;
1040  quint16 startIndex = qFromBigEndian<quint16>(idx);
1041 
1042  if (startIndex > unicode)
1043  return 0;
1044 
1045  idx += segCountX2;
1046  qint16 idDelta = (qint16)qFromBigEndian<quint16>(idx);
1047  idx += segCountX2;
1048  quint16 idRangeoffset_t = (quint16)qFromBigEndian<quint16>(idx);
1049 
1050  quint16 glyphIndex;
1051  if (idRangeoffset_t) {
1052  quint16 id = qFromBigEndian<quint16>(idRangeoffset_t + 2*(unicode - startIndex) + idx);
1053  if (id)
1054  glyphIndex = (idDelta + id) % 0x10000;
1055  else
1056  glyphIndex = 0;
1057  } else {
1058  glyphIndex = (idDelta + unicode) % 0x10000;
1059  }
1060  return glyphIndex;
1061  } else if (format == 6) {
1062  quint16 tableSize = qFromBigEndian<quint16>(cmap + 2);
1063 
1064  quint16 firstCode6 = qFromBigEndian<quint16>(cmap + 6);
1065  if (unicode < firstCode6)
1066  return 0;
1067 
1068  quint16 entryCount6 = qFromBigEndian<quint16>(cmap + 8);
1069  if (entryCount6 * 2 + 10 > tableSize)
1070  return 0;
1071 
1072  quint16 sentinel6 = firstCode6 + entryCount6;
1073  if (unicode >= sentinel6)
1074  return 0;
1075 
1076  quint16 entryIndex6 = unicode - firstCode6;
1077  return qFromBigEndian<quint16>(cmap + 10 + (entryIndex6 * 2));
1078  } else if (format == 12) {
1079  quint32 nGroups = qFromBigEndian<quint32>(cmap + 12);
1080 
1081  cmap += 16; // move to start of groups
1082 
1083  int left = 0, right = nGroups - 1;
1084  while (left <= right) {
1085  int middle = left + ( ( right - left ) >> 1 );
1086 
1087  quint32 startCharCode = qFromBigEndian<quint32>(cmap + 12*middle);
1088  if(unicode < startCharCode)
1089  right = middle - 1;
1090  else {
1091  quint32 endCharCode = qFromBigEndian<quint32>(cmap + 12*middle + 4);
1092  if(unicode <= endCharCode)
1093  return qFromBigEndian<quint32>(cmap + 12*middle + 8) + unicode - startCharCode;
1094  left = middle + 1;
1095  }
1096  }
1097  } else {
1098  qDebug("cmap table of format %d not implemented", format);
1099  }
1100 
1101  return 0;
1102 }
static QColor cmap[256]
Definition: qgl_mac.mm:760
quint32 qFromBigEndian< quint32 >(const uchar *src)
Definition: qendian.h:239
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_CORE_EXPORT void qDebug(const char *,...)
short qint16
Definition: qglobal.h:935
unsigned short quint16
Definition: qglobal.h:936
quint16 qFromBigEndian< quint16 >(const uchar *src)
Definition: qendian.h:249
unsigned int quint32
Definition: qglobal.h:938
Q_CORE_EXPORT QTextStream & left(QTextStream &s)

◆ getUnscaledGlyph()

void QFontEngine::getUnscaledGlyph ( glyph_t  glyph,
QPainterPath path,
glyph_metrics_t metrics 
)
virtual

Reimplemented in QFontEngineFT, QCoreTextFontEngine, QFontEngineXLFD, QFontEngineMac, and QFontEngineWin.

Definition at line 710 of file qfontengine.cpp.

Referenced by QVGFontEngineCleaner::fontEngineDestroyed(), QFontSubset::toTruetype(), and QFontSubset::type1AddedGlyphs().

711 {
712  *metrics = boundingBox(glyph);
713  QFixedPoint p;
714  p.x = 0;
715  p.y = 0;
716  addGlyphsToPath(&glyph, &p, 1, path, QFlag(0));
717 }
The QFlag class is a helper data type for QFlags.
Definition: qglobal.h:2289
QFixed y
Definition: qfixed_p.h:191
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags)
QFixed x
Definition: qfixed_p.h:190

◆ glyphCache()

QFontEngineGlyphCache * QFontEngine::glyphCache ( void *  key,
QFontEngineGlyphCache::Type  type,
const QTransform transform 
) const

Definition at line 752 of file qfontengine.cpp.

Referenced by QGL2PaintEngineExPrivate::drawCachedGlyphs(), and QRasterPaintEngine::drawCachedGlyphs().

753 {
754  for (QLinkedList<GlyphCacheEntry>::const_iterator it = m_glyphCaches.constBegin(), end = m_glyphCaches.constEnd(); it != end; ++it) {
755  QFontEngineGlyphCache *c = it->cache.data();
756  if (key == it->context
757  && type == c->cacheType()
758  && qtransform_equals_no_translate(c->m_transform, transform)) {
759  return c;
760  }
761  }
762  return 0;
763 }
unsigned char c[8]
Definition: qnumeric_p.h:62
#define it(className, varName)
QLinkedList< GlyphCacheEntry > m_glyphCaches
virtual Type type() const =0
The QLinkedList::const_iterator class provides an STL-style const iterator for QLinkedList.
Definition: qlinkedlist.h:151
static bool qtransform_equals_no_translate(const QTransform &a, const QTransform &b)
Definition: qfontengine.cpp:55
int key
static const KeyPair *const end

◆ glyphCount()

int QFontEngine::glyphCount ( ) const
virtual

Reimplemented in QFontEngineFT, QFontEngineQPF, QFontEngineQPA, and QProxyFontEngine.

Definition at line 870 of file qfontengine.cpp.

Referenced by QFontEngineMacMulti::stringToCMap().

871 {
872  QByteArray maxpTable = getSfntTable(MAKE_TAG('m', 'a', 'x', 'p'));
873  if (maxpTable.size() < 6)
874  return 0;
875  return qFromBigEndian<quint16>(reinterpret_cast<const uchar *>(maxpTable.constData() + 4));
876 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define MAKE_TAG(ch1, ch2, ch3, ch4)
unsigned char uchar
Definition: qglobal.h:994
quint16 qFromBigEndian< quint16 >(const uchar *src)
Definition: qendian.h:249
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
QByteArray getSfntTable(uint) const

◆ grayPalette()

static const QVector<QRgb>& QFontEngine::grayPalette ( )
staticprotected

◆ harfbuzzFace()

HB_Face QFontEngine::harfbuzzFace ( ) const

Definition at line 227 of file qfontengine.cpp.

Referenced by QFontconfigDatabase::fontEngine(), QBasicUnixFontDatabase::fontEngine(), loadEngine(), QTextEngine::shapeText(), QTextEngine::shapeTextWithHarfbuzz(), and tryPatternLoad().

228 {
229  if (!hbFace) {
230  hbFace = qHBNewFace(const_cast<QFontEngine *>(this), hb_getSFntTable);
232  }
233  return hbFace;
234 }
HB_Face hbFace
HB_Face qHBNewFace(void *font, HB_GetFontTableFunc tableFunc)
Definition: qharfbuzz.cpp:123
#define Q_CHECK_PTR(p)
Definition: qglobal.h:1853
static HB_Error hb_getSFntTable(void *font, HB_Tag tableTag, HB_Byte *buffer, HB_UInt *length)

◆ harfbuzzFont()

HB_Font QFontEngine::harfbuzzFont ( ) const

Definition at line 215 of file qfontengine.cpp.

Referenced by QTextEngine::shapeTextWithHarfbuzz().

216 {
217  if (!hbFont.x_ppem) {
218  QFixed emSquare = emSquareSize();
219  hbFont.x_ppem = fontDef.pixelSize;
220  hbFont.y_ppem = fontDef.pixelSize * fontDef.stretch / 100;
221  hbFont.x_scale = (QFixed(hbFont.x_ppem * (1 << 16)) / emSquare).value();
222  hbFont.y_scale = (QFixed(hbFont.y_ppem * (1 << 16)) / emSquare).value();
223  }
224  return &hbFont;
225 }
HB_FontRec hbFont
qreal pixelSize
Definition: qfont_p.h:90
virtual QFixed emSquareSize() const
uint stretch
Definition: qfont_p.h:98
QFontDef fontDef

◆ lastRightBearing()

QFixed QFontEngine::lastRightBearing ( const QGlyphLayout glyphs,
bool  round = false 
)
protected

Definition at line 1133 of file qfontengine.cpp.

Referenced by QFontEngineMac::boundingBox(), and QFontEngineDirectWrite::boundingBox().

1134 {
1135  if (glyphs.numGlyphs >= 1) {
1136  glyph_t glyph = glyphs.glyphs[glyphs.numGlyphs - 1];
1137  glyph_metrics_t gi = boundingBox(glyph);
1138  if (gi.isValid())
1139  return round ? QFixed(qRound(gi.xoff - gi.x - gi.width))
1140  : QFixed(gi.xoff - gi.x - gi.width);
1141  }
1142  return 0;
1143 }
HB_Glyph * glyphs
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
bool isValid() const
unsigned int glyph_t
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ leading()

virtual QFixed QFontEngine::leading ( ) const
pure virtual

◆ lineThickness()

QFixed QFontEngine::lineThickness ( ) const
virtual

Reimplemented in QFontEngineMulti, QFontEngineQPF1, QFontEngineFT, QFontEngineQPF, QFontEngineQPA, QProxyFontEngine, QFontEngineDirectWrite, and QFontEngineWin.

Definition at line 197 of file qfontengine.cpp.

Referenced by QPainterPath::addText(), QFontEngineBox::boundingBox(), QFontEngineMac::draw(), QTextLine::draw(), QPaintEnginePrivate::drawBoxTextItem(), QPdfBaseEnginePrivate::drawTextItem(), drawTextItemDecoration(), QFontEngineMac::imageForGlyph(), QFontEngineWin::lineThickness(), QFontEngineDirectWrite::lineThickness(), QFontMetrics::lineWidth(), QFontMetricsF::lineWidth(), properties(), and underlinePosition().

198 {
199  // ad hoc algorithm
200  int score = fontDef.weight * fontDef.pixelSize;
201  int lw = score / 700;
202 
203  // looks better with thicker line for small pointsizes
204  if (lw < 2 && score >= 1050) lw = 2;
205  if (lw == 0) lw = 1;
206 
207  return lw;
208 }
uint weight
Definition: qfont_p.h:95
qreal pixelSize
Definition: qfont_p.h:90
QFontDef fontDef

◆ loadKerningPairs()

void QFontEngine::loadKerningPairs ( QFixed  scalingFactor)

Definition at line 802 of file qfontengine.cpp.

Referenced by QFontEngineQPF::doKerning().

803 {
804  kerning_pairs.clear();
805 
806  QByteArray tab = getSfntTable(MAKE_TAG('k', 'e', 'r', 'n'));
807  if (tab.isEmpty())
808  return;
809 
810  const uchar *table = reinterpret_cast<const uchar *>(tab.constData());
811 
812  unsigned short version = qFromBigEndian<quint16>(table);
813  if (version != 0) {
814 // qDebug("wrong version");
815  return;
816  }
817 
818  unsigned short numTables = qFromBigEndian<quint16>(table + 2);
819  {
820  int offset = 4;
821  for(int i = 0; i < numTables; ++i) {
822  if (offset + 6 > tab.size()) {
823 // qDebug("offset out of bounds");
824  goto end;
825  }
826  const uchar *header = table + offset;
827 
828  ushort version = qFromBigEndian<quint16>(header);
829  ushort length = qFromBigEndian<quint16>(header+2);
830  ushort coverage = qFromBigEndian<quint16>(header+4);
831 // qDebug("subtable: version=%d, coverage=%x",version, coverage);
832  if(version == 0 && coverage == 0x0001) {
833  if (offset + length > tab.size()) {
834 // qDebug("length ouf ot bounds");
835  goto end;
836  }
837  const uchar *data = table + offset + 6;
838 
840  if(nPairs * 6 + 8 > length - 6) {
841 // qDebug("corrupt table!");
842  // corrupt table
843  goto end;
844  }
845 
846  int off = 8;
847  for(int i = 0; i < nPairs; ++i) {
849  p.left_right = (((uint)qFromBigEndian<quint16>(data+off)) << 16) + qFromBigEndian<quint16>(data+off+2);
850  p.adjust = QFixed(((int)(short)qFromBigEndian<quint16>(data+off+4))) / scalingFactor;
851  kerning_pairs.append(p);
852  off += 6;
853  }
854  }
855  offset += length;
856  }
857  }
858 end:
860 // for (int i = 0; i < kerning_pairs.count(); ++i)
861 // qDebug() << 'i' << i << "left_right" << hex << kerning_pairs.at(i).left_right;
862 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
#define MAKE_TAG(ch1, ch2, ch3, ch4)
unsigned char uchar
Definition: qglobal.h:994
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
void qSort(RandomAccessIterator start, RandomAccessIterator end)
Definition: qalgorithms.h:177
quint16 qFromBigEndian< quint16 >(const uchar *src)
Definition: qendian.h:249
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
unsigned short ushort
Definition: qglobal.h:995
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
QVector< KernPair > kerning_pairs
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
Definition: qbytearray.h:421
static const KeyPair *const end
QByteArray getSfntTable(uint) const

◆ maxCharWidth()

virtual qreal QFontEngine::maxCharWidth ( ) const
pure virtual

◆ minLeftBearing()

virtual qreal QFontEngine::minLeftBearing ( ) const
inlinevirtual

◆ minRightBearing()

virtual qreal QFontEngine::minRightBearing ( ) const
inlinevirtual

◆ name()

virtual const char* QFontEngine::name ( ) const
pure virtual

◆ properties()

QFontEngine::Properties QFontEngine::properties ( ) const
virtual

Reimplemented in QFontEngineFT, QFontEngineXLFD, QFontEngineMac, and QFontEngineWin.

Definition at line 689 of file qfontengine.cpp.

Referenced by QPdfEnginePrivate::embedFont(), QFontEngineXLFD::faceId(), QVGFontEngineCleaner::fontEngineDestroyed(), QFontSubset::toTruetype(), QFontSubset::toType1(), QFontSubset::type1AddedGlyphs(), and QFontSubset::widthArray().

690 {
691  Properties p;
693  psname += '-';
694  psname += QByteArray::number(fontDef.style);
695  psname += '-';
696  psname += QByteArray::number(fontDef.weight);
697 
698  p.postscriptName = psname;
699  p.ascent = ascent();
700  p.descent = descent();
701  p.leading = leading();
702  p.emSquare = p.ascent;
703  p.boundingBox = QRectF(0, -p.ascent.toReal(), maxCharWidth(), (p.ascent + p.descent).toReal());
704  p.italicAngle = 0;
705  p.capHeight = p.ascent;
706  p.lineWidth = lineThickness();
707  return p;
708 }
virtual QFixed lineThickness() const
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
virtual qreal maxCharWidth() const =0
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
virtual QFixed ascent() const =0
virtual QFixed descent() const =0
uint weight
Definition: qfont_p.h:95
uint style
Definition: qfont_p.h:97
static QByteArray convertToPostscriptFontFamilyName(const QByteArray &fontFamily)
QFontDef fontDef
QString family
Definition: qfont_p.h:82
static QByteArray number(int, int base=10)
Returns a byte array containing the string equivalent of the number n to base base (10 by default)...
virtual QFixed leading() const =0
static qreal toReal(Register *reg, int type, bool *ok=0)

◆ recalcAdvances()

virtual void QFontEngine::recalcAdvances ( QGlyphLayout ,
QTextEngine::ShaperFlags   
) const
inlinevirtual

This is a callback from harfbuzz. The font engine uses the font-system in use to find out the advances of each glyph and set it on the layout.

Reimplemented in QFontEngineMulti, QFontEngineBox, QFontEngineQPF1, QFontEngineFT, QFontEngineQPF, QFontEngineQPA, QFontEngineMacMulti, QFontEngineXLFD, QFontEngineDirectWrite, QFontEngineWin, QProxyFontEngine, QCoreTextFontEngine, and QFontEngineMac.

Definition at line 180 of file qfontengine_p.h.

Referenced by QRawFont::advancesForGlyphIndexes(), and hb_getAdvances().

180 {}

◆ removeGlyphFromCache()

void QFontEngine::removeGlyphFromCache ( glyph_t  )
virtual

Reimplemented in QFontEngineFT.

Definition at line 685 of file qfontengine.cpp.

Referenced by QFontEngineQPF::loadGlyph().

686 {
687 }

◆ setGlyphCache()

void QFontEngine::setGlyphCache ( void *  key,
QFontEngineGlyphCache data 
)

Definition at line 733 of file qfontengine.cpp.

Referenced by QGL2PaintEngineExPrivate::drawCachedGlyphs(), and QRasterPaintEngine::drawCachedGlyphs().

734 {
735  Q_ASSERT(data);
736 
737  GlyphCacheEntry entry;
738  entry.context = key;
739  entry.cache = data;
740  if (m_glyphCaches.contains(entry))
741  return;
742 
743  // Limit the glyph caches to 4. This covers all 90 degree rotations and limits
744  // memory use when there is continuous or random rotation
745  if (m_glyphCaches.size() == 4)
746  m_glyphCaches.removeLast();
747 
748  m_glyphCaches.push_front(entry);
749 
750 }
QLinkedList< GlyphCacheEntry > m_glyphCaches
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
static const char * data(const QByteArray &arr)
int key

◆ stringToCMap()

virtual bool QFontEngine::stringToCMap ( const QChar str,
int  len,
QGlyphLayout glyphs,
int *  nglyphs,
QTextEngine::ShaperFlags  flags 
) const
pure virtual

◆ supportsSubPixelPositions()

virtual bool QFontEngine::supportsSubPixelPositions ( ) const
inlinevirtual

◆ synthesized()

virtual int QFontEngine::synthesized ( ) const
inlinevirtual

◆ tightBoundingBox()

glyph_metrics_t QFontEngine::tightBoundingBox ( const QGlyphLayout glyphs)

Definition at line 395 of file qfontengine.cpp.

Referenced by QTextEngine::tightBoundingBox().

396 {
397  glyph_metrics_t overall;
398 
399  QFixed ymax = 0;
400  QFixed xmax = 0;
401  for (int i = 0; i < glyphs.numGlyphs; i++) {
402  glyph_metrics_t bb = boundingBox(glyphs.glyphs[i]);
403  QFixed x = overall.xoff + glyphs.offsets[i].x + bb.x;
404  QFixed y = overall.yoff + glyphs.offsets[i].y + bb.y;
405  overall.x = qMin(overall.x, x);
406  overall.y = qMin(overall.y, y);
407  xmax = qMax(xmax, x + bb.width);
408  ymax = qMax(ymax, y + bb.height);
409  overall.xoff += bb.xoff;
410  overall.yoff += bb.yoff;
411  }
412  overall.height = qMax(overall.height, ymax - overall.y);
413  overall.width = xmax - overall.x;
414 
415  return overall;
416 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
HB_Glyph * glyphs
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QFixed y
Definition: qfixed_p.h:191
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
QFixed x
Definition: qfixed_p.h:190
QFixedPoint * offsets

◆ type()

virtual Type QFontEngine::type ( ) const
pure virtual

◆ underlinePosition()

QFixed QFontEngine::underlinePosition ( ) const
virtual

◆ xHeight()

QFixed QFontEngine::xHeight ( ) const
virtual

Reimplemented in QFontEngineMulti, QFontEngineFT, QFontEngineDirectWrite, QFontEngineWin, QProxyFontEngine, QCoreTextFontEngine, and QFontEngineMac.

Definition at line 246 of file qfontengine.cpp.

Referenced by QFontMetrics::xHeight(), QFontEngineWin::xHeight(), QRawFont::xHeight(), QFontMetricsF::xHeight(), and QFontEngineFT::xHeight().

247 {
248  QGlyphLayoutArray<8> glyphs;
249  int nglyphs = 7;
250  QChar x((ushort)'x');
251  stringToCMap(&x, 1, &glyphs, &nglyphs, QTextEngine::GlyphIndicesOnly);
252 
253  glyph_metrics_t bb = const_cast<QFontEngine *>(this)->boundingBox(glyphs.glyphs[0]);
254  return bb.height;
255 }
HB_Glyph * glyphs
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const =0
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
unsigned short ushort
Definition: qglobal.h:995

Properties

◆ cache_cost

uint QFontEngine::cache_cost

◆ cache_count

int QFontEngine::cache_count

◆ fontDef

QFontDef QFontEngine::fontDef

Definition at line 255 of file qfontengine_p.h.

Referenced by QFontEngineDirectWrite::addGlyphsToPath(), QFontEngineDirectWrite::alphaMapBoundingBox(), QFontEngineMac::ascent(), QFontEngineDirectWrite::ascent(), QFontEngineMac::averageCharWidth(), QFontEngineMac::boundingBox(), QFontEngineDirectWrite::boundingBox(), QFontEngineDirectWrite::cloneWithSize(), QFontEngineWin::cloneWithSize(), QFontEngineX11FT::cloneWithSize(), QFontEngineFT::cloneWithSize(), QFontEngineMac::descent(), QFontEngineDirectWrite::descent(), QFontEngineMac::draw(), QPainter::drawGlyphRun(), QOpenGLPaintEngine::drawStaticTextItem(), QGL2PaintEngineEx::drawStaticTextItem(), QPaintEngineEx::drawStaticTextItem(), QCoreGraphicsPaintEngine::drawTextItem(), QGL2PaintEngineEx::drawTextItem(), QPdfEnginePrivate::drawTextItem(), QPdfBaseEnginePrivate::drawTextItem(), engineForPattern(), QFontInfo::exactMatch(), QFont::exactMatch(), QFontInfo::family(), QRawFont::familyName(), QFontDatabase::findFont(), QFontInfo::fixedPitch(), QFontEngineMacMulti::fontIndexForFontID(), harfbuzzFont(), QFontEngineMac::imageForGlyph(), QFontEngineDirectWrite::imageForGlyph(), initFontInfo(), QFontInfo::italic(), QFontEngineMac::leading(), QFontEngineDirectWrite::leading(), lineThickness(), QFontDatabase::load(), QFontEngineMultiFT::loadEngine(), QFontEngineMultiWin::loadEngine(), QFontEngineMultiQPA::loadEngine(), QFontEngineMultiQWS::loadEngine(), loadEngine(), loadFc(), loadWin(), QFontDatabase::loadXlfd(), QFontEngineQPF::lockFace(), QFontEngineMac::maxCharWidth(), QFontInfo::pixelSize(), QRawFont::pixelSize(), QRawFontPrivate::platformLoadFromData(), QFontInfo::pointSize(), QFontInfo::pointSizeF(), properties(), QFontEngineDirectWrite::QFontEngineDirectWrite(), QFontEngineMac::QFontEngineMac(), QFontEngineMacMulti::QFontEngineMacMulti(), QFontEngineMultiFT::QFontEngineMultiFT(), QFontEngineMultiQPA::QFontEngineMultiQPA(), QFontEngineMultiQWS::QFontEngineMultiQWS(), QFontEngineMultiWin::QFontEngineMultiWin(), QFontEngineMultiXLFD::QFontEngineMultiXLFD(), QFontEngineQPA::QFontEngineQPA(), QFontEngineQPF::QFontEngineQPF(), QProxyFontEngine::QProxyFontEngine(), QFontEngineMac::recalcAdvances(), QFontEngineDirectWrite::recalcAdvances(), registerFont(), QFontEngineMacMulti::stringToCMapInternal(), QFontInfo::style(), QRawFont::style(), QFontInfo::styleHint(), QFontInfo::styleName(), QRawFont::styleName(), QRasterPaintEngine::supportsTransformations(), QFontSubset::toTruetype(), QFontSubset::toType1(), QFontInfo::weight(), QRawFont::weight(), QFontEngineMac::xHeight(), and QFontEngineDirectWrite::xHeight().

◆ fsType

uint QFontEngine::fsType

◆ glyphFormat

int QFontEngine::glyphFormat

◆ hbFace

HB_Face QFontEngine::hbFace
mutable

Definition at line 261 of file qfontengine_p.h.

Referenced by harfbuzzFace(), QFontEngine(), and ~QFontEngine().

◆ hbFont

HB_FontRec QFontEngine::hbFont
mutable

Definition at line 260 of file qfontengine_p.h.

Referenced by harfbuzzFont(), and QFontEngine().

◆ kerning_pairs

QVector<KernPair> QFontEngine::kerning_pairs

Definition at line 272 of file qfontengine_p.h.

Referenced by doKerning(), and loadKerningPairs().

◆ m_glyphCaches

QLinkedList<GlyphCacheEntry> QFontEngine::m_glyphCaches
mutableprivate

Definition at line 289 of file qfontengine_p.h.

Referenced by glyphCache(), setGlyphCache(), and ~QFontEngine().

◆ ref

QAtomicInt QFontEngine::ref

◆ symbol

bool QFontEngine::symbol

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