Qt 4.8
Public Functions | Public Variables | List of all members
QPAGenerator Struct Reference

#include <qfontengine_qpa_p.h>

Public Functions

void align4 ()
 
void generate ()
 
 QPAGenerator (QBuffer *device, QFontEngine *engine)
 
void writeBlock (QFontEngineQPA::BlockTag tag, const QByteArray &data)
 
void writeGMap ()
 
void writeHeader ()
 
void writeInt8 (qint8 value)
 
void writeTaggedQFixed (QFontEngineQPA::HeaderTag tag, QFixed value)
 
void writeTaggedString (QFontEngineQPA::HeaderTag tag, const QByteArray &string)
 
void writeTaggedUInt32 (QFontEngineQPA::HeaderTag tag, quint32 value)
 
void writeTaggedUInt8 (QFontEngineQPA::HeaderTag tag, quint8 value)
 
void writeUInt16 (quint16 value)
 
void writeUInt32 (quint32 value)
 
void writeUInt8 (quint8 value)
 

Public Variables

QBufferdev
 
QFontEnginefe
 

Detailed Description

Definition at line 220 of file qfontengine_qpa_p.h.

Constructors and Destructors

◆ QPAGenerator()

QPAGenerator::QPAGenerator ( QBuffer device,
QFontEngine engine 
)
inline

Definition at line 222 of file qfontengine_qpa_p.h.

223  : dev(device), fe(engine) {}
QFontEngine * fe

Functions

◆ align4()

void QPAGenerator::align4 ( )
inline

Definition at line 240 of file qfontengine_qpa_p.h.

240 { while (dev->pos() & 3) { dev->putChar('\0'); } }
qint64 pos() const
Reimplemented Function
Definition: qbuffer.cpp:367
bool putChar(char c)
Writes the character c to the device.
Definition: qiodevice.cpp:1486

◆ generate()

void QPAGenerator::generate ( )

Definition at line 536 of file qfontengine_qpa.cpp.

537 {
538  writeHeader();
539  writeGMap();
541 
542  dev->seek(4); // position of header.lock
543  writeUInt32(0);
544 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool seek(qint64 off)
Reimplemented Function
Definition: qbuffer.cpp:384
void writeBlock(QFontEngineQPA::BlockTag tag, const QByteArray &data)
void writeUInt32(quint32 value)

◆ writeBlock()

void QPAGenerator::writeBlock ( QFontEngineQPA::BlockTag  tag,
const QByteArray data 
)

Definition at line 618 of file qfontengine_qpa.cpp.

619 {
620  writeUInt16(tag);
621  writeUInt16(0); // padding
622  const int padSize = ((data.size() + 3) / 4) * 4 - data.size();
623  writeUInt32(data.size() + padSize);
624  dev->write(data);
625  for (int i = 0; i < padSize; ++i)
626  writeUInt8(0);
627 }
void writeUInt8(quint8 value)
void writeUInt16(quint16 value)
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
void writeUInt32(quint32 value)
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342

◆ writeGMap()

void QPAGenerator::writeGMap ( )

Definition at line 602 of file qfontengine_qpa.cpp.

603 {
604  const quint16 glyphCount = fe->glyphCount();
605 
607  writeUInt16(0); // padding
608  writeUInt32(glyphCount * 4);
609 
610  QByteArray &buffer = dev->buffer();
611  const int numBytes = glyphCount * sizeof(quint32);
612  qint64 pos = buffer.size();
613  buffer.resize(pos + numBytes);
614  qMemSet(buffer.data() + pos, 0xff, numBytes);
615  dev->seek(pos + numBytes);
616 }
virtual int glyphCount() const
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
void writeUInt16(quint16 value)
bool seek(qint64 off)
Reimplemented Function
Definition: qbuffer.cpp:384
QByteArray & buffer()
Returns a reference to the QBuffer&#39;s internal buffer.
Definition: qbuffer.cpp:271
unsigned short quint16
Definition: qglobal.h:936
__int64 qint64
Definition: qglobal.h:942
void * qMemSet(void *dest, int c, size_t n)
Definition: qglobal.cpp:2509
void resize(int size)
Sets the size of the byte array to size bytes.
unsigned int quint32
Definition: qglobal.h:938
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
void writeUInt32(quint32 value)
QFontEngine * fe

◆ writeHeader()

void QPAGenerator::writeHeader ( )

Definition at line 546 of file qfontengine_qpa.cpp.

547 {
548  QFontEngineQPA::Header header;
549 
550  header.magic[0] = 'Q';
551  header.magic[1] = 'P';
552  header.magic[2] = 'F';
553  header.magic[3] = '2';
554  header.lock = 1;
557  header.dataSize = 0;
558  dev->write((const char *)&header, sizeof(header));
559 
561 
562  QFontEngine::FaceId face = fe->faceId();
565 
566  {
567  uchar data[4];
568  uint len = 4;
569  bool ok = fe->getSfntTableData(MAKE_TAG('h', 'e', 'a', 'd'), data, &len);
570  if (ok) {
571  const quint32 revision = qFromBigEndian<quint32>(data);
573  }
574  }
575 
589 
591 
593  align4();
594 
595  const quint64 size = dev->pos();
596  header.dataSize = qToBigEndian<quint16>(size - sizeof(header));
597  dev->seek(0);
598  dev->write((const char *)&header, sizeof(header));
599  dev->seek(size);
600 }
virtual QFixed lineThickness() const
virtual qreal minRightBearing() const
virtual QFixed averageCharWidth() const
void writeTaggedQFixed(QFontEngineQPA::HeaderTag tag, QFixed value)
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
Definition: qstring.cpp:4074
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
qint64 pos() const
Reimplemented Function
Definition: qbuffer.cpp:367
quint32 qFromBigEndian< quint32 >(const uchar *src)
Definition: qendian.h:239
static QFixed fromReal(qreal r)
Definition: qfixed_p.h:70
bool seek(qint64 off)
Reimplemented Function
Definition: qbuffer.cpp:384
#define MAKE_TAG(ch1, ch2, ch3, ch4)
virtual qreal maxCharWidth() const =0
unsigned char uchar
Definition: qglobal.h:994
unsigned __int64 quint64
Definition: qglobal.h:943
void writeTaggedUInt32(QFontEngineQPA::HeaderTag tag, quint32 value)
virtual QFixed ascent() const =0
void writeTaggedUInt8(QFontEngineQPA::HeaderTag tag, quint8 value)
virtual QFixed descent() const =0
static const char * data(const QByteArray &arr)
unsigned int uint
Definition: qglobal.h:996
uint weight
Definition: qfont_p.h:95
void writeTaggedString(QFontEngineQPA::HeaderTag tag, const QByteArray &string)
virtual FaceId faceId() const
virtual bool getSfntTableData(uint, uchar *, uint *) const
virtual qreal minLeftBearing() const
qreal pixelSize
Definition: qfont_p.h:90
virtual QFixed xHeight() const
uint style
Definition: qfont_p.h:97
unsigned int quint32
Definition: qglobal.h:938
QFontDef fontDef
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
QString family
Definition: qfont_p.h:82
virtual QFixed underlinePosition() const
virtual QFixed leading() const =0
QFontEngine * fe

◆ writeInt8()

void QPAGenerator::writeInt8 ( qint8  value)
inline

Definition at line 238 of file qfontengine_qpa_p.h.

238 { dev->write((const char *)&value, sizeof(value)); }
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342

◆ writeTaggedQFixed()

void QPAGenerator::writeTaggedQFixed ( QFontEngineQPA::HeaderTag  tag,
QFixed  value 
)

Definition at line 650 of file qfontengine_qpa.cpp.

651 {
652  writeUInt16(tag);
653  writeUInt16(sizeof(quint32));
654  writeUInt32(value.value());
655 }
int value() const
Definition: qfixed_p.h:73
void writeUInt16(quint16 value)
unsigned int quint32
Definition: qglobal.h:938
void writeUInt32(quint32 value)

◆ writeTaggedString()

void QPAGenerator::writeTaggedString ( QFontEngineQPA::HeaderTag  tag,
const QByteArray string 
)

Definition at line 629 of file qfontengine_qpa.cpp.

630 {
631  writeUInt16(tag);
632  writeUInt16(string.length());
633  dev->write(string);
634 }
void writeUInt16(quint16 value)
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342

◆ writeTaggedUInt32()

void QPAGenerator::writeTaggedUInt32 ( QFontEngineQPA::HeaderTag  tag,
quint32  value 
)

Definition at line 636 of file qfontengine_qpa.cpp.

637 {
638  writeUInt16(tag);
639  writeUInt16(sizeof(value));
640  writeUInt32(value);
641 }
void writeUInt16(quint16 value)
void writeUInt32(quint32 value)

◆ writeTaggedUInt8()

void QPAGenerator::writeTaggedUInt8 ( QFontEngineQPA::HeaderTag  tag,
quint8  value 
)

Definition at line 643 of file qfontengine_qpa.cpp.

644 {
645  writeUInt16(tag);
646  writeUInt16(sizeof(value));
647  writeUInt8(value);
648 }
void writeUInt8(quint8 value)
void writeUInt16(quint16 value)

◆ writeUInt16()

void QPAGenerator::writeUInt16 ( quint16  value)
inline

Definition at line 235 of file qfontengine_qpa_p.h.

235 { value = qToBigEndian(value); dev->write((const char *)&value, sizeof(value)); }
T qToBigEndian(T source)
Definition: qendian.h:337
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342

◆ writeUInt32()

void QPAGenerator::writeUInt32 ( quint32  value)
inline

Definition at line 236 of file qfontengine_qpa_p.h.

236 { value = qToBigEndian(value); dev->write((const char *)&value, sizeof(value)); }
T qToBigEndian(T source)
Definition: qendian.h:337
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342

◆ writeUInt8()

void QPAGenerator::writeUInt8 ( quint8  value)
inline

Definition at line 237 of file qfontengine_qpa_p.h.

237 { dev->write((const char *)&value, sizeof(value)); }
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342

Properties

◆ dev

QBuffer* QPAGenerator::dev

Definition at line 242 of file qfontengine_qpa_p.h.

◆ fe

QFontEngine* QPAGenerator::fe

Definition at line 243 of file qfontengine_qpa_p.h.


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