mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 10:52:56 +00:00
remove unused harfbuzz offsets related code
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
31ff2625cd
commit
ac7aac3fbd
5 changed files with 10 additions and 134 deletions
|
@ -110,8 +110,8 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform
|
||||||
if (!transform) {
|
if (!transform) {
|
||||||
while (i < glyphs.numGlyphs) {
|
while (i < glyphs.numGlyphs) {
|
||||||
if (!glyphs.attributes[i].dontPrint) {
|
if (!glyphs.attributes[i].dontPrint) {
|
||||||
positions[current].x = xpos + glyphs.offsets[i].x;
|
positions[current].x = xpos;
|
||||||
positions[current].y = ypos + glyphs.offsets[i].y;
|
positions[current].y = ypos;
|
||||||
glyphs_out[current] = glyphs.glyphs[i];
|
glyphs_out[current] = glyphs.glyphs[i];
|
||||||
xpos += glyphs.advances_x[i] + QFixed::fromFixed(glyphs.justifications[i].space_18d6);
|
xpos += glyphs.advances_x[i] + QFixed::fromFixed(glyphs.justifications[i].space_18d6);
|
||||||
++current;
|
++current;
|
||||||
|
@ -121,9 +121,7 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform
|
||||||
} else {
|
} else {
|
||||||
while (i < glyphs.numGlyphs) {
|
while (i < glyphs.numGlyphs) {
|
||||||
if (!glyphs.attributes[i].dontPrint) {
|
if (!glyphs.attributes[i].dontPrint) {
|
||||||
QFixed gpos_x = xpos + glyphs.offsets[i].x;
|
QPointF gpos(xpos.toReal(), ypos.toReal());
|
||||||
QFixed gpos_y = ypos + glyphs.offsets[i].y;
|
|
||||||
QPointF gpos(gpos_x.toReal(), gpos_y.toReal());
|
|
||||||
gpos = gpos * matrix;
|
gpos = gpos * matrix;
|
||||||
positions[current].x = QFixed::fromReal(gpos.x());
|
positions[current].x = QFixed::fromReal(gpos.x());
|
||||||
positions[current].y = QFixed::fromReal(gpos.y());
|
positions[current].y = QFixed::fromReal(gpos.y());
|
||||||
|
@ -443,10 +441,6 @@ void QFontEngineBox::addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, in
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFixedPoint offset = g.offsets[i];
|
|
||||||
advanceX += offset.x;
|
|
||||||
advanceY += offset.y;
|
|
||||||
|
|
||||||
path->moveTo((advanceX + metrics.x).toReal(), (advanceY + metrics.y).toReal());
|
path->moveTo((advanceX + metrics.x).toReal(), (advanceY + metrics.y).toReal());
|
||||||
path->addRect(QRectF(0.0, 0.0, _size, _size));
|
path->addRect(QRectF(0.0, 0.0, _size, _size));
|
||||||
path->closeSubpath();
|
path->closeSubpath();
|
||||||
|
|
|
@ -64,21 +64,6 @@ static void qHB_GetUnicodeCharProperties(HB_UChar32 ch, HB_CharCategory *categor
|
||||||
*combiningClass = QUnicodeTables::combiningClass(ch);
|
*combiningClass = QUnicodeTables::combiningClass(ch);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qHB_getGlyphMetrics(QFontEngine* fe, HB_Glyph glyph, HB_GlyphMetrics *metrics)
|
|
||||||
{
|
|
||||||
glyph_metrics_t m = fe->boundingBox(glyph);
|
|
||||||
metrics->x = m.x.value();
|
|
||||||
metrics->y = m.y.value();
|
|
||||||
metrics->width = m.width.value();
|
|
||||||
metrics->height = m.height.value();
|
|
||||||
metrics->xOffset = m.xoff.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
static HB_Fixed qHB_getGlyphAscent(QFontEngine* fe)
|
|
||||||
{
|
|
||||||
return fe->ascent().value();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void qHB_GetGlyphAdvances(QFontEngine* fe, const HB_Glyph *glyphs, uint32_t numGlyphs, HB_Fixed *advances, int flags)
|
static void qHB_GetGlyphAdvances(QFontEngine* fe, const HB_Glyph *glyphs, uint32_t numGlyphs, HB_Fixed *advances, int flags)
|
||||||
{
|
{
|
||||||
QVarLengthGlyphLayoutArray qglyphs(numGlyphs);
|
QVarLengthGlyphLayoutArray qglyphs(numGlyphs);
|
||||||
|
@ -239,90 +224,10 @@ static inline void positionCluster(HB_ShaperItem *item, int gfrom, int glast)
|
||||||
int nmarks = glast - gfrom;
|
int nmarks = glast - gfrom;
|
||||||
assert(nmarks > 0);
|
assert(nmarks > 0);
|
||||||
|
|
||||||
HB_Glyph *glyphs = item->glyphs;
|
|
||||||
HB_GlyphAttributes *attributes = item->attributes;
|
|
||||||
|
|
||||||
HB_GlyphMetrics baseMetrics;
|
|
||||||
qHB_getGlyphMetrics(item->font, glyphs[gfrom], &baseMetrics);
|
|
||||||
|
|
||||||
if (item->item.script == HB_Script_Hebrew
|
|
||||||
&& (-baseMetrics.y) > baseMetrics.height)
|
|
||||||
// we need to attach below the baseline, because of the hebrew iud.
|
|
||||||
baseMetrics.height = -baseMetrics.y;
|
|
||||||
|
|
||||||
// qDebug("---> positionCluster: cluster from %d to %d", gfrom, glast);
|
// qDebug("---> positionCluster: cluster from %d to %d", gfrom, glast);
|
||||||
// qDebug("baseInfo: %f/%f (%f/%f) off=%f/%f", baseInfo.x, baseInfo.y, baseInfo.width, baseInfo.height, baseInfo.xoff, baseInfo.yoff);
|
// qDebug("baseInfo: %f/%f (%f/%f) off=%f/%f", baseInfo.x, baseInfo.y, baseInfo.width, baseInfo.height, baseInfo.xoff, baseInfo.yoff);
|
||||||
|
|
||||||
HB_Fixed size = qHB_getGlyphAscent(item->font) / 10;
|
|
||||||
HB_Fixed offsetBase = HB_FIXED_CONSTANT(1) + (size - HB_FIXED_CONSTANT(4)) / 4;
|
|
||||||
if (size > HB_FIXED_CONSTANT(4))
|
|
||||||
offsetBase += HB_FIXED_CONSTANT(4);
|
|
||||||
else
|
|
||||||
offsetBase += size;
|
|
||||||
// qreal offsetBase = (size - 4) / 4 + qMin<qreal>(size, 4) + 1;
|
|
||||||
// qDebug("offset = %f", offsetBase);
|
|
||||||
|
|
||||||
HB_CombiningClass lastCmb = HB_Combining_NotOrdered;
|
|
||||||
HB_GlyphMetrics attachmentRect;
|
|
||||||
memset(&attachmentRect, 0, sizeof(attachmentRect));
|
|
||||||
|
|
||||||
for(int i = 1; i <= nmarks; i++) {
|
for(int i = 1; i <= nmarks; i++) {
|
||||||
HB_Glyph mark = glyphs[gfrom+i];
|
|
||||||
HB_GlyphMetrics markMetrics;
|
|
||||||
qHB_getGlyphMetrics(item->font, mark, &markMetrics);
|
|
||||||
HB_FixedPoint p;
|
|
||||||
p.x = p.y = 0;
|
|
||||||
// qDebug("markInfo: %f/%f (%f/%f) off=%f/%f", markInfo.x, markInfo.y, markInfo.width, markInfo.height, markInfo.xoff, markInfo.yoff);
|
|
||||||
|
|
||||||
HB_Fixed offset = offsetBase;
|
|
||||||
HB_CombiningClass cmb = attributes[gfrom+i].combiningClass;
|
|
||||||
|
|
||||||
// combining marks of different class don't interact. Reset the rectangle.
|
|
||||||
if (cmb != lastCmb) {
|
|
||||||
// qDebug("resetting rect");
|
|
||||||
attachmentRect = baseMetrics;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(cmb) {
|
|
||||||
case HB_Combining_DoubleBelow:
|
|
||||||
// ### wrong in rtl context!
|
|
||||||
case HB_Combining_BelowLeft:
|
|
||||||
p.y += offset;
|
|
||||||
case HB_Combining_Below:
|
|
||||||
p.y += offset;
|
|
||||||
case HB_Combining_BelowRight:
|
|
||||||
p.y += offset;
|
|
||||||
case HB_Combining_Left:
|
|
||||||
p.x -= offset;
|
|
||||||
case HB_Combining_Right:
|
|
||||||
p.x += offset;
|
|
||||||
case HB_Combining_DoubleAbove:
|
|
||||||
// ### wrong in RTL context!
|
|
||||||
case HB_Combining_AboveLeft:
|
|
||||||
p.y -= offset;
|
|
||||||
case HB_Combining_Above:
|
|
||||||
p.y -= offset;
|
|
||||||
case HB_Combining_AboveRight:
|
|
||||||
p.y -= offset;
|
|
||||||
|
|
||||||
case HB_Combining_IotaSubscript:
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// qDebug("char=%x combiningClass = %d offset=%f/%f", mark, cmb, p.x(), p.y());
|
|
||||||
markMetrics.x += p.x;
|
|
||||||
markMetrics.y += p.y;
|
|
||||||
|
|
||||||
HB_GlyphMetrics unitedAttachmentRect = attachmentRect;
|
|
||||||
unitedAttachmentRect.x = HB_MIN(attachmentRect.x, markMetrics.x);
|
|
||||||
unitedAttachmentRect.y = HB_MIN(attachmentRect.y, markMetrics.y);
|
|
||||||
unitedAttachmentRect.width = HB_MAX(attachmentRect.x + attachmentRect.width, markMetrics.x + markMetrics.width) - unitedAttachmentRect.x;
|
|
||||||
unitedAttachmentRect.height = HB_MAX(attachmentRect.y + attachmentRect.height, markMetrics.y + markMetrics.height) - unitedAttachmentRect.y;
|
|
||||||
attachmentRect = unitedAttachmentRect;
|
|
||||||
|
|
||||||
lastCmb = cmb;
|
|
||||||
item->offsets[gfrom+i].x = p.x - baseMetrics.xOffset;
|
|
||||||
item->offsets[gfrom+i].y = p.y;
|
|
||||||
item->advances[gfrom+i] = 0;
|
item->advances[gfrom+i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -373,17 +373,6 @@ typedef struct {
|
||||||
bool charStop; /* Valid cursor position (for left/right arrow) */
|
bool charStop; /* Valid cursor position (for left/right arrow) */
|
||||||
} HB_CharAttributes;
|
} HB_CharAttributes;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
HB_Fixed x;
|
|
||||||
HB_Fixed y;
|
|
||||||
} HB_FixedPoint;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
HB_Fixed x, y;
|
|
||||||
HB_Fixed width, height;
|
|
||||||
HB_Fixed xOffset;
|
|
||||||
} HB_GlyphMetrics;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t pos;
|
uint32_t pos;
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
|
@ -412,7 +401,6 @@ typedef struct {
|
||||||
HB_Glyph *glyphs; /* output: <num_glyphs> indices of shaped glyphs */
|
HB_Glyph *glyphs; /* output: <num_glyphs> indices of shaped glyphs */
|
||||||
HB_GlyphAttributes *attributes; /* output: <num_glyphs> glyph attributes */
|
HB_GlyphAttributes *attributes; /* output: <num_glyphs> glyph attributes */
|
||||||
HB_Fixed *advances; /* output: <num_glyphs> advances */
|
HB_Fixed *advances; /* output: <num_glyphs> advances */
|
||||||
HB_FixedPoint *offsets; /* output: <num_glyphs> offsets */
|
|
||||||
unsigned short *log_clusters; /* output: for each output glyph, the index in the input of the start of its logical cluster */
|
unsigned short *log_clusters; /* output: for each output glyph, the index in the input of the start of its logical cluster */
|
||||||
|
|
||||||
QFontEngine* font;
|
QFontEngine* font;
|
||||||
|
@ -424,7 +412,6 @@ void qHB_GetCharAttributes(const HB_UChar16 *string, uint32_t stringLength,
|
||||||
HB_CharAttributes *attributes);
|
HB_CharAttributes *attributes);
|
||||||
|
|
||||||
Q_DECLARE_TYPEINFO(HB_GlyphAttributes, Q_PRIMITIVE_TYPE);
|
Q_DECLARE_TYPEINFO(HB_GlyphAttributes, Q_PRIMITIVE_TYPE);
|
||||||
Q_DECLARE_TYPEINFO(HB_FixedPoint, Q_PRIMITIVE_TYPE);
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,6 @@ void QTextEngine::shapeText(int item) const
|
||||||
void QTextEngine::shapeTextWithHarfbuzz(int item) const
|
void QTextEngine::shapeTextWithHarfbuzz(int item) const
|
||||||
{
|
{
|
||||||
Q_ASSERT(sizeof(HB_Fixed) == sizeof(QFixed));
|
Q_ASSERT(sizeof(HB_Fixed) == sizeof(QFixed));
|
||||||
Q_ASSERT(sizeof(HB_FixedPoint) == sizeof(QFixedPoint));
|
|
||||||
|
|
||||||
QScriptItem &si = layoutData->items[item];
|
QScriptItem &si = layoutData->items[item];
|
||||||
|
|
||||||
|
@ -220,7 +219,6 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const
|
||||||
shaper_item.glyphs = g.glyphs;
|
shaper_item.glyphs = g.glyphs;
|
||||||
shaper_item.attributes = g.attributes;
|
shaper_item.attributes = g.attributes;
|
||||||
shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances_x);
|
shaper_item.advances = reinterpret_cast<HB_Fixed *>(g.advances_x);
|
||||||
shaper_item.offsets = reinterpret_cast<HB_FixedPoint *>(g.offsets);
|
|
||||||
|
|
||||||
if (shaper_item.glyphIndicesPresent) {
|
if (shaper_item.glyphIndicesPresent) {
|
||||||
for (uint32_t i = 0; i < shaper_item.initialGlyphCount; ++i)
|
for (uint32_t i = 0; i < shaper_item.initialGlyphCount; ++i)
|
||||||
|
|
|
@ -112,7 +112,6 @@ Q_DECLARE_TYPEINFO(QGlyphJustification, Q_PRIMITIVE_TYPE);
|
||||||
struct QGlyphLayout
|
struct QGlyphLayout
|
||||||
{
|
{
|
||||||
// init to 0 not needed, done when shaping
|
// init to 0 not needed, done when shaping
|
||||||
QFixedPoint *offsets; // 8 bytes per element
|
|
||||||
HB_Glyph *glyphs; // 4 bytes per element
|
HB_Glyph *glyphs; // 4 bytes per element
|
||||||
QFixed *advances_x; // 4 bytes per element
|
QFixed *advances_x; // 4 bytes per element
|
||||||
QGlyphJustification *justifications; // 4 bytes per element
|
QGlyphJustification *justifications; // 4 bytes per element
|
||||||
|
@ -124,10 +123,8 @@ struct QGlyphLayout
|
||||||
|
|
||||||
inline explicit QGlyphLayout(char *address, int totalGlyphs)
|
inline explicit QGlyphLayout(char *address, int totalGlyphs)
|
||||||
{
|
{
|
||||||
offsets = reinterpret_cast<QFixedPoint *>(address);
|
int offset = totalGlyphs * sizeof(HB_Glyph);
|
||||||
int offset = totalGlyphs * sizeof(HB_FixedPoint);
|
glyphs = reinterpret_cast<HB_Glyph *>(address);
|
||||||
glyphs = reinterpret_cast<HB_Glyph *>(address + offset);
|
|
||||||
offset += totalGlyphs * sizeof(HB_Glyph);
|
|
||||||
advances_x = reinterpret_cast<QFixed *>(address + offset);
|
advances_x = reinterpret_cast<QFixed *>(address + offset);
|
||||||
offset += totalGlyphs * sizeof(QFixed);
|
offset += totalGlyphs * sizeof(QFixed);
|
||||||
justifications = reinterpret_cast<QGlyphJustification *>(address + offset);
|
justifications = reinterpret_cast<QGlyphJustification *>(address + offset);
|
||||||
|
@ -140,7 +137,6 @@ struct QGlyphLayout
|
||||||
QGlyphLayout copy = *this;
|
QGlyphLayout copy = *this;
|
||||||
copy.glyphs += position;
|
copy.glyphs += position;
|
||||||
copy.advances_x += position;
|
copy.advances_x += position;
|
||||||
copy.offsets += position;
|
|
||||||
copy.justifications += position;
|
copy.justifications += position;
|
||||||
copy.attributes += position;
|
copy.attributes += position;
|
||||||
if (n == -1)
|
if (n == -1)
|
||||||
|
@ -152,8 +148,7 @@ struct QGlyphLayout
|
||||||
|
|
||||||
static inline int spaceNeededForGlyphLayout(int totalGlyphs) {
|
static inline int spaceNeededForGlyphLayout(int totalGlyphs) {
|
||||||
return totalGlyphs * (sizeof(HB_Glyph) + sizeof(HB_GlyphAttributes)
|
return totalGlyphs * (sizeof(HB_Glyph) + sizeof(HB_GlyphAttributes)
|
||||||
+ sizeof(QFixed) + sizeof(QFixedPoint)
|
+ sizeof(QFixed) + sizeof(QGlyphJustification));
|
||||||
+ sizeof(QGlyphJustification));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline QFixed effectiveAdvance(int item) const
|
inline QFixed effectiveAdvance(int item) const
|
||||||
|
@ -162,12 +157,10 @@ struct QGlyphLayout
|
||||||
inline void clear(int first = 0, int last = -1) {
|
inline void clear(int first = 0, int last = -1) {
|
||||||
if (last == -1)
|
if (last == -1)
|
||||||
last = numGlyphs;
|
last = numGlyphs;
|
||||||
if (first == 0 && last == numGlyphs
|
if (first == 0 && last == numGlyphs) {
|
||||||
&& reinterpret_cast<char *>(offsets + numGlyphs) == reinterpret_cast<char *>(glyphs)) {
|
memset(glyphs, 0, spaceNeededForGlyphLayout(numGlyphs));
|
||||||
memset(offsets, 0, spaceNeededForGlyphLayout(numGlyphs));
|
|
||||||
} else {
|
} else {
|
||||||
const int num = last - first;
|
const int num = last - first;
|
||||||
memset(offsets + first, 0, num * sizeof(QFixedPoint));
|
|
||||||
memset(glyphs + first, 0, num * sizeof(HB_Glyph));
|
memset(glyphs + first, 0, num * sizeof(HB_Glyph));
|
||||||
memset(advances_x + first, 0, num * sizeof(QFixed));
|
memset(advances_x + first, 0, num * sizeof(QFixed));
|
||||||
memset(justifications + first, 0, num * sizeof(QGlyphJustification));
|
memset(justifications + first, 0, num * sizeof(QGlyphJustification));
|
||||||
|
@ -176,7 +169,7 @@ struct QGlyphLayout
|
||||||
}
|
}
|
||||||
|
|
||||||
inline char *data() {
|
inline char *data() {
|
||||||
return reinterpret_cast<char *>(offsets);
|
return reinterpret_cast<char *>(glyphs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void grow(char *address, int totalGlyphs);
|
void grow(char *address, int totalGlyphs);
|
||||||
|
@ -214,8 +207,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void *buffer[(N * (sizeof(HB_Glyph) + sizeof(HB_GlyphAttributes)
|
void *buffer[(N * (sizeof(HB_Glyph) + sizeof(HB_GlyphAttributes)
|
||||||
+ sizeof(QFixed) + sizeof(QFixedPoint)
|
+ sizeof(QFixed) + sizeof(QGlyphJustification)))
|
||||||
+ sizeof(QGlyphJustification)))
|
|
||||||
/ QT_POINTER_SIZE + 1];
|
/ QT_POINTER_SIZE + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue