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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
|
/*******************************************************************
*
* ftxsbit.h
*
* embedded bitmap support API extension
*
* Copyright 1996-1999 by
* David Turner, Robert Wilhelm, and Werner Lemberg.
*
* This file is part of the FreeType project, and may only be used
* modified and distributed under the terms of the FreeType project
* license, LICENSE.TXT. By continuing to use, modify, or distribute
* this file you indicate that you have read the license and
* understand and accept it fully.
*
*
* This extension is used to load the embedded bitmaps present
* in certain TrueType files.
*
******************************************************************/
#ifndef FTXSBIT_H
#define FTXSBIT_H
#include "freetype.h"
#ifdef __cplusplus
extern "C" {
#endif
/*************************************************************/
/* */
/* <Struct> TT_SBit_Metrics */
/* */
/* <Description> */
/* A structure used to hold the big metrics of a given */
/* glyph bitmap in a TrueType or OpenType font. These */
/* are usually found in the `EBDT' table. */
/* */
/* <Fields> */
/* height :: glyph height in pixels */
/* width :: glyph width in pixels */
/* */
/* horiBearingX :: horizontal left bearing */
/* horiBearingY :: horizontal top bearing */
/* horiAdvance :: horizontal advance */
/* */
/* vertBearingX :: vertical left bearing */
/* vertBearingY :: vertical top bearing */
/* vertAdvance :: vertical advance */
/* */
typedef struct TT_SBit_Metrics_
{
TT_Byte height;
TT_Byte width;
TT_Char horiBearingX;
TT_Char horiBearingY;
TT_Byte horiAdvance;
TT_Char vertBearingX;
TT_Char vertBearingY;
TT_Byte vertAdvance;
} TT_SBit_Metrics;
/*************************************************************/
/* */
/* <Struct> TT_SBit_Small_Metrics */
/* */
/* <Description> */
/* A structure used to hold the small metrics of a given */
/* glyph bitmap in a TrueType or OpenType font. These */
/* are usually found in the `EBDT' table. */
/* */
/* <Fields> */
/* height :: glyph height in pixels */
/* width :: glyph width in pixels */
/* */
/* bearingX :: left-side bearing */
/* bearingY :: top-side bearing */
/* advance :: advance width or height */
/* */
typedef struct TT_SBit_Small_Metrics_
{
TT_Byte height;
TT_Byte width;
TT_Char bearingX;
TT_Char bearingY;
TT_Byte advance;
} TT_SBit_Small_Metrics;
/*************************************************************/
/* */
/* <Struct> TT_SBit_Line_Metrics */
/* */
/* <Description> */
/* A structure used to describe the text line metrics of */
/* a given bitmap strike, for either horizontal or */
/* vertical layout. */
/* */
/* <Fields> */
/* ascender :: ascender in pixels */
/* descender :: descender in pixels */
/* max_width :: maximum glyph width in pixels */
/* */
/* caret_slope_enumerator :: Rise of the caret slope, */
/* typically set to 1 for non-italic fonts. */
/* caret_slope_denominator :: Rise of the caret slope, */
/* typically set to 0 for non-italic fonts. */
/* caret_offset :: Offset in pixels */
/* to move the caret for proper positioning. */
/* */
/* min_origin_SB :: Minimum of horiBearingX */
/* (resp. vertBearingY) */
/* min_advance_SB :: Minimum of */
/* (hori. advance - ( horiBearingX + width )) */
/* (resp. vert. advance - ( vertBearingY + height )) */
/* max_before_BL :: Maximum of horiBearingY */
/* (resp. Maximum of vertBearingY) */
/* min_after_BL :: Minimum of ( horiBearingY - height ) */
/* (resp. vertBearingX - width ) */
/* */
typedef struct TT_SBit_Line_Metrics_
{
TT_Char ascender;
TT_Char descender;
TT_Byte max_width;
TT_Char caret_slope_numerator;
TT_Char caret_slope_denominator;
TT_Char caret_offset;
TT_Char min_origin_SB;
TT_Char min_advance_SB;
TT_Char max_before_BL;
TT_Char min_after_BL;
TT_Char pads[2];
} TT_SBit_Line_Metrics;
/*************************************************************/
/* */
/* <Struct> TT_SBit_Range */
/* */
/* <Description> */
/* A TrueType/OpenType subIndexTable as defined in the */
/* `EBLC' or `bloc' tables. */
/* */
/* <Fields> */
/* */
/* first_glyph :: first glyph index in range */
/* last_glyph :: last glyph index in range */
/* */
/* index_format :: format of index table. valid */
/* values are 1 to 5. */
/* */
/* image_format :: format of `EBDT' image data */
/* image_offset :: offset to image data in `EBDT' */
/* */
/* image_size :: for index formats 2 and 5. This is */
/* the size in bytes of each glyph bitmap */
/* glyph bitmap */
/* */
/* big_metrics :: for index formats 2 and 5. This is */
/* the big metrics for each glyph bitmap */
/* */
/* num_glyphs :: for index formats 4 and 5. This is */
/* the number of glyphs in the code */
/* array. */
/* */
/* glyph_offsets :: for index formats 1 and 3. */
/* glyph_codes :: for index formats 4 and 5. */
/* */
/* table_offset :: offset of index table in `EBLC' table */
/* -- only used during strike loading. */
/* */
typedef struct TT_SBit_Range
{
TT_UShort first_glyph;
TT_UShort last_glyph;
TT_UShort index_format;
TT_UShort image_format;
TT_ULong image_offset;
TT_ULong image_size;
TT_SBit_Metrics metrics;
TT_ULong num_glyphs;
TT_ULong* glyph_offsets;
TT_UShort* glyph_codes;
TT_ULong table_offset;
} TT_SBit_Range;
/*************************************************************/
/* */
/* <Struct> TT_SBit_Strike */
/* */
/* <Description> */
/* A structure used describe a given bitmap strike in the */
/* `EBLC' or `bloc' tables. */
/* */
/* <Fields> */
/* */
/* num_index_ranges :: number of index ranges */
/* index_ranges :: array of glyph index ranges */
/* */
/* color_ref :: unused. color reference? */
/* hori :: line metrics for horizontal layouts. */
/* vert :: line metrics for vertical layouts. */
/* */
/* start_glyph :: lowest glyph index for this strike. */
/* end_glyph :: higher glyph index for this strike. */
/* */
/* x_ppem :: horizontal pixels per EM */
/* y_ppem :: vertical pixels per EM */
/* bit_depth :: bit depth. valid values are 1, 2, 4 & 8 */
/* flags :: vertical or horizontal? */
/* */
typedef struct TT_SBit_Strike_
{
TT_Int num_ranges;
TT_SBit_Range* sbit_ranges;
TT_ULong ranges_offset;
TT_ULong color_ref;
TT_SBit_Line_Metrics hori;
TT_SBit_Line_Metrics vert;
TT_UShort start_glyph;
TT_UShort end_glyph;
TT_Byte x_ppem;
TT_Byte y_ppem;
TT_Byte bit_depth;
TT_Char flags;
} TT_SBit_Strike;
/*************************************************************/
/* */
/* <Struct> TT_SBit_Component */
/* */
/* <Description> */
/* A simple structure to describe a compound sbit element */
/* */
/* <Fields> */
/* glyph_code :: element's glyph index */
/* x_offset :: element's left bearing */
/* y_offset :: element's top bearing */
/* */
typedef struct TT_SBit_Component_
{
TT_UShort glyph_code;
TT_Char x_offset;
TT_Char y_offset;
} TT_SBit_Component;
/*************************************************************/
/* */
/* <Struct> TT_SBit_Scale */
/* */
/* <Description> */
/* A structure used describe a given bitmap scaling */
/* table, as defined for the `EBSC' table. */
/* */
/* <Fields> */
/* hori :: horizontal line metrics */
/* vert :: vertical line metrics */
/* */
/* x_ppem :: horizontal pixels per EM */
/* y_ppem :: vertical pixels per EM */
/* */
/* x_ppem_substitute :: substitution x_ppem */
/* y_ppem_substitute :: substitution y_ppem */
/* */
typedef struct TT_SBit_Scale_
{
TT_SBit_Line_Metrics hori;
TT_SBit_Line_Metrics vert;
TT_Byte x_ppem;
TT_Byte y_ppem;
TT_Byte x_ppem_substitute;
TT_Byte y_ppem_substitute;
} TT_SBit_Scale;
/*************************************************************/
/* */
/* <Struct> TT_SBit_Image */
/* */
/* <Description> */
/* A structure used to describe a given embedded bitmap */
/* image. */
/* */
/* <Fields> */
/* map :: bitmap descriptor */
/* bit_depth :: pixel bit depth */
/* metrics :: glyph metrics for the bitmap */
/* */
typedef struct TT_SBit_Image_
{
TT_Raster_Map map;
int bit_depth;
TT_Big_Glyph_Metrics metrics;
} TT_SBit_Image;
/*************************************************************/
/* */
/* <Struct> TT_EBLC */
/* */
/* <Description> */
/* A structure used to describe the `EBLC' table from */
/* a TrueType font. */
/* */
/* <Fields> */
/* version :: version number of the EBLC table */
/* */
/* num_strikes :: the number of strikes, i.e. bitmap */
/* sizes, present in this font */
/* */
/* strikes :: array of strikes */
/* */
typedef struct TT_EBLC_
{
TT_ULong version;
TT_ULong num_strikes;
TT_SBit_Strike* strikes;
} TT_EBLC;
/*************************************************************/
/* */
/* <Function> */
/* TT_Init_SBit_Extension */
/* */
/* <Description> */
/* Initializes the embedded bitmap extension for the */
/* FreeType engine. */
/* */
/* <Input> */
/* engine :: handle to current FreeType library instance */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* */
EXPORT_DEF
TT_Error TT_Init_SBit_Extension( TT_Engine engine );
/*************************************************************/
/* */
/* <Function> */
/* TT_Get_Face_Bitmaps */
/* */
/* <Description> */
/* Loads the `EBLC' table from a font file, if any. */
/* */
/* <Input> */
/* face :: handle to the source TrueType font/face */
/* */
/* <Output> */
/* eblc_table :: a descriptor for the EBLC table */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* */
/* <Note> */
/* This function returns TT_Err_Table_Missing if the */
/* font contains no embedded bitmaps. All fields in */
/* `eblc_table' will then be set to 0. */
/* */
EXPORT_DEF
TT_Error TT_Get_Face_Bitmaps( TT_Face face,
TT_EBLC* eblc_table );
/*************************************************************/
/* */
/* <Function> */
/* TT_New_SBit_Image */
/* */
/* <Description> */
/* Allocates a new embedded bitmap container. */
/* */
/* <Output> */
/* image :: sbit image */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* */
EXPORT_DEF
TT_Error TT_New_SBit_Image( TT_SBit_Image** image );
/*************************************************************/
/* */
/* <Function> */
/* TT_Done_SBit_Image */
/* */
/* <Description> */
/* Releases an embedded bitmap container. */
/* */
/* <Input> */
/* image :: sbit image */
/* */
EXPORT_DEF
void TT_Done_SBit_Image( TT_SBit_Image* image );
/*************************************************************/
/* */
/* <Function> TT_Get_SBit_Strike */
/* */
/* <Description> */
/* Loads a suitable strike (bitmap sizetable) for the */
/* given instance. This strike includes */
/* sbitLineMetrics. */
/* */
/* <Input> */
/* face :: the source face */
/* instance :: the current size instance */
/* */
/* <Output> */
/* strike :: the bitmap strike descriptor */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* */
EXPORT_DEF
TT_Error TT_Get_SBit_Strike( TT_Face face,
TT_Instance instance,
TT_SBit_Strike* strike );
/*************************************************************/
/* */
/* <Function> */
/* TT_Load_Glyph_Bitmap */
/* */
/* <Description> */
/* Loads a given glyph embedded bitmap. */
/* */
/* <Input> */
/* face :: handle to the source TrueType font/face */
/* instance :: current size/transform instance */
/* glyph_index :: index of source glyph */
/* bitmap :: target embedded bitmap descriptor */
/* */
/* <Return> */
/* Error code. 0 means success. */
/* */
/* <Note> */
/* This function returns an error if there is no */
/* embedded bitmap for the glyph at the given */
/* instance. */
/* */
EXPORT_DEF
TT_Error TT_Load_Glyph_Bitmap( TT_Face face,
TT_Instance instance,
TT_UShort glyph_index,
TT_SBit_Image* bitmap );
#ifdef __cplusplus
}
#endif
#endif /* FTXSBIT_H */
/* END */
|