127bool QGlyphRun::operator==(
const QGlyphRun &other)
const
132 if ((d->glyphIndexDataSize != other.d->glyphIndexDataSize)
133 || (d->glyphPositionDataSize != other.d->glyphPositionDataSize)) {
137 if (d->glyphIndexData != other.d->glyphIndexData) {
138 for (
int i = 0; i < d->glyphIndexDataSize; ++i) {
139 if (d->glyphIndexData[i] != other.d->glyphIndexData[i])
143 if (d->glyphPositionData != other.d->glyphPositionData) {
144 for (
int i = 0; i < d->glyphPositionDataSize; ++i) {
145 if (d->glyphPositionData[i] != other.d->glyphPositionData[i])
150 return (d->flags == other.d->flags && d->rawFont == other.d->rawFont);
187QList<quint32> QGlyphRun::glyphIndexes()
const
189 if (d->glyphIndexes.constData() == d->glyphIndexData) {
190 return d->glyphIndexes;
192 QList<quint32> indexes(d->glyphIndexDataSize);
193 memcpy(indexes.data(), d->glyphIndexData, d->glyphIndexDataSize *
sizeof(quint32));
202void QGlyphRun::setGlyphIndexes(
const QList<quint32> &glyphIndexes)
205 d->glyphIndexes = glyphIndexes;
206 d->glyphIndexData = glyphIndexes.constData();
207 d->glyphIndexDataSize = glyphIndexes.size();
213QList<QPointF> QGlyphRun::positions()
const
215 if (d->glyphPositions.constData() == d->glyphPositionData) {
216 return d->glyphPositions;
218 QList<QPointF> glyphPositions(d->glyphPositionDataSize);
219 memcpy(glyphPositions.data(), d->glyphPositionData,
220 d->glyphPositionDataSize *
sizeof(QPointF));
221 return glyphPositions;
258void QGlyphRun::setRawData(
const quint32 *glyphIndexArray,
const QPointF *glyphPositionArray,
262 d->glyphIndexes.clear();
263 d->glyphPositions.clear();
265 d->glyphIndexData = glyphIndexArray;
266 d->glyphPositionData = glyphPositionArray;
267 d->glyphIndexDataSize = d->glyphPositionDataSize = size;
431QRectF QGlyphRun::boundingRect()
const
433 if (!d->boundingRect.isNull() || !d->rawFont.isValid())
434 return d->boundingRect;
436 qreal minX, minY, maxX, maxY;
437 minX = minY = maxX = maxY = 0;
439 for (
int i = 0, n = qMin(d->glyphIndexDataSize, d->glyphPositionDataSize); i < n; ++i) {
440 QRectF glyphRect = d->rawFont.boundingRect(d->glyphIndexData[i]);
441 glyphRect.translate(d->glyphPositionData[i]);
444 minX = glyphRect.left();
445 minY = glyphRect.top();
446 maxX = glyphRect.right();
447 maxY = glyphRect.bottom();
449 minX = qMin(glyphRect.left(), minX);
450 minY = qMin(glyphRect.top(), minY);
451 maxX = qMax(glyphRect.right(),maxX);
452 maxY = qMax(glyphRect.bottom(), maxY);
456 return QRectF(QPointF(minX, minY), QPointF(maxX, maxY));