Port QFontSubset API from int to qsizetype
Removing the impedance mismatch with the Qt containers. Task-number: QTBUG-104814 Change-Id: I141d9056249644b90c404219792e0fcd87960f7c Reviewed-by: Lars Knoll <lars.knoll@gmail.com> (cherry picked from commit f2c9f8c83781fea73b148bf24472f1d3d191c26e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
c677238643
commit
749bce16a0
@ -1961,7 +1961,7 @@ void QPdfEnginePrivate::embedFont(QFontSubset *font)
|
|||||||
QByteArray cidSetStream(font->nGlyphs() / 8 + 1, 0);
|
QByteArray cidSetStream(font->nGlyphs() / 8 + 1, 0);
|
||||||
int byteCounter = 0;
|
int byteCounter = 0;
|
||||||
int bitCounter = 0;
|
int bitCounter = 0;
|
||||||
for (int i = 0; i < font->nGlyphs(); ++i) {
|
for (qsizetype i = 0; i < font->nGlyphs(); ++i) {
|
||||||
cidSetStream.data()[byteCounter] |= (1 << (7 - bitCounter));
|
cidSetStream.data()[byteCounter] |= (1 << (7 - bitCounter));
|
||||||
|
|
||||||
bitCounter++;
|
bitCounter++;
|
||||||
@ -3081,7 +3081,7 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti)
|
|||||||
x += .3*y;
|
x += .3*y;
|
||||||
x /= stretch;
|
x /= stretch;
|
||||||
char buf[5];
|
char buf[5];
|
||||||
int g = font->addGlyph(glyphs[i]);
|
qsizetype g = font->addGlyph(glyphs[i]);
|
||||||
*currentPage << x - last_x << last_y - y << "Td <"
|
*currentPage << x - last_x << last_y - y << "Td <"
|
||||||
<< QPdf::toHex((ushort)g, buf) << "> Tj\n";
|
<< QPdf::toHex((ushort)g, buf) << "> Tj\n";
|
||||||
last_x = x;
|
last_x = x;
|
||||||
@ -3101,7 +3101,7 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti)
|
|||||||
x += .3*y;
|
x += .3*y;
|
||||||
x /= stretch;
|
x /= stretch;
|
||||||
char buf[5];
|
char buf[5];
|
||||||
int g = font->addGlyph(glyphs[i]);
|
qsizetype g = font->addGlyph(glyphs[i]);
|
||||||
*currentPage << x - last_x << last_y - y << "Td <"
|
*currentPage << x - last_x << last_y - y << "Td <"
|
||||||
<< QPdf::toHex((ushort)g, buf) << "> Tj\n";
|
<< QPdf::toHex((ushort)g, buf) << "> Tj\n";
|
||||||
last_x = x;
|
last_x = x;
|
||||||
|
@ -90,7 +90,7 @@ QByteArray QFontSubset::widthArray() const
|
|||||||
|
|
||||||
QFixed defWidth = widths[0];
|
QFixed defWidth = widths[0];
|
||||||
//qDebug("defWidth=%d, scale=%f", defWidth.toInt(), scale.toReal());
|
//qDebug("defWidth=%d, scale=%f", defWidth.toInt(), scale.toReal());
|
||||||
for (int i = 0; i < nGlyphs(); ++i) {
|
for (qsizetype i = 0; i < nGlyphs(); ++i) {
|
||||||
if (defWidth != widths[i])
|
if (defWidth != widths[i])
|
||||||
defWidth = 0;
|
defWidth = 0;
|
||||||
}
|
}
|
||||||
@ -98,10 +98,10 @@ QByteArray QFontSubset::widthArray() const
|
|||||||
s << "/DW " << qRound(defWidth.toInt() * scale);
|
s << "/DW " << qRound(defWidth.toInt() * scale);
|
||||||
} else {
|
} else {
|
||||||
s << "/W [";
|
s << "/W [";
|
||||||
for (int g = 0; g < nGlyphs();) {
|
for (qsizetype g = 0; g < nGlyphs();) {
|
||||||
QFixed w = widths[g];
|
QFixed w = widths[g];
|
||||||
int start = g;
|
qsizetype start = g;
|
||||||
int startLinear = 0;
|
qsizetype startLinear = 0;
|
||||||
++g;
|
++g;
|
||||||
while (g < nGlyphs()) {
|
while (g < nGlyphs()) {
|
||||||
QFixed nw = widths[g];
|
QFixed nw = widths[g];
|
||||||
@ -119,11 +119,11 @@ QByteArray QFontSubset::widthArray() const
|
|||||||
// qDebug("start=%x startLinear=%x g-1=%x",start,startLinear,g-1);
|
// qDebug("start=%x startLinear=%x g-1=%x",start,startLinear,g-1);
|
||||||
if (g - startLinear < 10)
|
if (g - startLinear < 10)
|
||||||
startLinear = 0;
|
startLinear = 0;
|
||||||
int endnonlinear = startLinear ? startLinear : g;
|
qsizetype endnonlinear = startLinear ? startLinear : g;
|
||||||
// qDebug(" startLinear=%x endnonlinear=%x", startLinear,endnonlinear);
|
// qDebug(" startLinear=%x endnonlinear=%x", startLinear,endnonlinear);
|
||||||
if (endnonlinear > start) {
|
if (endnonlinear > start) {
|
||||||
s << start << '[';
|
s << start << '[';
|
||||||
for (int i = start; i < endnonlinear; ++i)
|
for (qsizetype i = start; i < endnonlinear; ++i)
|
||||||
s << qRound(widths[i].toInt() * scale);
|
s << qRound(widths[i].toInt() * scale);
|
||||||
s << "]\n";
|
s << "]\n";
|
||||||
}
|
}
|
||||||
@ -177,14 +177,14 @@ QByteArray QFontSubset::createToUnicodeMap() const
|
|||||||
QPdf::ByteStream s(&ranges);
|
QPdf::ByteStream s(&ranges);
|
||||||
|
|
||||||
char buf[5];
|
char buf[5];
|
||||||
for (int g = 1; g < nGlyphs(); ) {
|
for (qsizetype g = 1; g < nGlyphs(); ) {
|
||||||
int uc0 = reverseMap.at(g);
|
int uc0 = reverseMap.at(g);
|
||||||
if (!uc0) {
|
if (!uc0) {
|
||||||
++g;
|
++g;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int start = g;
|
qsizetype start = g;
|
||||||
int startLinear = 0;
|
qsizetype startLinear = 0;
|
||||||
++g;
|
++g;
|
||||||
while (g < nGlyphs()) {
|
while (g < nGlyphs()) {
|
||||||
int uc = reverseMap[g];
|
int uc = reverseMap[g];
|
||||||
@ -205,7 +205,7 @@ QByteArray QFontSubset::createToUnicodeMap() const
|
|||||||
// qDebug("start=%x startLinear=%x g-1=%x",start,startLinear,g-1);
|
// qDebug("start=%x startLinear=%x g-1=%x",start,startLinear,g-1);
|
||||||
if (g - startLinear < 10)
|
if (g - startLinear < 10)
|
||||||
startLinear = 0;
|
startLinear = 0;
|
||||||
int endnonlinear = startLinear ? startLinear : g;
|
qsizetype endnonlinear = startLinear ? startLinear : g;
|
||||||
// qDebug(" startLinear=%x endnonlinear=%x", startLinear,endnonlinear);
|
// qDebug(" startLinear=%x endnonlinear=%x", startLinear,endnonlinear);
|
||||||
if (endnonlinear > start) {
|
if (endnonlinear > start) {
|
||||||
s << '<' << QPdf::toHex((ushort)start, buf) << "> <";
|
s << '<' << QPdf::toHex((ushort)start, buf) << "> <";
|
||||||
@ -214,7 +214,7 @@ QByteArray QFontSubset::createToUnicodeMap() const
|
|||||||
s << '<' << QPdf::toHex((ushort)reverseMap[start], buf) << ">\n";
|
s << '<' << QPdf::toHex((ushort)reverseMap[start], buf) << ">\n";
|
||||||
} else {
|
} else {
|
||||||
s << '[';
|
s << '[';
|
||||||
for (int i = start; i < endnonlinear; ++i) {
|
for (qsizetype i = start; i < endnonlinear; ++i) {
|
||||||
s << '<' << QPdf::toHex((ushort)reverseMap[i], buf) << "> ";
|
s << '<' << QPdf::toHex((ushort)reverseMap[i], buf) << "> ";
|
||||||
}
|
}
|
||||||
s << "]\n";
|
s << "]\n";
|
||||||
@ -223,9 +223,9 @@ QByteArray QFontSubset::createToUnicodeMap() const
|
|||||||
}
|
}
|
||||||
if (startLinear) {
|
if (startLinear) {
|
||||||
while (startLinear < g) {
|
while (startLinear < g) {
|
||||||
int len = g - startLinear;
|
qsizetype len = g - startLinear;
|
||||||
int uc_start = reverseMap[startLinear];
|
qsizetype uc_start = reverseMap[startLinear];
|
||||||
int uc_end = uc_start + len - 1;
|
qsizetype uc_end = uc_start + len - 1;
|
||||||
if ((uc_end >> 8) != (uc_start >> 8))
|
if ((uc_end >> 8) != (uc_start >> 8))
|
||||||
len = 256 - (uc_start & 0xff);
|
len = 256 - (uc_start & 0xff);
|
||||||
s << '<' << QPdf::toHex((ushort)startLinear, buf) << "> <";
|
s << '<' << QPdf::toHex((ushort)startLinear, buf) << "> <";
|
||||||
@ -248,14 +248,14 @@ QByteArray QFontSubset::createToUnicodeMap() const
|
|||||||
return touc;
|
return touc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int QFontSubset::addGlyph(uint index)
|
qsizetype QFontSubset::addGlyph(uint index)
|
||||||
{
|
{
|
||||||
qsizetype idx = glyph_indices.indexOf(index);
|
qsizetype idx = glyph_indices.indexOf(index);
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
idx = glyph_indices.size();
|
idx = glyph_indices.size();
|
||||||
glyph_indices.append(index);
|
glyph_indices.append(index);
|
||||||
}
|
}
|
||||||
return (int)idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // QT_NO_PDF
|
#endif // QT_NO_PDF
|
||||||
@ -1147,12 +1147,12 @@ QByteArray QFontSubset::toTruetype() const
|
|||||||
font.maxp.maxCompositeContours = 0;
|
font.maxp.maxCompositeContours = 0;
|
||||||
font.maxp.maxComponentElements = 0;
|
font.maxp.maxComponentElements = 0;
|
||||||
font.maxp.maxComponentDepth = 0;
|
font.maxp.maxComponentDepth = 0;
|
||||||
const int numGlyphs = nGlyphs();
|
const qsizetype numGlyphs = nGlyphs();
|
||||||
font.maxp.numGlyphs = numGlyphs;
|
font.maxp.numGlyphs = quint16(numGlyphs);
|
||||||
QList<QTtfGlyph> glyphs;
|
QList<QTtfGlyph> glyphs;
|
||||||
glyphs.reserve(numGlyphs);
|
glyphs.reserve(numGlyphs);
|
||||||
|
|
||||||
for (int i = 0; i < numGlyphs; ++i) {
|
for (qsizetype i = 0; i < numGlyphs; ++i) {
|
||||||
glyph_t g = glyph_indices.at(i);
|
glyph_t g = glyph_indices.at(i);
|
||||||
QPainterPath path;
|
QPainterPath path;
|
||||||
glyph_metrics_t metric;
|
glyph_metrics_t metric;
|
||||||
|
@ -44,7 +44,7 @@ public:
|
|||||||
|
|
||||||
static QByteArray glyphName(unsigned short unicode, bool symbol);
|
static QByteArray glyphName(unsigned short unicode, bool symbol);
|
||||||
|
|
||||||
int addGlyph(uint index);
|
qsizetype addGlyph(uint index);
|
||||||
#endif
|
#endif
|
||||||
const uint object_id;
|
const uint object_id;
|
||||||
bool noEmbed;
|
bool noEmbed;
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
QList<uint> glyph_indices;
|
QList<uint> glyph_indices;
|
||||||
mutable int downloaded_glyphs;
|
mutable int downloaded_glyphs;
|
||||||
mutable bool standard_font;
|
mutable bool standard_font;
|
||||||
int nGlyphs() const { return glyph_indices.size(); }
|
qsizetype nGlyphs() const { return glyph_indices.size(); }
|
||||||
mutable QFixed emSquare;
|
mutable QFixed emSquare;
|
||||||
mutable QList<QFixed> widths;
|
mutable QList<QFixed> widths;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user