Qt 4.8
Public Functions | Protected Functions | Protected Variables | Friends | List of all members
QFontEngineMulti Class Referenceabstract

#include <qfontengine_p.h>

Inheritance diagram for QFontEngineMulti:
QFontEngine QObject QCoreTextFontEngineMulti QFontEngineMacMulti QFontEngineMultiFT QFontEngineMultiQPA QFontEngineMultiQWS QFontEngineMultiWin QFontEngineMultiXLFD

Public Functions

virtual void addOutlineToPath (qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags)
 
virtual QImage alphaMapForGlyph (glyph_t)
 
virtual QFixed ascent () const
 
virtual QFixed averageCharWidth () const
 
virtual glyph_metrics_t boundingBox (const QGlyphLayout &glyphs)
 
virtual glyph_metrics_t boundingBox (glyph_t glyph)
 
virtual bool canRender (const QChar *string, int len)
 
virtual QFixed descent () const
 
virtual void doKerning (QGlyphLayout *, QTextEngine::ShaperFlags) const
 
QFontEngineengine (int at) const
 
virtual void getGlyphBearings (glyph_t glyph, qreal *leftBearing=0, qreal *rightBearing=0)
 
virtual QFixed leading () const
 
virtual QFixed lineThickness () const
 
virtual qreal maxCharWidth () const
 
virtual qreal minLeftBearing () const
 
virtual qreal minRightBearing () const
 
virtual const char * name () const
 
 QFontEngineMulti (int engineCount)
 
virtual void recalcAdvances (QGlyphLayout *, QTextEngine::ShaperFlags) const
 
virtual bool stringToCMap (const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
 
virtual Type type () const
 
virtual QFixed underlinePosition () const
 
virtual QFixed xHeight () const
 
 ~QFontEngineMulti ()
 
- Public Functions inherited from QFontEngine
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 glyph_metrics_t alphaMapBoundingBox (glyph_t glyph, QFixed, const QTransform &matrix, GlyphFormat)
 
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 glyph_metrics_t boundingBox (glyph_t glyph, const QTransform &matrix)
 
virtual QFontEnginecloneWithSize (qreal) const
 
virtual QFixed emSquareSize () const
 
virtual FaceId faceId () const
 
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
 
void loadKerningPairs (QFixed scalingFactor)
 
virtual Properties properties () const
 
 QFontEngine ()
 
virtual void removeGlyphFromCache (glyph_t)
 
void setGlyphCache (void *key, QFontEngineGlyphCache *data)
 
virtual bool supportsSubPixelPositions () const
 
virtual int synthesized () const
 
glyph_metrics_t tightBoundingBox (const QGlyphLayout &glyphs)
 
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...
 

Protected Functions

virtual void loadEngine (int at)=0
 
- Protected Functions inherited from QFontEngine
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...
 

Protected Variables

QVector< QFontEngine * > engines
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Friends

class QPSPrintEngineFontMulti
 
class QPSPrintEnginePrivate
 
class QRawFont
 

Additional Inherited Members

- Public Types inherited from QFontEngine
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 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 Functions inherited from QFontEngine
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 inherited from QFontEngine
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
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Static Protected Functions inherited from QFontEngine
static const QVector< QRgb > & grayPalette ()
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 389 of file qfontengine_p.h.

Constructors and Destructors

◆ QFontEngineMulti()

QFontEngineMulti::QFontEngineMulti ( int  engineCount)
explicit

Definition at line 1318 of file qfontengine.cpp.

1319 {
1320  engines.fill(0, engineCount);
1321  cache_cost = 0;
1322 }
QVector< T > & fill(const T &t, int size=-1)
Assigns value to all items in the vector.
Definition: qvector.h:665
QVector< QFontEngine * > engines

◆ ~QFontEngineMulti()

QFontEngineMulti::~QFontEngineMulti ( )

Definition at line 1324 of file qfontengine.cpp.

1325 {
1326  for (int i = 0; i < engines.size(); ++i) {
1327  QFontEngine *fontEngine = engines.at(i);
1328  if (fontEngine) {
1329  fontEngine->ref.deref();
1330  if (fontEngine->cache_count == 0 && fontEngine->ref == 0)
1331  delete fontEngine;
1332  }
1333  }
1334 }
QAtomicInt ref
bool deref()
Atomically decrements the value of this QAtomicInt.
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QFontEngine * > engines
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

Functions

◆ addOutlineToPath()

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

Reimplemented from QFontEngine.

Definition at line 1455 of file qfontengine.cpp.

1457 {
1458  if (glyphs.numGlyphs <= 0)
1459  return;
1460 
1461  int which = highByte(glyphs.glyphs[0]);
1462  int start = 0;
1463  int end, i;
1464  if (flags & QTextItem::RightToLeft) {
1465  for (int gl = 0; gl < glyphs.numGlyphs; gl++) {
1466  x += glyphs.advances_x[gl].toReal();
1467  y += glyphs.advances_y[gl].toReal();
1468  }
1469  }
1470  for (end = 0; end < glyphs.numGlyphs; ++end) {
1471  const int e = highByte(glyphs.glyphs[end]);
1472  if (e == which)
1473  continue;
1474 
1475  if (flags & QTextItem::RightToLeft) {
1476  for (i = start; i < end; ++i) {
1477  x -= glyphs.advances_x[i].toReal();
1478  y -= glyphs.advances_y[i].toReal();
1479  }
1480  }
1481 
1482  // set the high byte to zero
1483  for (i = start; i < end; ++i)
1484  glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
1485  engine(which)->addOutlineToPath(x, y, glyphs.mid(start, end - start), path, flags);
1486  // reset the high byte for all glyphs and update x and y
1487  const int hi = which << 24;
1488  for (i = start; i < end; ++i)
1489  glyphs.glyphs[i] = hi | glyphs.glyphs[i];
1490 
1491  if (!(flags & QTextItem::RightToLeft)) {
1492  for (i = start; i < end; ++i) {
1493  x += glyphs.advances_x[i].toReal();
1494  y += glyphs.advances_y[i].toReal();
1495  }
1496  }
1497 
1498  // change engine
1499  start = end;
1500  which = e;
1501  }
1502 
1503  if (flags & QTextItem::RightToLeft) {
1504  for (i = start; i < end; ++i) {
1505  x -= glyphs.advances_x[i].toReal();
1506  y -= glyphs.advances_y[i].toReal();
1507  }
1508  }
1509 
1510  // set the high byte to zero
1511  for (i = start; i < end; ++i)
1512  glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
1513 
1514  engine(which)->addOutlineToPath(x, y, glyphs.mid(start, end - start), path, flags);
1515 
1516  // reset the high byte for all glyphs
1517  const int hi = which << 24;
1518  for (i = start; i < end; ++i)
1519  glyphs.glyphs[i] = hi | glyphs.glyphs[i];
1520 }
QFixed * advances_y
QFixed * advances_x
HB_Glyph * glyphs
static glyph_t stripped(glyph_t glyph)
virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags)
QGlyphLayout mid(int position, int n=-1) const
if(void) toggleToolbarShown
qreal toReal() const
Definition: qfixed_p.h:77
static uchar highByte(glyph_t glyph)
static const KeyPair *const end
QFontEngine * engine(int at) const

◆ alphaMapForGlyph()

QImage QFontEngineMulti::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 from QFontEngine.

Definition at line 1684 of file qfontengine.cpp.

1685 {
1686  Q_ASSERT(false);
1687  return QImage();
1688 }
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QImage class provides a hardware-independent image representation that allows direct access to th...
Definition: qimage.h:87

◆ ascent()

QFixed QFontEngineMulti::ascent ( ) const
virtual

Implements QFontEngine.

Definition at line 1615 of file qfontengine.cpp.

1616 { return engine(0)->ascent(); }
virtual QFixed ascent() const =0
QFontEngine * engine(int at) const

◆ averageCharWidth()

QFixed QFontEngineMulti::averageCharWidth ( ) const
virtual

Reimplemented from QFontEngine.

Definition at line 1631 of file qfontengine.cpp.

1632 {
1633  return engine(0)->averageCharWidth();
1634 }
virtual QFixed averageCharWidth() const
QFontEngine * engine(int at) const

◆ boundingBox() [1/2]

glyph_metrics_t QFontEngineMulti::boundingBox ( const QGlyphLayout glyphs)
virtual

Implements QFontEngine.

Definition at line 1386 of file qfontengine.cpp.

1387 {
1388  if (glyphs.numGlyphs <= 0)
1389  return glyph_metrics_t();
1390 
1391  glyph_metrics_t overall;
1392 
1393  int which = highByte(glyphs.glyphs[0]);
1394  int start = 0;
1395  int end, i;
1396  for (end = 0; end < glyphs.numGlyphs; ++end) {
1397  const int e = highByte(glyphs.glyphs[end]);
1398  if (e == which)
1399  continue;
1400 
1401  // set the high byte to zero
1402  for (i = start; i < end; ++i)
1403  glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
1404 
1405  // merge the bounding box for this run
1406  const glyph_metrics_t gm = engine(which)->boundingBox(glyphs.mid(start, end - start));
1407 
1408  overall.x = qMin(overall.x, gm.x);
1409  overall.y = qMin(overall.y, gm.y);
1410  overall.width = overall.xoff + gm.width;
1411  overall.height = qMax(overall.height + overall.y, gm.height + gm.y) -
1412  qMin(overall.y, gm.y);
1413  overall.xoff += gm.xoff;
1414  overall.yoff += gm.yoff;
1415 
1416  // reset the high byte for all glyphs
1417  const int hi = which << 24;
1418  for (i = start; i < end; ++i)
1419  glyphs.glyphs[i] = hi | glyphs.glyphs[i];
1420 
1421  // change engine
1422  start = end;
1423  which = e;
1424  }
1425 
1426  // set the high byte to zero
1427  for (i = start; i < end; ++i)
1428  glyphs.glyphs[i] = stripped(glyphs.glyphs[i]);
1429 
1430  // merge the bounding box for this run
1431  const glyph_metrics_t gm = engine(which)->boundingBox(glyphs.mid(start, end - start));
1432 
1433  overall.x = qMin(overall.x, gm.x);
1434  overall.y = qMin(overall.y, gm.y);
1435  overall.width = overall.xoff + gm.width;
1436  overall.height = qMax(overall.height + overall.y, gm.height + gm.y) -
1437  qMin(overall.y, gm.y);
1438  overall.xoff += gm.xoff;
1439  overall.yoff += gm.yoff;
1440 
1441  // reset the high byte for all glyphs
1442  const int hi = which << 24;
1443  for (i = start; i < end; ++i)
1444  glyphs.glyphs[i] = hi | glyphs.glyphs[i];
1445 
1446  return overall;
1447 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
HB_Glyph * glyphs
static glyph_t stripped(glyph_t glyph)
QGlyphLayout mid(int position, int n=-1) const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
static uchar highByte(glyph_t glyph)
static const KeyPair *const end
QFontEngine * engine(int at) const

◆ boundingBox() [2/2]

glyph_metrics_t QFontEngineMulti::boundingBox ( glyph_t  glyph)
virtual

Implements QFontEngine.

Definition at line 1608 of file qfontengine.cpp.

1609 {
1610  const int which = highByte(glyph);
1611  Q_ASSERT(which < engines.size());
1612  return engine(which)->boundingBox(stripped(glyph));
1613 }
static glyph_t stripped(glyph_t glyph)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)=0
QVector< QFontEngine * > engines
static uchar highByte(glyph_t glyph)
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QFontEngine * engine(int at) const

◆ canRender()

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

Implements QFontEngine.

Reimplemented in QFontEngineMacMulti.

Definition at line 1661 of file qfontengine.cpp.

Referenced by QFontEngineXLFD::type().

1662 {
1663  if (engine(0)->canRender(string, len))
1664  return true;
1665 
1666  QVarLengthGlyphLayoutArray glyphs(len);
1667  int nglyphs = len;
1668  if (stringToCMap(string, len, &glyphs, &nglyphs, QTextEngine::GlyphIndicesOnly) == false) {
1669  glyphs.resize(nglyphs);
1670  stringToCMap(string, len, &glyphs, &nglyphs, QTextEngine::GlyphIndicesOnly);
1671  }
1672 
1673  bool allExist = true;
1674  for (int i = 0; i < nglyphs; i++) {
1675  if (!glyphs.glyphs[i]) {
1676  allExist = false;
1677  break;
1678  }
1679  }
1680 
1681  return allExist;
1682 }
virtual bool canRender(const QChar *string, int len)
QFontEngine * engine(int at) const
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const

◆ descent()

QFixed QFontEngineMulti::descent ( ) const
virtual

Implements QFontEngine.

Definition at line 1618 of file qfontengine.cpp.

1619 { return engine(0)->descent(); }
virtual QFixed descent() const =0
QFontEngine * engine(int at) const

◆ doKerning()

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

Reimplemented from QFontEngine.

Reimplemented in QFontEngineMacMulti.

Definition at line 1565 of file qfontengine.cpp.

1566 {
1567  if (glyphs->numGlyphs <= 0)
1568  return;
1569 
1570  int which = highByte(glyphs->glyphs[0]);
1571  int start = 0;
1572  int end, i;
1573  for (end = 0; end < glyphs->numGlyphs; ++end) {
1574  const int e = highByte(glyphs->glyphs[end]);
1575  if (e == which)
1576  continue;
1577 
1578  // set the high byte to zero
1579  for (i = start; i < end; ++i)
1580  glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
1581 
1582  QGlyphLayout offs = glyphs->mid(start, end - start);
1583  engine(which)->doKerning(&offs, flags);
1584 
1585  // reset the high byte for all glyphs and update x and y
1586  const int hi = which << 24;
1587  for (i = start; i < end; ++i)
1588  glyphs->glyphs[i] = hi | glyphs->glyphs[i];
1589 
1590  // change engine
1591  start = end;
1592  which = e;
1593  }
1594 
1595  // set the high byte to zero
1596  for (i = start; i < end; ++i)
1597  glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
1598 
1599  QGlyphLayout offs = glyphs->mid(start, end - start);
1600  engine(which)->doKerning(&offs, flags);
1601 
1602  // reset the high byte for all glyphs
1603  const int hi = which << 24;
1604  for (i = start; i < end; ++i)
1605  glyphs->glyphs[i] = hi | glyphs->glyphs[i];
1606 }
HB_Glyph * glyphs
virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const
static glyph_t stripped(glyph_t glyph)
QGlyphLayout mid(int position, int n=-1) const
static uchar highByte(glyph_t glyph)
static const KeyPair *const end
QFontEngine * engine(int at) const

◆ engine()

QFontEngine* QFontEngineMulti::engine ( int  at) const
inline

Definition at line 426 of file qfontengine_p.h.

Referenced by QPainter::drawTextItem(), QFontDatabase::findFont(), QRawFont::fromFont(), QTextLine::glyphs(), QFontDatabase::load(), loadEngine(), and loadSingleEngine().

427  {Q_ASSERT(at < engines.size()); return engines.at(at); }
#define at(className, varName)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QFontEngine * > engines
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ getGlyphBearings()

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

Reimplemented from QFontEngine.

Definition at line 1449 of file qfontengine.cpp.

1450 {
1451  int which = highByte(glyph);
1452  engine(which)->getGlyphBearings(stripped(glyph), leftBearing, rightBearing);
1453 }
static glyph_t stripped(glyph_t glyph)
virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing=0, qreal *rightBearing=0)
static uchar highByte(glyph_t glyph)
QFontEngine * engine(int at) const

◆ leading()

QFixed QFontEngineMulti::leading ( ) const
virtual

Implements QFontEngine.

Definition at line 1621 of file qfontengine.cpp.

1622 {
1623  return engine(0)->leading();
1624 }
QFontEngine * engine(int at) const
virtual QFixed leading() const =0

◆ lineThickness()

QFixed QFontEngineMulti::lineThickness ( ) const
virtual

Reimplemented from QFontEngine.

Definition at line 1636 of file qfontengine.cpp.

1637 {
1638  return engine(0)->lineThickness();
1639 }
virtual QFixed lineThickness() const
QFontEngine * engine(int at) const

◆ loadEngine()

virtual void QFontEngineMulti::loadEngine ( int  at)
protectedpure virtual

◆ maxCharWidth()

qreal QFontEngineMulti::maxCharWidth ( ) const
virtual

Implements QFontEngine.

Definition at line 1646 of file qfontengine.cpp.

Referenced by QFontEngineMacMulti::stringToCMap().

1647 {
1648  return engine(0)->maxCharWidth();
1649 }
virtual qreal maxCharWidth() const =0
QFontEngine * engine(int at) const

◆ minLeftBearing()

qreal QFontEngineMulti::minLeftBearing ( ) const
virtual

Reimplemented from QFontEngine.

Definition at line 1651 of file qfontengine.cpp.

1652 {
1653  return engine(0)->minLeftBearing();
1654 }
virtual qreal minLeftBearing() const
QFontEngine * engine(int at) const

◆ minRightBearing()

qreal QFontEngineMulti::minRightBearing ( ) const
virtual

Reimplemented from QFontEngine.

Definition at line 1656 of file qfontengine.cpp.

1657 {
1658  return engine(0)->minRightBearing();
1659 }
virtual qreal minRightBearing() const
QFontEngine * engine(int at) const

◆ name()

virtual const char* QFontEngineMulti::name ( ) const
inlinevirtual

Implements QFontEngine.

Reimplemented in QFontEngineMacMulti, and QCoreTextFontEngineMulti.

Definition at line 423 of file qfontengine_p.h.

Referenced by QFontEngineXLFD::type().

424  { return "Multi"; }

◆ recalcAdvances()

void QFontEngineMulti::recalcAdvances ( QGlyphLayout ,
QTextEngine::ShaperFlags   
) const
virtual

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 from QFontEngine.

Reimplemented in QFontEngineMacMulti.

Definition at line 1522 of file qfontengine.cpp.

1523 {
1524  if (glyphs->numGlyphs <= 0)
1525  return;
1526 
1527  int which = highByte(glyphs->glyphs[0]);
1528  int start = 0;
1529  int end, i;
1530  for (end = 0; end < glyphs->numGlyphs; ++end) {
1531  const int e = highByte(glyphs->glyphs[end]);
1532  if (e == which)
1533  continue;
1534 
1535  // set the high byte to zero
1536  for (i = start; i < end; ++i)
1537  glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
1538 
1539  QGlyphLayout offs = glyphs->mid(start, end - start);
1540  engine(which)->recalcAdvances(&offs, flags);
1541 
1542  // reset the high byte for all glyphs and update x and y
1543  const int hi = which << 24;
1544  for (i = start; i < end; ++i)
1545  glyphs->glyphs[i] = hi | glyphs->glyphs[i];
1546 
1547  // change engine
1548  start = end;
1549  which = e;
1550  }
1551 
1552  // set the high byte to zero
1553  for (i = start; i < end; ++i)
1554  glyphs->glyphs[i] = stripped(glyphs->glyphs[i]);
1555 
1556  QGlyphLayout offs = glyphs->mid(start, end - start);
1557  engine(which)->recalcAdvances(&offs, flags);
1558 
1559  // reset the high byte for all glyphs
1560  const int hi = which << 24;
1561  for (i = start; i < end; ++i)
1562  glyphs->glyphs[i] = hi | glyphs->glyphs[i];
1563 }
static glyph_t stripped(glyph_t glyph)
QGlyphLayout mid(int position, int n=-1) const
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const
static uchar highByte(glyph_t glyph)
static const KeyPair *const end
QFontEngine * engine(int at) const

◆ stringToCMap()

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

Implements QFontEngine.

Reimplemented in QFontEngineMacMulti, and QCoreTextFontEngineMulti.

Definition at line 1336 of file qfontengine.cpp.

1339 {
1340  int ng = *nglyphs;
1341  if (!engine(0)->stringToCMap(str, len, glyphs, &ng, flags))
1342  return false;
1343 
1344  int glyph_pos = 0;
1345  for (int i = 0; i < len; ++i) {
1346  bool surrogate = (str[i].isHighSurrogate() && i < len-1 && str[i+1].isLowSurrogate());
1347 
1348  if (glyphs->glyphs[glyph_pos] == 0 && str[i].category() != QChar::Separator_Line) {
1349  QGlyphLayoutInstance tmp = glyphs->instance(glyph_pos);
1350  for (int x = 1; x < engines.size(); ++x) {
1351  QFontEngine *engine = engines.at(x);
1352  if (!engine) {
1353  const_cast<QFontEngineMulti *>(this)->loadEngine(x);
1354  engine = engines.at(x);
1355  }
1356  Q_ASSERT(engine != 0);
1357  if (engine->type() == Box)
1358  continue;
1359  glyphs->advances_x[glyph_pos] = glyphs->advances_y[glyph_pos] = 0;
1360  glyphs->offsets[glyph_pos] = QFixedPoint();
1361  int num = 2;
1362  QGlyphLayout offs = glyphs->mid(glyph_pos, num);
1363  engine->stringToCMap(str + i, surrogate ? 2 : 1, &offs, &num, flags);
1364  Q_ASSERT(num == 1); // surrogates only give 1 glyph
1365  if (glyphs->glyphs[glyph_pos]) {
1366  // set the high byte to indicate which engine the glyph came from
1367  glyphs->glyphs[glyph_pos] |= (x << 24);
1368  break;
1369  }
1370  }
1371  // ensure we use metrics from the 1st font when we use the fallback image.
1372  if (!glyphs->glyphs[glyph_pos]) {
1373  glyphs->setInstance(glyph_pos, tmp);
1374  }
1375  }
1376  if (surrogate)
1377  ++i;
1378  ++glyph_pos;
1379  }
1380 
1381  *nglyphs = ng;
1382  glyphs->numGlyphs = ng;
1383  return true;
1384 }
QFixed * advances_y
QFixed * advances_x
HB_Glyph * glyphs
bool isLowSurrogate() const
Returns true if the QChar is the low part of a utf16 surrogate (ie.
Definition: qchar.h:279
QGlyphLayout mid(int position, int n=-1) const
bool isHighSurrogate() const
Returns true if the QChar is the high part of a utf16 surrogate (ie.
Definition: qchar.h:276
#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
virtual Type type() const =0
Category category() const
Returns the character&#39;s category.
Definition: qchar.cpp:853
QGlyphLayoutInstance instance(int position) const
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
QVector< QFontEngine * > engines
virtual void loadEngine(int at)=0
QFixedPoint * offsets
void setInstance(int position, const QGlyphLayoutInstance &g)
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
QFontEngine * engine(int at) const
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const

◆ type()

virtual Type QFontEngineMulti::type ( ) const
inlinevirtual

Implements QFontEngine.

Definition at line 419 of file qfontengine_p.h.

◆ underlinePosition()

QFixed QFontEngineMulti::underlinePosition ( ) const
virtual

Reimplemented from QFontEngine.

Definition at line 1641 of file qfontengine.cpp.

1642 {
1643  return engine(0)->underlinePosition();
1644 }
virtual QFixed underlinePosition() const
QFontEngine * engine(int at) const

◆ xHeight()

QFixed QFontEngineMulti::xHeight ( ) const
virtual

Reimplemented from QFontEngine.

Definition at line 1626 of file qfontengine.cpp.

1627 {
1628  return engine(0)->xHeight();
1629 }
virtual QFixed xHeight() const
QFontEngine * engine(int at) const

Friends and Related Functions

◆ QPSPrintEngineFontMulti

friend class QPSPrintEngineFontMulti
friend

Definition at line 432 of file qfontengine_p.h.

◆ QPSPrintEnginePrivate

Definition at line 431 of file qfontengine_p.h.

◆ QRawFont

friend class QRawFont
friend

Definition at line 433 of file qfontengine_p.h.

Properties

◆ engines

QVector<QFontEngine *> QFontEngineMulti::engines
protected

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