Fontgen.cpp
9.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
// Font_Resgen.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "FontClass.h"
#include "FontgenGprot.h"
#include "FontHWCompress.h"
FontEngine Font_app;
bool g_is_compression;
bool g_is_hw_compression;
bool g_is_group_compression;
/*****************************************************************************
* FUNCTION
* IsUseFontCompression
* DESCRIPTION
*
* PARAMETERS
*
*
* RETURNS
* void
******************************************************************************/
bool IsUseFontCompression(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return g_is_compression;
}
/*****************************************************************************
* FUNCTION
* IsUseHWFontCompression
* DESCRIPTION
*
* PARAMETERS
*
*
* RETURNS
* void
******************************************************************************/
bool IsUseHWFontCompression(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return g_is_hw_compression;
}
/*****************************************************************************
* FUNCTION
* IsUseFontGroupCompression
* DESCRIPTION
*
* PARAMETERS
*
*
* RETURNS
* void
******************************************************************************/
bool IsUseFontGroupCompression(void)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
return g_is_group_compression;
}
/*****************************************************************************
* FUNCTION
* InitialFontEngine
* DESCRIPTION
*
* PARAMETERS
*
*
* RETURNS
* void
******************************************************************************/
void InitialFontEngine(char * outputPath)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
Font_app.m_outputPath = outputPath;
#ifdef __MMI_FONT_COMPRESSION__
g_is_compression = 1;
#else
g_is_compression = 0;
#endif
remove(string(Font_app.m_outputPath + "\\" + FONT_COMPRESSION_INFO_NAME).c_str());
#ifdef __MMI_BDF_SW_COMPRESSION__
bfEncInitEncoder(&g_encoder);
g_is_hw_compression = 1;
#else
g_is_hw_compression = 0;
#endif
#ifdef __MMI_FONT_GROUP_COMPRESSION__
g_is_group_compression = 1;
#else
g_is_group_compression = 0;
#endif
}
/*****************************************************************************
* FUNCTION
* InitialFontEngine
* DESCRIPTION
*
* PARAMETERS
*
*
* RETURNS
* void
******************************************************************************/
void DeinitialFontEngine()
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
remove(string(Font_app.m_outputPath + "\\" + FONT_COMPRESSION_INFO_NAME).c_str());
#ifdef __MMI_BDF_SW_COMPRESSION__
bfEncDeInitEncoder(&g_encoder);
#endif
}
/*****************************************************************************
* FUNCTION
* InitialFontEngine
* DESCRIPTION
*
* PARAMETERS
*
*
* RETURNS
* void
******************************************************************************/
bool AddFont(
char *language_name,
char *str_langid,
char *str_code,
char *pbdf_filepath,
U16 fontDataIndex,
bool is_fixed = 0,
U8 is_dwidth = 1)
{
/*----------------------------------------------------------------*/
/* Local Variables */
/*----------------------------------------------------------------*/
U16 font_size = 0;
const FontData_Info *font_info = NULL;
string str_language_name = " ";
string str_language_id = " ";
string str_language_code = " ";
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* font_size is the smallest font size. */
for(font_size = 0; font_size < MCT_MAX_FONT_TYPES; font_size++)
{
if((fontDataIndex & (1 << font_size)) != 0)
{
break;
}
}
if(language_name != NULL)
{
str_language_name = language_name;
}
if(str_langid != NULL)
{
str_language_id = str_langid;
}
if(str_code != NULL)
{
str_language_code = str_code;
}
Font_app.AddNewLanguage(&str_language_name, &str_language_id, &str_language_code);
Font_app.m_bdf_parser = new CBdfOperation(&str_language_name, font_size, is_fixed, &string(pbdf_filepath), is_dwidth);
Font_app.m_file_gen = new FontGenFile(&(Font_app.m_outputPath));
/* Should initiate this stack variable? Be careful. */
sMCTCustFontData fontdata;
ResetFontDataValue(&fontdata);
/* Check whether the font is added in font family by bdf file path */
if((font_info = Font_app.FontDataIsAdded(&string(pbdf_filepath))) == NULL)
{
if(Font_app.ParserBDFFile(&fontdata) == false)
{
return false;
}
Font_app.AddFontDataToList(&fontdata);
}
else
{
Font_app.SetFontDataInfo(&fontdata, font_info);
}
Font_app.SetLanguageWithFontData(&str_language_code, &fontdata);
/* Add this font to all selected font list */
for(font_size = 0; font_size < MCT_MAX_FONT_TYPES; font_size++)
{
if((fontDataIndex & 1 << font_size) != 0)
{
Font_app.AddNewFontData(&fontdata, font_size);
}
}
return true;
}
/*****************************************************************************
* FUNCTION
* InitialFontEngine
* DESCRIPTION
*
* PARAMETERS
*
*
* RETURNS
* void
******************************************************************************/
bool GenerateFontResFile()
{
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
Font_app.m_file_gen = new FontGenFile(&(Font_app.m_outputPath));
Font_app.GenerateHWCompressionData();
if(Font_app.GenerateFontDataFile() == false)
{
return false;
}
Font_app.GenerateFontResFile();
delete Font_app.m_file_gen;
Font_app.m_file_gen = NULL;
return true;
}
/*****************************************************************************
* FUNCTION
* InitialFontEngine
* DESCRIPTION
*
* PARAMETERS
*
*
* RETURNS
* void
******************************************************************************/
static void ResetFontDataValue(sMCTCustFontData *fontdata)
{
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/*----------------------------------------------------------------*/
/* Code Body */
/*----------------------------------------------------------------*/
/* Must */
fontdata->Language_flags = 0;
fontdata->nHWCompressionDataSize = 0;
/* Best to have */
fontdata->nSize = 0;
fontdata->is_dwidth = 0;
fontdata->m_nTotalChars = 0;
}