sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
* Header FNTREADR.H
|
sl@0
|
16 |
*
|
sl@0
|
17 |
*/
|
sl@0
|
18 |
|
sl@0
|
19 |
|
sl@0
|
20 |
#ifndef __FNTREADR_H__
|
sl@0
|
21 |
#define __FNTREADR_H__
|
sl@0
|
22 |
|
sl@0
|
23 |
#include "FNTRECRD.H"
|
sl@0
|
24 |
#include "LST.H"
|
sl@0
|
25 |
#include "READER.H"
|
sl@0
|
26 |
/**
|
sl@0
|
27 |
@internalComponent
|
sl@0
|
28 |
*/
|
sl@0
|
29 |
const uint16 KMaxSizeCodeSectionBitmap = 0x7FFF;
|
sl@0
|
30 |
const int KMaxBitmapWidth = 0x7f;
|
sl@0
|
31 |
const int KMaxBitmapHeight = 0x7f;
|
sl@0
|
32 |
const int KNumberOfBitsInByte = 8;
|
sl@0
|
33 |
/**
|
sl@0
|
34 |
@internalComponent
|
sl@0
|
35 |
*/
|
sl@0
|
36 |
const int KLowestPermittedCharacterEncoding = 0x0000;
|
sl@0
|
37 |
const int KHighestPermittedCharacterEncoding = 0xffff;
|
sl@0
|
38 |
/**
|
sl@0
|
39 |
@internalComponent
|
sl@0
|
40 |
*/
|
sl@0
|
41 |
const int KMaxNumberRepeatedLines = 15; // maximum number of repeated lines in font compiler
|
sl@0
|
42 |
|
sl@0
|
43 |
/**
|
sl@0
|
44 |
KFillCharacterOffset is a significant offset that is set when a character within a code section is
|
sl@0
|
45 |
not in the font. This means that for these fill characters nothing is stored within the binary
|
sl@0
|
46 |
data part of the code section
|
sl@0
|
47 |
@internalComponent
|
sl@0
|
48 |
*/
|
sl@0
|
49 |
const uint16 KFillCharacterOffset = 0x7FFF;
|
sl@0
|
50 |
|
sl@0
|
51 |
/**
|
sl@0
|
52 |
Resource identifiers
|
sl@0
|
53 |
@internalComponent
|
sl@0
|
54 |
*/
|
sl@0
|
55 |
const String IdentFontBitmap("FontBitmap");
|
sl@0
|
56 |
const String IdentSTARTFONT("STARTFONT");
|
sl@0
|
57 |
const String IdentTypeface("Typeface");
|
sl@0
|
58 |
const String IdentFontStoreFile("FontStoreFile");
|
sl@0
|
59 |
/**
|
sl@0
|
60 |
Char identifiers
|
sl@0
|
61 |
@internalComponent
|
sl@0
|
62 |
*/
|
sl@0
|
63 |
const String IdentAdjust("Adjust");
|
sl@0
|
64 |
const String IdentEndChar("EndChar");
|
sl@0
|
65 |
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
Codesection identifiers
|
sl@0
|
68 |
@internalComponent
|
sl@0
|
69 |
*/
|
sl@0
|
70 |
const String IdentEndCodeSection("EndCodeSection");
|
sl@0
|
71 |
const String IdentChar("Char");
|
sl@0
|
72 |
|
sl@0
|
73 |
/**
|
sl@0
|
74 |
Fontbitmap identifiers
|
sl@0
|
75 |
@internalComponent
|
sl@0
|
76 |
*/
|
sl@0
|
77 |
const String IdentEndFontBitmap("EndFontBitmap");
|
sl@0
|
78 |
const String IdentUid("Uid");
|
sl@0
|
79 |
const String IdentBold("Bold");
|
sl@0
|
80 |
const String IdentItalic("Italic");
|
sl@0
|
81 |
const String IdentFontBitmapProportional("Proportional");
|
sl@0
|
82 |
const String IdentCellHeight("CellHeight");
|
sl@0
|
83 |
const String IdentAscent("Ascent");
|
sl@0
|
84 |
const String IdentMaxNormalCharWidth("MaxNormalCharWidth");
|
sl@0
|
85 |
const String IdentBitmapEncoding("BitmapEncoding");
|
sl@0
|
86 |
const String IdentCodeSection("CodeSection");
|
sl@0
|
87 |
const String IdentMaxConsecutiveFillChars("MaxConsecutiveFillChars");
|
sl@0
|
88 |
|
sl@0
|
89 |
/**
|
sl@0
|
90 |
BDF CHAR identifiers
|
sl@0
|
91 |
@internalComponent
|
sl@0
|
92 |
*/
|
sl@0
|
93 |
const String IdentBDFFileHeader("STARTFONT");
|
sl@0
|
94 |
const String IdentBDFComment("COMMENT");
|
sl@0
|
95 |
const String IdentBDFContentVersion("CONTENTVERSION");
|
sl@0
|
96 |
const String IdentBDFFontBitmap("FONT");
|
sl@0
|
97 |
const String IdentBDFPointSize("SIZE");
|
sl@0
|
98 |
const String IdentBDFFontDesignBox("FONTBOUNDINGBOX");
|
sl@0
|
99 |
const String IdentBDFWritingDirection("METRICSSET");
|
sl@0
|
100 |
const String IdentBDFStartProperties("STARTPROPERTIES");
|
sl@0
|
101 |
const String IdentBDFPropertyUid("UID");
|
sl@0
|
102 |
const String IdentBDFPropertyBold("BOLD");
|
sl@0
|
103 |
const String IdentBDFPropertyItalic("ITALIC");
|
sl@0
|
104 |
const String IdentBDFPropertyFontAscent("FONTASCENT");
|
sl@0
|
105 |
const String IdentBDFPropertyFontDescent("FONTDESCENT");
|
sl@0
|
106 |
const String IdentBDFPropertyMaxNormalCharWidth("MAXNORMALCHARWIDTH");
|
sl@0
|
107 |
const String IdentBDFPropertyMaxConsecutiveFillChars("MAXCONSECUTIVEFILLCHARS");
|
sl@0
|
108 |
const String IdentBDFEndProperties("ENDPROPERTIES");
|
sl@0
|
109 |
const String IdentBDFNumChars("CHARS"); // To be used as sanity check on BDF files
|
sl@0
|
110 |
const String IdentBDFCharLabel("STARTCHAR");
|
sl@0
|
111 |
const String IdentBDFChar("ENCODING");
|
sl@0
|
112 |
const String IdentBDFCursorMove("DWIDTH");
|
sl@0
|
113 |
const String IdentBDFBitmapSizeAndDisplacement("BBX");
|
sl@0
|
114 |
const String IdentBDFStartBitmap("BITMAP");
|
sl@0
|
115 |
const String IdentBDFEndChar("ENDCHAR");
|
sl@0
|
116 |
const String IdentBDFEndFontBitmap("ENDFONT");
|
sl@0
|
117 |
|
sl@0
|
118 |
/**
|
sl@0
|
119 |
Typeface identifiers
|
sl@0
|
120 |
@internalComponent
|
sl@0
|
121 |
*/
|
sl@0
|
122 |
const String IdentEndTypeface("EndTypeface");
|
sl@0
|
123 |
const String IdentName("Name");
|
sl@0
|
124 |
const String IdentTypefaceProportional("Proportional");
|
sl@0
|
125 |
const String IdentSerif("Serif");
|
sl@0
|
126 |
const String IdentSymbol("Symbol");
|
sl@0
|
127 |
const String IdentFontBitmaps("FontBitmaps");
|
sl@0
|
128 |
const String IdentWidthFactor("WidthFactor");
|
sl@0
|
129 |
const String IdentHeightFactor("HeightFactor");
|
sl@0
|
130 |
const String IdentEndFontBitmaps("EndFontBitmaps");
|
sl@0
|
131 |
|
sl@0
|
132 |
/**
|
sl@0
|
133 |
Fontstorefile identifiers
|
sl@0
|
134 |
@internalComponent
|
sl@0
|
135 |
*/
|
sl@0
|
136 |
const String IdentEndFontStoreFile("EndFontStoreFile");
|
sl@0
|
137 |
const String IdentFilename("Filename");
|
sl@0
|
138 |
const String IdentCollectionUid("CollectionUid");
|
sl@0
|
139 |
const String IdentKPixelAspectRatio("KPixelAspectRatio");
|
sl@0
|
140 |
const String IdentTypefaces("Typefaces");
|
sl@0
|
141 |
const String IdentEndTypefaces("EndTypefaces");
|
sl@0
|
142 |
const String IdentExtraFontBitmaps("FontBitmaps");
|
sl@0
|
143 |
const String IdentEndExtraFontBitmaps("EndFontBitmaps");
|
sl@0
|
144 |
const String IdentCopyrightInfo("CopyrightInfo");
|
sl@0
|
145 |
const String IdentEndCopyrightInfo("EndCopyrightInfo");
|
sl@0
|
146 |
|
sl@0
|
147 |
class CroppedValues;
|
sl@0
|
148 |
|
sl@0
|
149 |
class FontReader : public Reader
|
sl@0
|
150 |
/**
|
sl@0
|
151 |
@internalComponent
|
sl@0
|
152 |
*/
|
sl@0
|
153 |
{
|
sl@0
|
154 |
public:
|
sl@0
|
155 |
enum TReadFileFormat
|
sl@0
|
156 |
{
|
sl@0
|
157 |
ESymbianGDFFormat,
|
sl@0
|
158 |
EBDFFormat
|
sl@0
|
159 |
};
|
sl@0
|
160 |
public:
|
sl@0
|
161 |
FontReader();
|
sl@0
|
162 |
boolean Read(const String& aFilename);
|
sl@0
|
163 |
boolean ReadBDFCharacter(int aCode);
|
sl@0
|
164 |
boolean ParseMetricsFromBDF(int aNumberCharsInFile, int aMaxConsecutiveFillChars);
|
sl@0
|
165 |
boolean ReadMetricFromBDFCharacter(CharacterMetrics* aMetric, CroppedValues* aCropped);
|
sl@0
|
166 |
boolean ReadBDFFontBitmap();
|
sl@0
|
167 |
boolean ReadTypeface();
|
sl@0
|
168 |
boolean ReadFontStoreFile();
|
sl@0
|
169 |
int Store(const String& aFilename);
|
sl@0
|
170 |
boolean CharLine(String& aCharLine);
|
sl@0
|
171 |
private:
|
sl@0
|
172 |
boolean ReadBDFChars(const int aNumberOfGlyphsInFile, const int aMaxConsecutiveFillChars);
|
sl@0
|
173 |
boolean DoMetricAnalysis(int& aHeight, int& aWidth, int& aLeftAdjust, int& aRightAdjust, int& aAscent);
|
sl@0
|
174 |
void ErrorIdentifierExpected(const String& aIdentifier);
|
sl@0
|
175 |
boolean CompareBitmapLines(int aLine1, int aLine2);
|
sl@0
|
176 |
boolean BitmapLineEmpty(int aLine);
|
sl@0
|
177 |
boolean BitmapColumnEmpty(int aColumn);
|
sl@0
|
178 |
void WriteFillCharacters(int aNumberConsecutive);
|
sl@0
|
179 |
void PrintoutCodeSection(const BitmapCodeSection* aCodeSection) const;
|
sl@0
|
180 |
private:
|
sl@0
|
181 |
FontStore iFontStore;
|
sl@0
|
182 |
FontStoreFile* iFontStoreFile;
|
sl@0
|
183 |
CharacterMetrics* iCharacterMetrics;
|
sl@0
|
184 |
BitmapCodeSection* iCodeSection;
|
sl@0
|
185 |
FontBitmap* iFontBitmap;
|
sl@0
|
186 |
FntTypeface* iTypeface;
|
sl@0
|
187 |
TReadFileFormat iReadFileFormat;
|
sl@0
|
188 |
int iBitArray[KMaxBitmapWidth][KMaxBitmapHeight];
|
sl@0
|
189 |
int iBitmapWidth;
|
sl@0
|
190 |
int iBitmapHeight;
|
sl@0
|
191 |
int iDefaultXMoveInPixels;
|
sl@0
|
192 |
int iDefaultYMoveInPixels;
|
sl@0
|
193 |
String iFileName;
|
sl@0
|
194 |
};
|
sl@0
|
195 |
|
sl@0
|
196 |
#endif
|