| 1 | /**************************************************************************** | 
|---|
| 2 | ** | 
|---|
| 3 | ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). | 
|---|
| 4 | ** Contact: Qt Software Information (qt-info@nokia.com) | 
|---|
| 5 | ** | 
|---|
| 6 | ** This file is part of the tools applications of the Qt Toolkit. | 
|---|
| 7 | ** | 
|---|
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
|---|
| 9 | ** Commercial Usage | 
|---|
| 10 | ** Licensees holding valid Qt Commercial licenses may use this file in | 
|---|
| 11 | ** accordance with the Qt Commercial License Agreement provided with the | 
|---|
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
|---|
| 13 | ** a written agreement between you and Nokia. | 
|---|
| 14 | ** | 
|---|
| 15 | ** GNU Lesser General Public License Usage | 
|---|
| 16 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
|---|
| 17 | ** General Public License version 2.1 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.LGPL included in the | 
|---|
| 19 | ** packaging of this file.  Please review the following information to | 
|---|
| 20 | ** ensure the GNU Lesser General Public License version 2.1 requirements | 
|---|
| 21 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | 
|---|
| 22 | ** | 
|---|
| 23 | ** In addition, as a special exception, Nokia gives you certain | 
|---|
| 24 | ** additional rights. These rights are described in the Nokia Qt LGPL | 
|---|
| 25 | ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this | 
|---|
| 26 | ** package. | 
|---|
| 27 | ** | 
|---|
| 28 | ** GNU General Public License Usage | 
|---|
| 29 | ** Alternatively, this file may be used under the terms of the GNU | 
|---|
| 30 | ** General Public License version 3.0 as published by the Free Software | 
|---|
| 31 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 32 | ** packaging of this file.  Please review the following information to | 
|---|
| 33 | ** ensure the GNU General Public License version 3.0 requirements will be | 
|---|
| 34 | ** met: http://www.gnu.org/copyleft/gpl.html. | 
|---|
| 35 | ** | 
|---|
| 36 | ** If you are unsure which license is appropriate for your use, please | 
|---|
| 37 | ** contact the sales department at qt-sales@nokia.com. | 
|---|
| 38 | ** $QT_END_LICENSE$ | 
|---|
| 39 | ** | 
|---|
| 40 | ****************************************************************************/ | 
|---|
| 41 |  | 
|---|
| 42 | #ifndef QPF2_H | 
|---|
| 43 | #define QPF2_H | 
|---|
| 44 |  | 
|---|
| 45 | #include <private/qfontengine_qpf_p.h> | 
|---|
| 46 | #include <qmetatype.h> | 
|---|
| 47 |  | 
|---|
| 48 | QT_BEGIN_NAMESPACE | 
|---|
| 49 |  | 
|---|
| 50 | class QFontEngine; | 
|---|
| 51 |  | 
|---|
| 52 | class QPF | 
|---|
| 53 | { | 
|---|
| 54 | public: | 
|---|
| 55 | static int debugVerbosity; | 
|---|
| 56 |  | 
|---|
| 57 | enum GenerationOption { | 
|---|
| 58 | IncludeCMap = 0x1, | 
|---|
| 59 | RenderGlyphs = 0x2 | 
|---|
| 60 | }; | 
|---|
| 61 |  | 
|---|
| 62 | struct CharacterRange | 
|---|
| 63 | { | 
|---|
| 64 | inline CharacterRange() : start(0), end(0x10000) {} | 
|---|
| 65 | uint start; | 
|---|
| 66 | uint end; | 
|---|
| 67 | }; | 
|---|
| 68 |  | 
|---|
| 69 | static QString fileNameForFont(const QFont &f); | 
|---|
| 70 |  | 
|---|
| 71 | static QByteArray generate(const QFont &font, int options, | 
|---|
| 72 | const QList<CharacterRange> &ranges, | 
|---|
| 73 | QString *originalFontFile = 0); | 
|---|
| 74 | static QByteArray generate(QFontEngine *fontEngine, int options, const QList<CharacterRange> &ranges); | 
|---|
| 75 | void addHeader(QFontEngine *fontEngine); | 
|---|
| 76 | void addCMap(QFontEngine *fontEngine); | 
|---|
| 77 | void addGlyphs(QFontEngine *fontEngine, const QList<CharacterRange> &ranges); | 
|---|
| 78 | void addBlock(QFontEngineQPF::BlockTag tag, const QByteArray &data); | 
|---|
| 79 |  | 
|---|
| 80 | void addTaggedString(QFontEngineQPF::HeaderTag tag, const QByteArray &string); | 
|---|
| 81 | void addTaggedQFixed(QFontEngineQPF::HeaderTag tag, QFixed value); | 
|---|
| 82 | void addTaggedUInt8(QFontEngineQPF::HeaderTag tag, quint8 value); | 
|---|
| 83 | void addTaggedInt8(QFontEngineQPF::HeaderTag tag, qint8 value); | 
|---|
| 84 | void addTaggedUInt16(QFontEngineQPF::HeaderTag tag, quint16 value); | 
|---|
| 85 | void addTaggedUInt32(QFontEngineQPF::HeaderTag tag, quint32 value); | 
|---|
| 86 |  | 
|---|
| 87 | static void dump(const QByteArray &qpf); | 
|---|
| 88 | const uchar *dumpHeader(const uchar *data); | 
|---|
| 89 | const uchar *dumpHeaderTag(const uchar *data); | 
|---|
| 90 | void dumpGMapBlock(const quint32 *gmap, int glyphCount); | 
|---|
| 91 | void dumpGlyphBlock(const quint32 *gmap, int glyphCount, const uchar *data, const uchar *endPtr); | 
|---|
| 92 | void dumpGlyph(const uchar *data, const QFontEngineQPF::Glyph *glyph); | 
|---|
| 93 |  | 
|---|
| 94 | void addUInt16(quint16 value) { qToBigEndian(value, addBytes(sizeof(value))); } | 
|---|
| 95 | void addUInt32(quint32 value) { qToBigEndian(value, addBytes(sizeof(value))); } | 
|---|
| 96 | void addUInt8(quint8 value) { *addBytes(sizeof(value)) = value; } | 
|---|
| 97 | void addInt8(qint8 value) { *addBytes(sizeof(value)) = quint8(value); } | 
|---|
| 98 | void addByteArray(const QByteArray &string) { | 
|---|
| 99 | uchar *data = addBytes(string.length()); | 
|---|
| 100 | qMemCopy(data, string.constData(), string.length()); | 
|---|
| 101 | } | 
|---|
| 102 |  | 
|---|
| 103 | void align4() { while (qpf.size() & 3) { addUInt8('\0'); } } | 
|---|
| 104 |  | 
|---|
| 105 | uchar *addBytes(int size) { | 
|---|
| 106 | const int oldSize = qpf.size(); | 
|---|
| 107 | qpf.resize(qpf.size() + size); | 
|---|
| 108 | return reinterpret_cast<uchar *>(qpf.data() + oldSize); | 
|---|
| 109 | } | 
|---|
| 110 |  | 
|---|
| 111 | QByteArray qpf; | 
|---|
| 112 | int options; | 
|---|
| 113 | }; | 
|---|
| 114 |  | 
|---|
| 115 | QT_END_NAMESPACE | 
|---|
| 116 |  | 
|---|
| 117 | Q_DECLARE_METATYPE(QPF::CharacterRange) | 
|---|
| 118 |  | 
|---|
| 119 | #endif // QPF2_H | 
|---|