1
/***************************************************************************/
5
/* High-level `sfnt' driver interface (specification). */
7
/* Copyright 1996-2001, 2002, 2003, 2004 by */
8
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
10
/* This file is part of the FreeType project, and may only be used, */
11
/* modified, and distributed under the terms of the FreeType project */
12
/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13
/* this file you indicate that you have read the license and */
14
/* understand and accept it fully. */
16
/***************************************************************************/
24
#include FT_INTERNAL_DRIVER_H
25
#include FT_INTERNAL_TRUETYPE_TYPES_H
31
/*************************************************************************/
34
/* TT_Init_Face_Func */
37
/* First part of the SFNT face object initialization. This will find */
38
/* the face in a SFNT file or collection, and load its format tag in */
39
/* face->format_tag. */
42
/* stream :: The input stream. */
44
/* face :: A handle to the target face object. */
46
/* face_index :: The index of the TrueType font, if we are opening a */
49
/* num_params :: The number of additional parameters. */
51
/* params :: Optional additional parameters. */
54
/* FreeType error code. 0 means success. */
57
/* The stream cursor must be at the font file's origin. */
59
/* This function recognizes fonts embedded in a `TrueType */
62
/* Once the format tag has been validated by the font driver, it */
63
/* should then call the TT_Load_Face_Func() callback to read the rest */
64
/* of the SFNT tables in the object. */
67
(*TT_Init_Face_Func)( FT_Stream stream,
71
FT_Parameter* params );
74
/*************************************************************************/
77
/* TT_Load_Face_Func */
80
/* Second part of the SFNT face object initialization. This will */
81
/* load the common SFNT tables (head, OS/2, maxp, metrics, etc.) in */
82
/* the face object. */
85
/* stream :: The input stream. */
87
/* face :: A handle to the target face object. */
89
/* face_index :: The index of the TrueType font, if we are opening a */
92
/* num_params :: The number of additional parameters. */
94
/* params :: Optional additional parameters. */
97
/* FreeType error code. 0 means success. */
100
/* This function must be called after TT_Init_Face_Func(). */
103
(*TT_Load_Face_Func)( FT_Stream stream,
107
FT_Parameter* params );
110
/*************************************************************************/
113
/* TT_Done_Face_Func */
116
/* A callback used to delete the common SFNT data from a face. */
119
/* face :: A handle to the target face object. */
122
/* This function does NOT destroy the face object. */
125
(*TT_Done_Face_Func)( TT_Face face );
128
/*************************************************************************/
131
/* TT_Load_SFNT_HeaderRec_Func */
134
/* Loads the header of a SFNT font file. Supports collections. */
137
/* face :: A handle to the target face object. */
139
/* stream :: The input stream. */
141
/* face_index :: The index of the TrueType font, if we are opening a */
145
/* sfnt :: The SFNT header. */
148
/* FreeType error code. 0 means success. */
151
/* The stream cursor must be at the font file's origin. */
153
/* This function recognizes fonts embedded in a `TrueType */
156
/* This function checks that the header is valid by looking at the */
157
/* values of `search_range', `entry_selector', and `range_shift'. */
160
(*TT_Load_SFNT_HeaderRec_Func)( TT_Face face,
166
/*************************************************************************/
169
/* TT_Load_Directory_Func */
172
/* Loads the table directory into a face object. */
175
/* face :: A handle to the target face object. */
177
/* stream :: The input stream. */
179
/* sfnt :: The SFNT header. */
182
/* FreeType error code. 0 means success. */
185
/* The stream cursor must be on the first byte after the 4-byte font */
186
/* format tag. This is the case just after a call to */
187
/* TT_Load_Format_Tag(). */
190
(*TT_Load_Directory_Func)( TT_Face face,
195
/*************************************************************************/
198
/* TT_Load_Any_Func */
201
/* Loads any font table into client memory. */
204
/* face :: The face object to look for. */
206
/* tag :: The tag of table to load. Use the value 0 if you want */
207
/* to access the whole font file, else set this parameter */
208
/* to a valid TrueType table tag that you can forge with */
209
/* the MAKE_TT_TAG macro. */
211
/* offset :: The starting offset in the table (or the file if */
214
/* length :: The address of the decision variable: */
216
/* If length == NULL: */
217
/* Loads the whole table. Returns an error if */
220
/* If *length == 0: */
221
/* Exits immediately; returning the length of the given */
222
/* table or of the font file, depending on the value of */
225
/* If *length != 0: */
226
/* Loads the next `length' bytes of table or font, */
227
/* starting at offset `offset' (in table or font too). */
230
/* buffer :: The address of target buffer. */
233
/* TrueType error code. 0 means success. */
236
(*TT_Load_Any_Func)( TT_Face face,
243
/*************************************************************************/
246
/* TT_Find_SBit_Image_Func */
249
/* Checks whether an embedded bitmap (an `sbit') exists for a given */
250
/* glyph, at a given strike. */
253
/* face :: The target face object. */
255
/* glyph_index :: The glyph index. */
257
/* strike_index :: The current strike index. */
260
/* arange :: The SBit range containing the glyph index. */
262
/* astrike :: The SBit strike containing the glyph index. */
264
/* aglyph_offset :: The offset of the glyph data in `EBDT' table. */
267
/* FreeType error code. 0 means success. Returns */
268
/* SFNT_Err_Invalid_Argument if no sbit exists for the requested */
272
(*TT_Find_SBit_Image_Func)( TT_Face face,
274
FT_ULong strike_index,
275
TT_SBit_Range *arange,
276
TT_SBit_Strike *astrike,
277
FT_ULong *aglyph_offset );
280
/*************************************************************************/
283
/* TT_Load_SBit_Metrics_Func */
286
/* Gets the big metrics for a given embedded bitmap. */
289
/* stream :: The input stream. */
291
/* range :: The SBit range containing the glyph. */
294
/* big_metrics :: A big SBit metrics structure for the glyph. */
297
/* FreeType error code. 0 means success. */
300
/* The stream cursor must be positioned at the glyph's offset within */
301
/* the `EBDT' table before the call. */
303
/* If the image format uses variable metrics, the stream cursor is */
304
/* positioned just after the metrics header in the `EBDT' table on */
308
(*TT_Load_SBit_Metrics_Func)( FT_Stream stream,
310
TT_SBit_Metrics metrics );
313
/*************************************************************************/
316
/* TT_Load_SBit_Image_Func */
319
/* Loads a given glyph sbit image from the font resource. This also */
320
/* returns its metrics. */
324
/* The target face object. */
326
/* strike_index :: */
327
/* The strike index. */
330
/* The current glyph index. */
333
/* The current load flags. */
336
/* The input stream. */
340
/* The target pixmap. */
343
/* A big sbit metrics structure for the glyph image. */
346
/* FreeType error code. 0 means success. Returns an error if no */
347
/* glyph sbit exists for the index. */
350
/* The `map.buffer' field is always freed before the glyph is loaded. */
353
(*TT_Load_SBit_Image_Func)( TT_Face face,
354
FT_ULong strike_index,
359
TT_SBit_MetricsRec *ametrics );
362
/*************************************************************************/
365
/* TT_Set_SBit_Strike_Func */
368
/* Selects an sbit strike for given horizontal and vertical ppem */
372
/* face :: The target face object. */
374
/* x_ppem :: The horizontal resolution in points per EM. */
376
/* y_ppem :: The vertical resolution in points per EM. */
379
/* astrike_index :: The index of the sbit strike. */
382
/* FreeType error code. 0 means success. Returns an error if no */
383
/* sbit strike exists for the selected ppem values. */
386
(*TT_Set_SBit_Strike_Func)( TT_Face face,
389
FT_ULong *astrike_index );
392
/*************************************************************************/
395
/* TT_Get_PS_Name_Func */
398
/* Gets the PostScript glyph name of a glyph. */
401
/* idx :: The glyph index. */
403
/* PSname :: The address of a string pointer. Will be NULL in case */
404
/* of error, otherwise it is a pointer to the glyph name. */
406
/* You must not modify the returned string! */
409
/* FreeType error code. 0 means success. */
412
(*TT_Get_PS_Name_Func)( TT_Face face,
414
FT_String** PSname );
417
/*************************************************************************/
420
/* TT_Load_Metrics_Func */
423
/* Loads the horizontal or vertical header in a face object. */
426
/* face :: A handle to the target face object. */
428
/* stream :: The input stream. */
430
/* vertical :: A boolean flag. If set, load vertical metrics. */
433
/* FreeType error code. 0 means success. */
436
(*TT_Load_Metrics_Func)( TT_Face face,
441
/*************************************************************************/
444
/* TT_Load_Table_Func */
447
/* Loads a given TrueType table. */
450
/* face :: A handle to the target face object. */
452
/* stream :: The input stream. */
455
/* FreeType error code. 0 means success. */
458
/* The function will use `face->goto_table' to seek the stream to */
459
/* the start of the table. */
462
(*TT_Load_Table_Func)( TT_Face face,
466
/*************************************************************************/
469
/* TT_Free_Table_Func */
472
/* Frees a given TrueType table. */
475
/* face :: A handle to the target face object. */
478
(*TT_Free_Table_Func)( TT_Face face );
481
/*************************************************************************/
487
/* This structure holds pointers to the functions used to load and */
488
/* free the basic tables that are required in a `sfnt' font file. */
491
/* Check the various xxx_Func() descriptions for details. */
493
typedef struct SFNT_Interface_
495
TT_Loader_GotoTableFunc goto_table;
497
TT_Init_Face_Func init_face;
498
TT_Load_Face_Func load_face;
499
TT_Done_Face_Func done_face;
500
FT_Module_Requester get_interface;
502
TT_Load_Any_Func load_any;
503
TT_Load_SFNT_HeaderRec_Func load_sfnt_header;
504
TT_Load_Directory_Func load_directory;
506
/* these functions are called by `load_face' but they can also */
507
/* be called from external modules, if there is a need to do so */
508
TT_Load_Table_Func load_header;
509
TT_Load_Metrics_Func load_metrics;
510
TT_Load_Table_Func load_charmaps;
511
TT_Load_Table_Func load_max_profile;
512
TT_Load_Table_Func load_os2;
513
TT_Load_Table_Func load_psnames;
515
TT_Load_Table_Func load_names;
516
TT_Free_Table_Func free_names;
518
/* optional tables */
519
TT_Load_Table_Func load_hdmx;
520
TT_Free_Table_Func free_hdmx;
522
TT_Load_Table_Func load_kerning;
523
TT_Load_Table_Func load_gasp;
524
TT_Load_Table_Func load_pclt;
527
TT_Load_Table_Func load_bitmap_header;
530
TT_Set_SBit_Strike_Func set_sbit_strike;
531
TT_Load_Table_Func load_sbits;
532
TT_Find_SBit_Image_Func find_sbit_image;
533
TT_Load_SBit_Metrics_Func load_sbit_metrics;
534
TT_Load_SBit_Image_Func load_sbit_image;
535
TT_Free_Table_Func free_sbits;
538
TT_Get_PS_Name_Func get_psname;
539
TT_Free_Table_Func free_psnames;
545
typedef SFNT_Interface* SFNT_Service;
550
#endif /* __SFNT_H__ */