Move ShaperFlags enum from QTextEngine to QFontEngine
These flags are specific to font engine(s) and has nothing to do with the text engine or the text layout. Change-Id: I4bb793c3c634b3cf0ae0a8a8c23b946fad5874b6 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
parent
84792b5ad5
commit
1db99a6250
@ -67,8 +67,8 @@ public:
|
||||
QProxyFontEngine(QAbstractFontEngine *engine, const QFontDef &def);
|
||||
virtual ~QProxyFontEngine();
|
||||
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const;
|
||||
virtual QImage alphaMapForGlyph(glyph_t);
|
||||
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, QPainterPath *path, QTextItem::RenderFlags flags);
|
||||
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
|
||||
|
@ -742,7 +742,7 @@ bool qt_fontHasNarrowOutlines(QFontEngine *fontEngine)
|
||||
glyphs.glyphs = &glyph;
|
||||
int numGlyphs;
|
||||
QChar *chars = QString(QLatin1String("O")).data();
|
||||
fe->stringToCMap(chars, 1, &glyphs, &numGlyphs, QTextEngine::GlyphIndicesOnly);
|
||||
fe->stringToCMap(chars, 1, &glyphs, &numGlyphs, QFontEngine::GlyphIndicesOnly);
|
||||
QImage im = fe->alphaMapForGlyph(glyph, QFixed(), QTransform());
|
||||
delete fe;
|
||||
|
||||
|
@ -77,9 +77,9 @@ static HB_Bool hb_stringToGlyphs(HB_Font font, const HB_UChar16 *string, hb_uint
|
||||
|
||||
QVarLengthGlyphLayoutArray qglyphs(*numGlyphs);
|
||||
|
||||
QTextEngine::ShaperFlags shaperFlags(QTextEngine::GlyphIndicesOnly);
|
||||
QFontEngine::ShaperFlags shaperFlags(QFontEngine::GlyphIndicesOnly);
|
||||
if (rightToLeft)
|
||||
shaperFlags |= QTextEngine::RightToLeft;
|
||||
shaperFlags |= QFontEngine::RightToLeft;
|
||||
|
||||
int nGlyphs = *numGlyphs;
|
||||
bool result = fe->stringToCMap(reinterpret_cast<const QChar *>(string), length, &qglyphs, &nGlyphs, shaperFlags);
|
||||
@ -102,7 +102,7 @@ static void hb_getAdvances(HB_Font font, const HB_Glyph *glyphs, hb_uint32 numGl
|
||||
for (hb_uint32 i = 0; i < numGlyphs; ++i)
|
||||
qglyphs.glyphs[i] = glyphs[i];
|
||||
|
||||
fe->recalcAdvances(&qglyphs, flags & HB_ShaperFlag_UseDesignMetrics ? QFlags<QTextEngine::ShaperFlag>(QTextEngine::DesignMetrics) : QFlags<QTextEngine::ShaperFlag>(0));
|
||||
fe->recalcAdvances(&qglyphs, (flags & HB_ShaperFlag_UseDesignMetrics) ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0));
|
||||
|
||||
for (hb_uint32 i = 0; i < numGlyphs; ++i)
|
||||
advances[i] = qglyphs.advances_x[i].value();
|
||||
@ -251,7 +251,7 @@ QFixed QFontEngine::xHeight() const
|
||||
QGlyphLayoutArray<8> glyphs;
|
||||
int nglyphs = 7;
|
||||
QChar x((ushort)'x');
|
||||
stringToCMap(&x, 1, &glyphs, &nglyphs, QTextEngine::GlyphIndicesOnly);
|
||||
stringToCMap(&x, 1, &glyphs, &nglyphs, GlyphIndicesOnly);
|
||||
|
||||
glyph_metrics_t bb = const_cast<QFontEngine *>(this)->boundingBox(glyphs.glyphs[0]);
|
||||
return bb.height;
|
||||
@ -262,7 +262,7 @@ QFixed QFontEngine::averageCharWidth() const
|
||||
QGlyphLayoutArray<8> glyphs;
|
||||
int nglyphs = 7;
|
||||
QChar x((ushort)'x');
|
||||
stringToCMap(&x, 1, &glyphs, &nglyphs, QTextEngine::GlyphIndicesOnly);
|
||||
stringToCMap(&x, 1, &glyphs, &nglyphs, GlyphIndicesOnly);
|
||||
|
||||
glyph_metrics_t bb = const_cast<QFontEngine *>(this)->boundingBox(glyphs.glyphs[0]);
|
||||
return bb.xoff;
|
||||
@ -826,7 +826,7 @@ static inline QFixed kerning(int left, int right, const QFontEngine::KernPair *p
|
||||
return 0;
|
||||
}
|
||||
|
||||
void QFontEngine::doKerning(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
|
||||
void QFontEngine::doKerning(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
int numPairs = kerning_pairs.size();
|
||||
if(!numPairs)
|
||||
@ -834,7 +834,7 @@ void QFontEngine::doKerning(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags
|
||||
|
||||
const KernPair *pairs = kerning_pairs.constData();
|
||||
|
||||
if(flags & QTextEngine::DesignMetrics) {
|
||||
if (flags & DesignMetrics) {
|
||||
for(int i = 0; i < glyphs->numGlyphs - 1; ++i)
|
||||
glyphs->advances_x[i] += kerning(glyphs->glyphs[i], glyphs->glyphs[i+1] , pairs, numPairs);
|
||||
} else {
|
||||
@ -1183,27 +1183,26 @@ QFontEngineBox::~QFontEngineBox()
|
||||
{
|
||||
}
|
||||
|
||||
bool QFontEngineBox::stringToCMap(const QChar *, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
|
||||
bool QFontEngineBox::stringToCMap(const QChar *, int len, QGlyphLayout *glyphs, int *nglyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
if (*nglyphs < len) {
|
||||
*nglyphs = len;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (int i = 0; i < len; ++i)
|
||||
glyphs->glyphs[i] = 0;
|
||||
if (!(flags & QTextEngine::GlyphIndicesOnly)) {
|
||||
glyphs->advances_x[i] = _size;
|
||||
glyphs->advances_y[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
*nglyphs = len;
|
||||
glyphs->numGlyphs = len;
|
||||
|
||||
if (!(flags & GlyphIndicesOnly))
|
||||
recalcAdvances(glyphs, flags);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QFontEngineBox::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const
|
||||
void QFontEngineBox::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags) const
|
||||
{
|
||||
for (int i = 0; i < glyphs->numGlyphs; i++) {
|
||||
glyphs->advances_x[i] = _size;
|
||||
@ -1360,7 +1359,7 @@ QFontEngineMulti::~QFontEngineMulti()
|
||||
|
||||
bool QFontEngineMulti::stringToCMap(const QChar *str, int len,
|
||||
QGlyphLayout *glyphs, int *nglyphs,
|
||||
QTextEngine::ShaperFlags flags) const
|
||||
QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
int ng = *nglyphs;
|
||||
if (!engine(0)->stringToCMap(str, len, glyphs, &ng, flags))
|
||||
@ -1558,7 +1557,7 @@ void QFontEngineMulti::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &gl
|
||||
glyphs.glyphs[i] = hi | glyphs.glyphs[i];
|
||||
}
|
||||
|
||||
void QFontEngineMulti::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
|
||||
void QFontEngineMulti::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
if (glyphs->numGlyphs <= 0)
|
||||
return;
|
||||
@ -1601,7 +1600,7 @@ void QFontEngineMulti::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperF
|
||||
glyphs->glyphs[i] = hi | glyphs->glyphs[i];
|
||||
}
|
||||
|
||||
void QFontEngineMulti::doKerning(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
|
||||
void QFontEngineMulti::doKerning(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
if (glyphs->numGlyphs <= 0)
|
||||
return;
|
||||
@ -1704,9 +1703,9 @@ bool QFontEngineMulti::canRender(const QChar *string, int len)
|
||||
|
||||
QVarLengthGlyphLayoutArray glyphs(len);
|
||||
int nglyphs = len;
|
||||
if (stringToCMap(string, len, &glyphs, &nglyphs, QTextEngine::GlyphIndicesOnly) == false) {
|
||||
if (!stringToCMap(string, len, &glyphs, &nglyphs, GlyphIndicesOnly)) {
|
||||
glyphs.resize(nglyphs);
|
||||
stringToCMap(string, len, &glyphs, &nglyphs, QTextEngine::GlyphIndicesOnly);
|
||||
stringToCMap(string, len, &glyphs, &nglyphs, GlyphIndicesOnly);
|
||||
}
|
||||
|
||||
bool allExist = true;
|
||||
|
@ -789,7 +789,7 @@ int QFontEngineFT::loadFlags(QGlyphSet *set, GlyphFormat format, int flags,
|
||||
if (set && set->outline_drawing)
|
||||
load_flags = FT_LOAD_NO_BITMAP;
|
||||
|
||||
if (default_hint_style == HintNone || (flags & HB_ShaperFlag_UseDesignMetrics) || (set && set->outline_drawing))
|
||||
if (default_hint_style == HintNone || (flags & DesignMetrics) || (set && set->outline_drawing))
|
||||
load_flags |= FT_LOAD_NO_HINTING;
|
||||
else
|
||||
load_flags |= load_target;
|
||||
@ -1249,7 +1249,7 @@ qreal QFontEngineFT::minRightBearing() const
|
||||
const QChar *ch = (const QChar *)(const void*)char_table;
|
||||
QGlyphLayoutArray<char_table_entries> glyphs;
|
||||
int ng = char_table_entries;
|
||||
stringToCMap(ch, char_table_entries, &glyphs, &ng, QTextEngine::GlyphIndicesOnly);
|
||||
stringToCMap(ch, char_table_entries, &glyphs, &ng, GlyphIndicesOnly);
|
||||
while (--ng) {
|
||||
if (glyphs.glyphs[ng]) {
|
||||
glyph_metrics_t gi = const_cast<QFontEngineFT *>(this)->boundingBox(glyphs.glyphs[ng]);
|
||||
@ -1271,7 +1271,7 @@ QFixed QFontEngineFT::underlinePosition() const
|
||||
return underline_position;
|
||||
}
|
||||
|
||||
void QFontEngineFT::doKerning(QGlyphLayout *g, QTextEngine::ShaperFlags flags) const
|
||||
void QFontEngineFT::doKerning(QGlyphLayout *g, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
if (!kerning_pairs_loaded) {
|
||||
kerning_pairs_loaded = true;
|
||||
@ -1467,14 +1467,14 @@ void QFontEngineFT::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int
|
||||
}
|
||||
|
||||
bool QFontEngineFT::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
|
||||
QTextEngine::ShaperFlags flags) const
|
||||
QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
if (*nglyphs < len) {
|
||||
*nglyphs = len;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool mirrored = flags & QTextEngine::RightToLeft;
|
||||
bool mirrored = flags & QFontEngine::RightToLeft;
|
||||
int glyph_pos = 0;
|
||||
if (freetype->symbol_map) {
|
||||
FT_Face face = freetype->face;
|
||||
@ -1533,20 +1533,18 @@ bool QFontEngineFT::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs
|
||||
*nglyphs = glyph_pos;
|
||||
glyphs->numGlyphs = glyph_pos;
|
||||
|
||||
if (flags & QTextEngine::GlyphIndicesOnly)
|
||||
return true;
|
||||
|
||||
if (!(flags & GlyphIndicesOnly))
|
||||
recalcAdvances(glyphs, flags);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
|
||||
void QFontEngineFT::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
FT_Face face = 0;
|
||||
bool design = (default_hint_style == HintNone ||
|
||||
default_hint_style == HintLight ||
|
||||
(flags & HB_ShaperFlag_UseDesignMetrics)) && FT_IS_SCALABLE(freetype->face);
|
||||
(flags & DesignMetrics)) && FT_IS_SCALABLE(freetype->face);
|
||||
for (int i = 0; i < glyphs->numGlyphs; i++) {
|
||||
Glyph *g = cacheEnabled ? defaultGlyphSet.getGlyph(glyphs->glyphs[i]) : 0;
|
||||
// Since we are passing Format_None to loadGlyph, use same default format logic as loadGlyph
|
||||
|
@ -226,7 +226,7 @@ private:
|
||||
virtual QFixed lineThickness() const;
|
||||
virtual QFixed underlinePosition() const;
|
||||
|
||||
void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
void doKerning(QGlyphLayout *, ShaperFlags) const;
|
||||
|
||||
inline virtual Type type() const
|
||||
{ return QFontEngine::Freetype; }
|
||||
@ -242,14 +242,13 @@ private:
|
||||
virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs,
|
||||
QPainterPath *path, QTextItem::RenderFlags flags);
|
||||
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
|
||||
QTextEngine::ShaperFlags flags) const;
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
|
||||
|
||||
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
|
||||
virtual glyph_metrics_t boundingBox(glyph_t glyph);
|
||||
virtual glyph_metrics_t boundingBox(glyph_t glyph, const QTransform &matrix);
|
||||
|
||||
virtual void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags flags) const;
|
||||
virtual QImage alphaMapForGlyph(glyph_t g) { return alphaMapForGlyph(g, 0); }
|
||||
virtual QImage alphaMapForGlyph(glyph_t, QFixed);
|
||||
virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
|
||||
|
@ -72,7 +72,6 @@ QT_BEGIN_NAMESPACE
|
||||
class QChar;
|
||||
class QPainterPath;
|
||||
|
||||
class QTextEngine;
|
||||
struct QGlyphLayout;
|
||||
|
||||
#define MAKE_TAG(ch1, ch2, ch3, ch4) (\
|
||||
@ -116,6 +115,13 @@ public:
|
||||
Format_A32
|
||||
};
|
||||
|
||||
enum ShaperFlag {
|
||||
RightToLeft = 0x0001,
|
||||
DesignMetrics = 0x0002,
|
||||
GlyphIndicesOnly = 0x0004
|
||||
};
|
||||
Q_DECLARE_FLAGS(ShaperFlags, ShaperFlag)
|
||||
|
||||
QFontEngine();
|
||||
virtual ~QFontEngine();
|
||||
|
||||
@ -158,14 +164,14 @@ public:
|
||||
virtual QFixed emSquareSize() const { return ascent(); }
|
||||
|
||||
/* returns 0 as glyph index for non existent glyphs */
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const = 0;
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const = 0;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const {}
|
||||
virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const {}
|
||||
virtual void doKerning(QGlyphLayout *, ShaperFlags) const;
|
||||
|
||||
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
|
||||
QPainterPath *path, QTextItem::RenderFlags flags);
|
||||
@ -301,6 +307,8 @@ private:
|
||||
mutable QLinkedList<GlyphCacheEntry> m_glyphCaches;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QFontEngine::ShaperFlags)
|
||||
|
||||
inline bool operator ==(const QFontEngine::FaceId &f1, const QFontEngine::FaceId &f2)
|
||||
{
|
||||
return (f1.index == f2.index) && (f1.encoding == f2.encoding) && (f1.filename == f2.filename);
|
||||
@ -322,8 +330,8 @@ public:
|
||||
QFontEngineBox(int size);
|
||||
~QFontEngineBox();
|
||||
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const;
|
||||
|
||||
void draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &si);
|
||||
virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags);
|
||||
@ -359,14 +367,13 @@ public:
|
||||
explicit QFontEngineMulti(int engineCount);
|
||||
~QFontEngineMulti();
|
||||
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
|
||||
QTextEngine::ShaperFlags flags) const;
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
|
||||
|
||||
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
|
||||
virtual glyph_metrics_t boundingBox(glyph_t glyph);
|
||||
|
||||
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const;
|
||||
virtual void doKerning(QGlyphLayout *, ShaperFlags) const;
|
||||
virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags);
|
||||
virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
|
||||
|
||||
|
@ -339,7 +339,7 @@ bool QFontEngineQPA::getSfntTableData(uint tag, uchar *buffer, uint *length) con
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QFontEngineQPA::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
|
||||
bool QFontEngineQPA::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
if (*nglyphs < len) {
|
||||
*nglyphs = len;
|
||||
@ -352,7 +352,7 @@ bool QFontEngineQPA::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph
|
||||
|
||||
const uchar *cmap = externalCMap ? externalCMap : (fontData + cmapOffset);
|
||||
|
||||
bool mirrored = flags & QTextEngine::RightToLeft;
|
||||
bool mirrored = flags & QFontEngine::RightToLeft;
|
||||
int glyph_pos = 0;
|
||||
if (symbol) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@ -387,7 +387,7 @@ bool QFontEngineQPA::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph
|
||||
return true;
|
||||
}
|
||||
|
||||
void QFontEngineQPA::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const
|
||||
void QFontEngineQPA::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags) const
|
||||
{
|
||||
for (int i = 0; i < glyphs->numGlyphs; ++i) {
|
||||
const Glyph *g = findGlyph(glyphs->glyphs[i]);
|
||||
|
@ -165,8 +165,8 @@ public:
|
||||
FaceId faceId() const { return face_id; }
|
||||
bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
|
||||
|
||||
bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
|
||||
void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
|
||||
void recalcAdvances(QGlyphLayout *, ShaperFlags) const;
|
||||
|
||||
void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags);
|
||||
QImage alphaMapForGlyph(glyph_t t);
|
||||
|
@ -541,7 +541,7 @@ bool QFontEngineQPF::getSfntTableData(uint tag, uchar *buffer, uint *length) con
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QFontEngineQPF::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
|
||||
bool QFontEngineQPF::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
if (!externalCMap && !cmapOffset && renderingFontEngine) {
|
||||
if (!renderingFontEngine->stringToCMap(str, len, glyphs, nglyphs, flags))
|
||||
@ -563,7 +563,7 @@ bool QFontEngineQPF::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph
|
||||
|
||||
const uchar *cmap = externalCMap ? externalCMap : (fontData + cmapOffset);
|
||||
|
||||
bool mirrored = flags & QTextEngine::RightToLeft;
|
||||
bool mirrored = flags & RightToLeft;
|
||||
int glyph_pos = 0;
|
||||
if (symbol) {
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@ -596,7 +596,7 @@ bool QFontEngineQPF::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph
|
||||
return true;
|
||||
}
|
||||
|
||||
void QFontEngineQPF::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const
|
||||
void QFontEngineQPF::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags) const
|
||||
{
|
||||
#ifndef QT_NO_FREETYPE
|
||||
const_cast<QFontEngineQPF *>(this)->ensureGlyphsLoaded(*glyphs);
|
||||
@ -835,7 +835,7 @@ void QFontEngineQPF::unlockFace() const
|
||||
freetype->unlock();
|
||||
}
|
||||
|
||||
void QFontEngineQPF::doKerning(QGlyphLayout *g, QTextEngine::ShaperFlags flags) const
|
||||
void QFontEngineQPF::doKerning(QGlyphLayout *g, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
if (!kerning_pairs_loaded) {
|
||||
kerning_pairs_loaded = true;
|
||||
|
@ -170,8 +170,8 @@ public:
|
||||
FaceId faceId() const { return face_id; }
|
||||
bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
|
||||
|
||||
bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
|
||||
void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
|
||||
void recalcAdvances(QGlyphLayout *, ShaperFlags) const;
|
||||
|
||||
void draw(QPaintEngine *p, qreal x, qreal y, const QTextItemInt &si);
|
||||
void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags);
|
||||
@ -207,7 +207,7 @@ public:
|
||||
#if !defined(QT_NO_FREETYPE)
|
||||
FT_Face lockFace() const;
|
||||
void unlockFace() const;
|
||||
void doKerning(QGlyphLayout *g, QTextEngine::ShaperFlags flags) const;
|
||||
void doKerning(QGlyphLayout *g, ShaperFlags flags) const;
|
||||
virtual HB_Error getPointInOutline(HB_Glyph glyph, int flags, hb_uint32 point, HB_Fixed *xpos, HB_Fixed *ypos, hb_uint32 *nPoints);
|
||||
virtual QFixed emSquareSize() const;
|
||||
#endif
|
||||
|
@ -201,7 +201,7 @@ QVector<int> QFontSubset::getReverseMap() const
|
||||
for (uint uc = 0; uc < 0x10000; ++uc) {
|
||||
QChar ch(uc);
|
||||
int nglyphs = 10;
|
||||
fontEngine->stringToCMap(&ch, 1, &glyphs, &nglyphs, QTextEngine::GlyphIndicesOnly);
|
||||
fontEngine->stringToCMap(&ch, 1, &glyphs, &nglyphs, QFontEngine::GlyphIndicesOnly);
|
||||
int idx = glyph_indices.indexOf(glyphs.glyphs[0]);
|
||||
if (idx >= 0 && !reverseMap.at(idx))
|
||||
reverseMap[idx] = uc;
|
||||
|
@ -496,7 +496,7 @@ bool QRawFont::glyphIndexesForChars(const QChar *chars, int numChars, quint32 *g
|
||||
|
||||
QGlyphLayout glyphs;
|
||||
glyphs.glyphs = glyphIndexes;
|
||||
return d->fontEngine->stringToCMap(chars, numChars, &glyphs, numGlyphs, QTextEngine::GlyphIndicesOnly);
|
||||
return d->fontEngine->stringToCMap(chars, numChars, &glyphs, numGlyphs, QFontEngine::GlyphIndicesOnly);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -849,9 +849,9 @@ static bool stringToGlyphs(HB_ShaperItem *item, QGlyphLayout *glyphs, QFontEngin
|
||||
{
|
||||
int nGlyphs = item->num_glyphs;
|
||||
|
||||
QTextEngine::ShaperFlags shaperFlags(QTextEngine::GlyphIndicesOnly);
|
||||
QFontEngine::ShaperFlags shaperFlags(QFontEngine::GlyphIndicesOnly);
|
||||
if (item->item.bidiLevel % 2)
|
||||
shaperFlags |= QTextEngine::RightToLeft;
|
||||
shaperFlags |= QFontEngine::RightToLeft;
|
||||
|
||||
bool result = fontEngine->stringToCMap(reinterpret_cast<const QChar *>(item->string + item->item.pos), item->item.length, glyphs, &nGlyphs, shaperFlags);
|
||||
item->num_glyphs = nGlyphs;
|
||||
@ -1140,7 +1140,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
|
||||
shaper_item.log_clusters[i] += glyph_pos;
|
||||
|
||||
if (kerningEnabled && !shaper_item.kerning_applied)
|
||||
actualFontEngine->doKerning(&g, option.useDesignMetrics() ? QFlag(QTextEngine::DesignMetrics) : QFlag(0));
|
||||
actualFontEngine->doKerning(&g, option.useDesignMetrics() ? QFontEngine::DesignMetrics : QFontEngine::ShaperFlags(0));
|
||||
|
||||
if (engineIdx != 0) {
|
||||
for (hb_uint32 i = 0; i < shaper_item.num_glyphs; ++i)
|
||||
|
@ -459,14 +459,6 @@ public:
|
||||
WidthOnly = 0x07
|
||||
};
|
||||
|
||||
// keep in sync with QAbstractFontEngine::TextShapingFlag!!
|
||||
enum ShaperFlag {
|
||||
RightToLeft = 0x0001,
|
||||
DesignMetrics = 0x0002,
|
||||
GlyphIndicesOnly = 0x0004
|
||||
};
|
||||
Q_DECLARE_FLAGS(ShaperFlags, ShaperFlag)
|
||||
|
||||
void invalidate();
|
||||
void clearLineData();
|
||||
|
||||
@ -728,8 +720,6 @@ struct QTextLineItemIterator
|
||||
const QTextLayout::FormatRange *selection;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QTextEngine::ShaperFlags)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QTEXTENGINE_P_H
|
||||
|
@ -55,7 +55,7 @@ static float SYNTHETIC_ITALIC_SKEW = tanf(14 * acosf(0) / 90);
|
||||
static void loadAdvancesForGlyphs(CTFontRef ctfont,
|
||||
QVarLengthArray<CGGlyph> &cgGlyphs,
|
||||
QGlyphLayout *glyphs, int len,
|
||||
QTextEngine::ShaperFlags flags,
|
||||
QFontEngine::ShaperFlags flags,
|
||||
const QFontDef &fontDef)
|
||||
{
|
||||
Q_UNUSED(flags);
|
||||
@ -188,7 +188,7 @@ void QCoreTextFontEngine::init()
|
||||
}
|
||||
|
||||
bool QCoreTextFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,
|
||||
int *nglyphs, QTextEngine::ShaperFlags flags) const
|
||||
int *nglyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
QCFType<CFStringRef> cfstring;
|
||||
|
||||
@ -211,7 +211,7 @@ bool QCoreTextFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *
|
||||
}
|
||||
|
||||
*nglyphs = glyph_pos;
|
||||
if (flags & QTextEngine::GlyphIndicesOnly)
|
||||
if (flags & GlyphIndicesOnly)
|
||||
return true;
|
||||
|
||||
QVarLengthArray<CGSize> advances(glyph_pos);
|
||||
@ -536,7 +536,7 @@ QImage QCoreTextFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPo
|
||||
return im;
|
||||
}
|
||||
|
||||
void QCoreTextFontEngine::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
|
||||
void QCoreTextFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
int i, numGlyphs = glyphs->numGlyphs;
|
||||
QVarLengthArray<CGGlyph> cgGlyphs(numGlyphs);
|
||||
|
@ -67,8 +67,8 @@ public:
|
||||
QCoreTextFontEngine(CGFontRef font, const QFontDef &def);
|
||||
~QCoreTextFontEngine();
|
||||
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *, ShaperFlags) const;
|
||||
|
||||
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
|
||||
virtual glyph_metrics_t boundingBox(glyph_t glyph);
|
||||
|
@ -356,19 +356,18 @@ HGDIOBJ QWindowsFontEngine::selectDesignFont() const
|
||||
return SelectObject(m_fontEngineData->hdc, designFont);
|
||||
}
|
||||
|
||||
bool QWindowsFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
|
||||
bool QWindowsFontEngine::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
if (*nglyphs < len) {
|
||||
*nglyphs = len;
|
||||
return false;
|
||||
}
|
||||
|
||||
*nglyphs = getGlyphIndexes(str, len, glyphs, flags & QTextEngine::RightToLeft);
|
||||
|
||||
if (flags & QTextEngine::GlyphIndicesOnly)
|
||||
return true;
|
||||
*nglyphs = getGlyphIndexes(str, len, glyphs, flags & RightToLeft);
|
||||
|
||||
if (!(flags & GlyphIndicesOnly))
|
||||
recalcAdvances(glyphs, flags);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -382,11 +381,11 @@ inline void calculateTTFGlyphWidth(HDC hdc, UINT glyph, int &width)
|
||||
#endif
|
||||
}
|
||||
|
||||
void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const
|
||||
void QWindowsFontEngine::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
HGDIOBJ oldFont = 0;
|
||||
HDC hdc = m_fontEngineData->hdc;
|
||||
if (ttf && (flags & QTextEngine::DesignMetrics)) {
|
||||
if (ttf && (flags & DesignMetrics)) {
|
||||
for(int i = 0; i < glyphs->numGlyphs; i++) {
|
||||
unsigned int glyph = glyphs->glyphs[i];
|
||||
if(int(glyph) >= designAdvancesSize) {
|
||||
|
@ -89,8 +89,8 @@ public:
|
||||
virtual int synthesized() const;
|
||||
virtual QFixed emSquareSize() const;
|
||||
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const;
|
||||
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
|
||||
virtual void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags) const;
|
||||
|
||||
virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags flags);
|
||||
virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
|
||||
|
@ -310,13 +310,13 @@ inline unsigned int getChar(const QChar *str, int &i, const int len)
|
||||
}
|
||||
|
||||
bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs,
|
||||
int *nglyphs, QTextEngine::ShaperFlags flags) const
|
||||
int *nglyphs, QFontEngine::ShaperFlags flags) const
|
||||
{
|
||||
if (m_directWriteFontFace != 0) {
|
||||
QVarLengthArray<UINT32> codePoints(len);
|
||||
for (int i=0; i<len; ++i) {
|
||||
codePoints[i] = getChar(str, i, len);
|
||||
if (flags & QTextEngine::RightToLeft)
|
||||
if (flags & QFontEngine::RightToLeft)
|
||||
codePoints[i] = QChar::mirroredChar(codePoints[i]);
|
||||
}
|
||||
|
||||
@ -331,7 +331,7 @@ bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGly
|
||||
|
||||
*nglyphs = len;
|
||||
|
||||
if (!(flags & QTextEngine::GlyphIndicesOnly))
|
||||
if (!(flags & GlyphIndicesOnly))
|
||||
recalcAdvances(glyphs, 0);
|
||||
|
||||
return true;
|
||||
@ -343,7 +343,7 @@ bool QWindowsFontEngineDirectWrite::stringToCMap(const QChar *str, int len, QGly
|
||||
return false;
|
||||
}
|
||||
|
||||
void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const
|
||||
void QWindowsFontEngineDirectWrite::recalcAdvances(QGlyphLayout *glyphs, QFontEngine::ShaperFlags) const
|
||||
{
|
||||
if (m_directWriteFontFace == 0)
|
||||
return;
|
||||
|
@ -72,8 +72,8 @@ public:
|
||||
bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
|
||||
QFixed emSquareSize() const;
|
||||
|
||||
bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const;
|
||||
void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags) const;
|
||||
bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, ShaperFlags flags) const;
|
||||
void recalcAdvances(QGlyphLayout *glyphs, ShaperFlags) const;
|
||||
|
||||
void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs,
|
||||
QPainterPath *path, QTextItem::RenderFlags flags);
|
||||
|
Loading…
Reference in New Issue
Block a user