1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the tools applications of the Qt Toolkit.
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
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
45 #include <private/qfontengine_qpf_p.h>
46 #include <qmetatype.h>
55 static int debugVerbosity
;
57 enum GenerationOption
{
64 inline CharacterRange() : start(0), end(0x10000) {}
69 static QString
fileNameForFont(const QFont
&f
);
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
);
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
);
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
);
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());
103 void align4() { while (qpf
.size() & 3) { addUInt8('\0'); } }
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
);
117 Q_DECLARE_METATYPE(QPF::CharacterRange
)