0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the tools applications of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
15 |
**
|
|
16 |
** GNU Lesser General Public License Usage
|
|
17 |
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
18 |
** General Public License version 2.1 as published by the Free Software
|
|
19 |
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
20 |
** packaging of this file. Please review the following information to
|
|
21 |
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
22 |
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
23 |
**
|
|
24 |
** In addition, as a special exception, Nokia gives you certain additional
|
|
25 |
** rights. These rights are described in the Nokia Qt LGPL Exception
|
|
26 |
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
27 |
**
|
|
28 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
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
|