sl@0
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#if !defined(__FONTCOMP_H__)
|
sl@0
|
17 |
#define __FONTCOMP_H__
|
sl@0
|
18 |
#include <stdlib.h>
|
sl@0
|
19 |
#include <string.h>
|
sl@0
|
20 |
#include <io.h>
|
sl@0
|
21 |
|
sl@0
|
22 |
#ifdef __MSVCDOTNET__
|
sl@0
|
23 |
#include <fstream>
|
sl@0
|
24 |
#include <iostream>
|
sl@0
|
25 |
using namespace std;
|
sl@0
|
26 |
#else //!__MSVCDOTNET__
|
sl@0
|
27 |
#include <fstream.h>
|
sl@0
|
28 |
#endif //__MSVCDOTNET__
|
sl@0
|
29 |
|
sl@0
|
30 |
/**
|
sl@0
|
31 |
@internalComponent
|
sl@0
|
32 |
*/
|
sl@0
|
33 |
#define MAX_CHARS 256
|
sl@0
|
34 |
#define FONT_NAME_LEN 16
|
sl@0
|
35 |
/**
|
sl@0
|
36 |
@internalComponent
|
sl@0
|
37 |
*/
|
sl@0
|
38 |
#define MAX_CHAR_WID 256
|
sl@0
|
39 |
#define MAX_HEIGHT 256
|
sl@0
|
40 |
#define MAX_LABEL_LENGTH 16 /* Max font label name */
|
sl@0
|
41 |
#define MAX_LEN_IN 255 /* Max input line length */
|
sl@0
|
42 |
#define MAXLINE 600 /* Max line length for writing to screen */
|
sl@0
|
43 |
#define FONT_MAX_HEADER_LEN 128
|
sl@0
|
44 |
#define P_FNAMESIZE 128 /* Maximum file name size */
|
sl@0
|
45 |
/**
|
sl@0
|
46 |
@internalComponent
|
sl@0
|
47 |
*/
|
sl@0
|
48 |
enum Errors
|
sl@0
|
49 |
{
|
sl@0
|
50 |
NoError=0,
|
sl@0
|
51 |
NoMemory=-1,
|
sl@0
|
52 |
NoFile=-2,
|
sl@0
|
53 |
FileRead=-3,
|
sl@0
|
54 |
FileWrite=-4,
|
sl@0
|
55 |
FileFormat=-5,
|
sl@0
|
56 |
Parameter=-6
|
sl@0
|
57 |
};
|
sl@0
|
58 |
/**
|
sl@0
|
59 |
@internalComponent
|
sl@0
|
60 |
*/
|
sl@0
|
61 |
struct FcmCharHead
|
sl@0
|
62 |
{
|
sl@0
|
63 |
int xOffset;
|
sl@0
|
64 |
int yOffset;
|
sl@0
|
65 |
int width;
|
sl@0
|
66 |
int height;
|
sl@0
|
67 |
int move;
|
sl@0
|
68 |
int ByteWid;
|
sl@0
|
69 |
int offset;
|
sl@0
|
70 |
};
|
sl@0
|
71 |
/**
|
sl@0
|
72 |
@internalComponent
|
sl@0
|
73 |
*/
|
sl@0
|
74 |
struct LetterTableData
|
sl@0
|
75 |
{
|
sl@0
|
76 |
short int offset;
|
sl@0
|
77 |
short int width; /* x16 in version 1*/
|
sl@0
|
78 |
};
|
sl@0
|
79 |
/**
|
sl@0
|
80 |
@internalComponent
|
sl@0
|
81 |
*/
|
sl@0
|
82 |
struct LetterData
|
sl@0
|
83 |
{
|
sl@0
|
84 |
char blx;
|
sl@0
|
85 |
char bly;
|
sl@0
|
86 |
unsigned char rWid; /* Enclosing rectangle width */
|
sl@0
|
87 |
unsigned char rHgt; /* Enclosing rectangle height */
|
sl@0
|
88 |
};
|
sl@0
|
89 |
/**
|
sl@0
|
90 |
@internalComponent
|
sl@0
|
91 |
*/
|
sl@0
|
92 |
struct EffVariousData
|
sl@0
|
93 |
{
|
sl@0
|
94 |
short int version;
|
sl@0
|
95 |
short int blx;
|
sl@0
|
96 |
short int bly;
|
sl@0
|
97 |
short int Wid;
|
sl@0
|
98 |
short int Hgt;
|
sl@0
|
99 |
short int xSize; /* 16 x Point size */
|
sl@0
|
100 |
short int xRes; /* DPI */
|
sl@0
|
101 |
short int ySize;
|
sl@0
|
102 |
short int yRes;
|
sl@0
|
103 |
unsigned char XHeight;
|
sl@0
|
104 |
unsigned char CapHeight;
|
sl@0
|
105 |
unsigned char Ascender;
|
sl@0
|
106 |
char Descender;
|
sl@0
|
107 |
unsigned char LineSpacing;
|
sl@0
|
108 |
char UnderLinePos;
|
sl@0
|
109 |
unsigned char UnderLineThickness;
|
sl@0
|
110 |
unsigned char filler[7];
|
sl@0
|
111 |
};
|
sl@0
|
112 |
/**
|
sl@0
|
113 |
@internalComponent
|
sl@0
|
114 |
*/
|
sl@0
|
115 |
const int EMaxFontNameLength=256;
|
sl@0
|
116 |
|
sl@0
|
117 |
class Fxf
|
sl@0
|
118 |
/**
|
sl@0
|
119 |
@internalComponent
|
sl@0
|
120 |
*/
|
sl@0
|
121 |
{
|
sl@0
|
122 |
public:
|
sl@0
|
123 |
FcmCharHead *chr[MAX_CHARS];
|
sl@0
|
124 |
char name[EMaxFontNameLength]; /* Font name */
|
sl@0
|
125 |
char typeface[EMaxFontNameLength]; /* Font typeface */
|
sl@0
|
126 |
int MaxChrWidth;
|
sl@0
|
127 |
int cell_height; /* Height of character set */
|
sl@0
|
128 |
int nominal_ascent; /* Max ascent of normal (ASCII) characters */
|
sl@0
|
129 |
int descent; /* Descent of characters below base line */
|
sl@0
|
130 |
int chr_seg;
|
sl@0
|
131 |
int FirstChr;
|
sl@0
|
132 |
int n_chars; /* counts total number of characters defined */
|
sl@0
|
133 |
unsigned int max_info_width; /* Max char width to put in info file */
|
sl@0
|
134 |
unsigned short int flags;
|
sl@0
|
135 |
unsigned short int special;
|
sl@0
|
136 |
unsigned int ByteWid;
|
sl@0
|
137 |
int UseWords;
|
sl@0
|
138 |
int UlinePos;
|
sl@0
|
139 |
int UlineThickness;
|
sl@0
|
140 |
int iBold;
|
sl@0
|
141 |
int iItalic;
|
sl@0
|
142 |
int iProportional;
|
sl@0
|
143 |
int iSerif;
|
sl@0
|
144 |
int iSymbol;
|
sl@0
|
145 |
unsigned int iUid;
|
sl@0
|
146 |
};
|
sl@0
|
147 |
/**
|
sl@0
|
148 |
@internalComponent
|
sl@0
|
149 |
*/
|
sl@0
|
150 |
enum FontType
|
sl@0
|
151 |
{
|
sl@0
|
152 |
EFontTypeFsc,
|
sl@0
|
153 |
EFontTypeEff
|
sl@0
|
154 |
};
|
sl@0
|
155 |
|
sl@0
|
156 |
class FontCompiler
|
sl@0
|
157 |
/**
|
sl@0
|
158 |
@internalComponent
|
sl@0
|
159 |
*/
|
sl@0
|
160 |
{
|
sl@0
|
161 |
public:
|
sl@0
|
162 |
FontCompiler();
|
sl@0
|
163 |
int Read(FontType aInputType);
|
sl@0
|
164 |
int Init(char*,char*,char*);
|
sl@0
|
165 |
void RemoveBlankSpace();
|
sl@0
|
166 |
char* FontStore() const;
|
sl@0
|
167 |
virtual int WriteFont()=0;
|
sl@0
|
168 |
protected: // general information
|
sl@0
|
169 |
fstream iInputFile;
|
sl@0
|
170 |
fstream iOutputFile;
|
sl@0
|
171 |
Fxf* iFxf;
|
sl@0
|
172 |
protected: // font information
|
sl@0
|
173 |
char* iFontSpace;
|
sl@0
|
174 |
char* iWorkSpace; // misc. stuff
|
sl@0
|
175 |
short int* iMapSpace;
|
sl@0
|
176 |
int iWorkSpaceSize;
|
sl@0
|
177 |
unsigned int iHeaderDataLen;
|
sl@0
|
178 |
unsigned char iHeaderData[FONT_MAX_HEADER_LEN];
|
sl@0
|
179 |
};
|
sl@0
|
180 |
|
sl@0
|
181 |
class FontRead
|
sl@0
|
182 |
/**
|
sl@0
|
183 |
@internalComponent
|
sl@0
|
184 |
*/
|
sl@0
|
185 |
{
|
sl@0
|
186 |
public:
|
sl@0
|
187 |
FontRead(fstream& aFile,FontCompiler& aFontCompiler,Fxf* aFxf);
|
sl@0
|
188 |
virtual int ReadFont()=0;
|
sl@0
|
189 |
private:
|
sl@0
|
190 |
FontRead& operator=(const FontRead&);
|
sl@0
|
191 |
protected:
|
sl@0
|
192 |
fstream& iInputFile;
|
sl@0
|
193 |
FontCompiler* iFontCompiler;
|
sl@0
|
194 |
Fxf* iFxf;
|
sl@0
|
195 |
};
|
sl@0
|
196 |
|
sl@0
|
197 |
class EffRead : public FontRead
|
sl@0
|
198 |
/**
|
sl@0
|
199 |
@internalComponent
|
sl@0
|
200 |
*/
|
sl@0
|
201 |
{
|
sl@0
|
202 |
public:
|
sl@0
|
203 |
EffRead(fstream& aFile,FontCompiler &aFontCompiler,Fxf* aFxf,short int* aMapSpace);
|
sl@0
|
204 |
virtual int ReadFont();
|
sl@0
|
205 |
private:
|
sl@0
|
206 |
EffRead& operator=(const EffRead&);
|
sl@0
|
207 |
private:
|
sl@0
|
208 |
short int* iMapSpace;
|
sl@0
|
209 |
};
|
sl@0
|
210 |
|
sl@0
|
211 |
class FscRead : public FontRead
|
sl@0
|
212 |
/**
|
sl@0
|
213 |
@internalComponent
|
sl@0
|
214 |
*/
|
sl@0
|
215 |
{
|
sl@0
|
216 |
public:
|
sl@0
|
217 |
FscRead(fstream& aFile,FontCompiler &aFontCompiler,Fxf* aFxf);
|
sl@0
|
218 |
virtual int ReadFont();
|
sl@0
|
219 |
private:
|
sl@0
|
220 |
FscRead& operator=(const FscRead&);
|
sl@0
|
221 |
private:
|
sl@0
|
222 |
int ReadLine();
|
sl@0
|
223 |
int Pass1();
|
sl@0
|
224 |
int Pass2();
|
sl@0
|
225 |
char* ScanLine(int& aLen);
|
sl@0
|
226 |
int DoCom(int aSecondPass);
|
sl@0
|
227 |
private:
|
sl@0
|
228 |
FcmCharHead *iChar;
|
sl@0
|
229 |
char iInputBuf[256];
|
sl@0
|
230 |
int iInputBufLen;
|
sl@0
|
231 |
char* iFileBuf;
|
sl@0
|
232 |
int iFileBufLen;
|
sl@0
|
233 |
int iFileBufPos;
|
sl@0
|
234 |
int iUnderHang;
|
sl@0
|
235 |
int iOverHang;
|
sl@0
|
236 |
};
|
sl@0
|
237 |
|
sl@0
|
238 |
#endif
|