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

#include <qfontengine_qpf_p.h>

Public Functions

void align4 ()
 
void generate ()
 
 QPFGenerator (QBuffer *device, QFontEngine *engine)
 
void writeBlock (QFontEngineQPF::BlockTag tag, const QByteArray &data)
 
void writeGMap ()
 
void writeHeader ()
 
void writeInt8 (qint8 value)
 
void writeTaggedQFixed (QFontEngineQPF::HeaderTag tag, QFixed value)
 
void writeTaggedString (QFontEngineQPF::HeaderTag tag, const QByteArray &string)
 
void writeTaggedUInt32 (QFontEngineQPF::HeaderTag tag, quint32 value)
 
void writeTaggedUInt8 (QFontEngineQPF::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 256 of file qfontengine_qpf_p.h.

Constructors and Destructors

◆ QPFGenerator()

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

Definition at line 258 of file qfontengine_qpf_p.h.

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

Functions

◆ align4()

void QPFGenerator::align4 ( )
inline

Definition at line 276 of file qfontengine_qpf_p.h.

276 { 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 QPFGenerator::generate ( )

Definition at line 1059 of file qfontengine_qpf.cpp.

Referenced by QFontEngineQPF::QFontEngineQPF().

1060 {
1061  writeHeader();
1062  writeGMap();
1064 
1065  dev->seek(4); // position of header.lock
1066  writeUInt32(0);
1067 }
void writeUInt32(quint32 value)
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
bool seek(qint64 off)
Reimplemented Function
Definition: qbuffer.cpp:384
void writeBlock(QFontEngineQPF::BlockTag tag, const QByteArray &data)

◆ writeBlock()

void QPFGenerator::writeBlock ( QFontEngineQPF::BlockTag  tag,
const QByteArray data 
)

Definition at line 1141 of file qfontengine_qpf.cpp.

1142 {
1143  writeUInt16(tag);
1144  writeUInt16(0); // padding
1145  const int padSize = ((data.size() + 3) / 4) * 4 - data.size();
1146  writeUInt32(data.size() + padSize);
1147  dev->write(data);
1148  for (int i = 0; i < padSize; ++i)
1149  writeUInt8(0);
1150 }
void writeUInt32(quint32 value)
void writeUInt8(quint8 value)
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
void writeUInt16(quint16 value)

◆ writeGMap()

void QPFGenerator::writeGMap ( )

Definition at line 1125 of file qfontengine_qpf.cpp.

1126 {
1127  const quint16 glyphCount = fe->glyphCount();
1128 
1130  writeUInt16(0); // padding
1131  writeUInt32(glyphCount * 4);
1132 
1133  QByteArray &buffer = dev->buffer();
1134  const int numBytes = glyphCount * sizeof(quint32);
1135  qint64 pos = buffer.size();
1136  buffer.resize(pos + numBytes);
1137  qMemSet(buffer.data() + pos, 0xff, numBytes);
1138  dev->seek(pos + numBytes);
1139 }
void writeUInt32(quint32 value)
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
QFontEngine * fe
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 writeUInt16(quint16 value)

◆ writeHeader()

void QPFGenerator::writeHeader ( )

Definition at line 1069 of file qfontengine_qpf.cpp.

1070 {
1071  QFontEngineQPF::Header header;
1072 
1073  header.magic[0] = 'Q';
1074  header.magic[1] = 'P';
1075  header.magic[2] = 'F';
1076  header.magic[3] = '2';
1077  header.lock = 1;
1080  header.dataSize = 0;
1081  dev->write((const char *)&header, sizeof(header));
1082 
1084 
1085  QFontEngine::FaceId face = fe->faceId();
1088 
1089  {
1090  uchar data[4];
1091  uint len = 4;
1092  bool ok = fe->getSfntTableData(MAKE_TAG('h', 'e', 'a', 'd'), data, &len);
1093  if (ok) {
1094  const quint32 revision = qFromBigEndian<quint32>(data);
1096  }
1097  }
1098 
1112 
1114 
1116  align4();
1117 
1118  const quint64 size = dev->pos();
1119  header.dataSize = qToBigEndian<quint16>(size - sizeof(header));
1120  dev->seek(0);
1121  dev->write((const char *)&header, sizeof(header));
1122  dev->seek(size);
1123 }
virtual QFixed lineThickness() const
virtual qreal minRightBearing() const
virtual QFixed averageCharWidth() const
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
QFontEngine * fe
bool seek(qint64 off)
Reimplemented Function
Definition: qbuffer.cpp:384
void writeTaggedUInt32(QFontEngineQPF::HeaderTag tag, quint32 value)
#define MAKE_TAG(ch1, ch2, ch3, ch4)
virtual qreal maxCharWidth() const =0
unsigned char uchar
Definition: qglobal.h:994
void writeTaggedString(QFontEngineQPF::HeaderTag tag, const QByteArray &string)
void writeTaggedQFixed(QFontEngineQPF::HeaderTag tag, QFixed value)
unsigned __int64 quint64
Definition: qglobal.h:943
virtual QFixed ascent() const =0
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
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
void writeTaggedUInt8(QFontEngineQPF::HeaderTag tag, quint8 value)
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

◆ writeInt8()

void QPFGenerator::writeInt8 ( qint8  value)
inline

Definition at line 274 of file qfontengine_qpf_p.h.

274 { 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 QPFGenerator::writeTaggedQFixed ( QFontEngineQPF::HeaderTag  tag,
QFixed  value 
)

Definition at line 1173 of file qfontengine_qpf.cpp.

1174 {
1175  writeUInt16(tag);
1176  writeUInt16(sizeof(quint32));
1177  writeUInt32(value.value());
1178 }
void writeUInt32(quint32 value)
int value() const
Definition: qfixed_p.h:73
unsigned int quint32
Definition: qglobal.h:938
void writeUInt16(quint16 value)

◆ writeTaggedString()

void QPFGenerator::writeTaggedString ( QFontEngineQPF::HeaderTag  tag,
const QByteArray string 
)

Definition at line 1152 of file qfontengine_qpf.cpp.

1153 {
1154  writeUInt16(tag);
1155  writeUInt16(string.length());
1156  dev->write(string);
1157 }
qint64 write(const char *data, qint64 len)
Writes at most maxSize bytes of data from data to the device.
Definition: qiodevice.cpp:1342
void writeUInt16(quint16 value)

◆ writeTaggedUInt32()

void QPFGenerator::writeTaggedUInt32 ( QFontEngineQPF::HeaderTag  tag,
quint32  value 
)

Definition at line 1159 of file qfontengine_qpf.cpp.

1160 {
1161  writeUInt16(tag);
1162  writeUInt16(sizeof(value));
1163  writeUInt32(value);
1164 }
void writeUInt32(quint32 value)
void writeUInt16(quint16 value)

◆ writeTaggedUInt8()

void QPFGenerator::writeTaggedUInt8 ( QFontEngineQPF::HeaderTag  tag,
quint8  value 
)

Definition at line 1166 of file qfontengine_qpf.cpp.

1167 {
1168  writeUInt16(tag);
1169  writeUInt16(sizeof(value));
1170  writeUInt8(value);
1171 }
void writeUInt8(quint8 value)
void writeUInt16(quint16 value)

◆ writeUInt16()

void QPFGenerator::writeUInt16 ( quint16  value)
inline

Definition at line 271 of file qfontengine_qpf_p.h.

271 { 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 QPFGenerator::writeUInt32 ( quint32  value)
inline

Definition at line 272 of file qfontengine_qpf_p.h.

272 { 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 QPFGenerator::writeUInt8 ( quint8  value)
inline

Definition at line 273 of file qfontengine_qpf_p.h.

273 { 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* QPFGenerator::dev

Definition at line 278 of file qfontengine_qpf_p.h.

◆ fe

QFontEngine* QPFGenerator::fe

Definition at line 279 of file qfontengine_qpf_p.h.


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