1 /***************************************************************************/
5 /* High-level `sfnt' driver interface (specification). */
7 /* Copyright 1996-2001 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 typedef FT_Module_Interface
129 (*SFNT_Get_Interface_Func)( FT_Module module,
130 const char* interface );
133 /*************************************************************************/
136 /* TT_Load_SFNT_Header_Func */
139 /* Loads the header of a SFNT font file. Supports collections. */
142 /* face :: A handle to the target face object. */
144 /* stream :: The input stream. */
146 /* face_index :: The index of the TrueType font, if we are opening a */
150 /* sfnt :: The SFNT header. */
153 /* FreeType error code. 0 means success. */
156 /* The stream cursor must be at the font file's origin. */
158 /* This function recognizes fonts embedded in a `TrueType */
161 /* This function checks that the header is valid by looking at the */
162 /* values of `search_range', `entry_selector', and `range_shift'. */
165 (*TT_Load_SFNT_Header_Func)( TT_Face face,
171 /*************************************************************************/
174 /* TT_Load_Directory_Func */
177 /* Loads the table directory into a face object. */
180 /* face :: A handle to the target face object. */
182 /* stream :: The input stream. */
184 /* sfnt :: The SFNT header. */
187 /* FreeType error code. 0 means success. */
190 /* The stream cursor must be on the first byte after the 4-byte font */
191 /* format tag. This is the case just after a call to */
192 /* TT_Load_Format_Tag(). */
195 (*TT_Load_Directory_Func)( TT_Face face,
200 /*************************************************************************/
203 /* TT_Load_Any_Func */
206 /* Loads any font table into client memory. */
209 /* face :: The face object to look for. */
211 /* tag :: The tag of table to load. Use the value 0 if you want */
212 /* to access the whole font file, else set this parameter */
213 /* to a valid TrueType table tag that you can forge with */
214 /* the MAKE_TT_TAG macro. */
216 /* offset :: The starting offset in the table (or the file if */
219 /* length :: The address of the decision variable: */
221 /* If length == NULL: */
222 /* Loads the whole table. Returns an error if */
225 /* If *length == 0: */
226 /* Exits immediately; returning the length of the given */
227 /* table or of the font file, depending on the value of */
230 /* If *length != 0: */
231 /* Loads the next `length' bytes of table or font, */
232 /* starting at offset `offset' (in table or font too). */
235 /* buffer :: The address of target buffer. */
238 /* TrueType error code. 0 means success. */
241 (*TT_Load_Any_Func)( TT_Face face,
248 /*************************************************************************/
251 /* TT_Load_SBit_Image_Func */
254 /* Loads a given glyph sbit image from the font resource. This also */
255 /* returns its metrics. */
258 /* face :: The target face object. */
260 /* x_ppem :: The horizontal resolution in points per EM. */
262 /* y_ppem :: The vertical resolution in points per EM. */
264 /* glyph_index :: The current glyph index. */
266 /* stream :: The input stream. */
269 /* amap :: The target pixmap. */
271 /* ametrics :: A big sbit metrics structure for the glyph image. */
274 /* FreeType error code. 0 means success. Returns an error if no */
275 /* glyph sbit exists for the index. */
278 /* The `map.buffer' field is always freed before the glyph is loaded. */
281 (*TT_Load_SBit_Image_Func)( TT_Face face,
282 FT_ULong strike_index,
287 TT_SBit_Metrics *ametrics );
290 /*************************************************************************/
293 /* TT_Set_SBit_Strike_Func */
296 /* Selects an sbit strike for given horizontal and vertical ppem */
300 /* face :: The target face object. */
302 /* x_ppem :: The horizontal resolution in points per EM. */
304 /* y_ppem :: The vertical resolution in points per EM. */
307 /* astrike_index :: The index of the sbit strike. */
310 /* FreeType error code. 0 means success. Returns an error if no */
311 /* sbit strike exists for the selected ppem values. */
314 (*TT_Set_SBit_Strike_Func)( TT_Face face,
317 FT_ULong *astrike_index );
320 /*************************************************************************/
323 /* TT_Get_PS_Name_Func */
326 /* Gets the PostScript glyph name of a glyph. */
329 /* index :: The glyph index. */
331 /* PSname :: The address of a string pointer. Will be NULL in case */
332 /* of error, otherwise it is a pointer to the glyph name. */
334 /* You must not modify the returned string! */
337 /* FreeType error code. 0 means success. */
340 (*TT_Get_PS_Name_Func)( TT_Face face,
342 FT_String** PSname );
345 /*************************************************************************/
348 /* TT_Load_Metrics_Func */
351 /* Loads the horizontal or vertical header in a face object. */
354 /* face :: A handle to the target face object. */
356 /* stream :: The input stream. */
358 /* vertical :: A boolean flag. If set, load vertical metrics. */
361 /* FreeType error code. 0 means success. */
364 (*TT_Load_Metrics_Func)( TT_Face face,
369 /*************************************************************************/
372 /* TT_CharMap_Load_Func */
375 /* Loads a given TrueType character map into memory. */
378 /* face :: A handle to the parent face object. */
380 /* stream :: A handle to the current stream object. */
383 /* cmap :: A pointer to a cmap object. */
386 /* FreeType error code. 0 means success. */
389 /* The function assumes that the stream is already in use (i.e., */
390 /* opened). In case of error, all partially allocated tables are */
394 (*TT_CharMap_Load_Func)( TT_Face face,
399 /*************************************************************************/
402 /* TT_CharMap_Free_Func */
405 /* Destroys a character mapping table. */
408 /* face :: A handle to the parent face object. */
410 /* cmap :: A handle to a cmap object. */
413 /* FreeType error code. 0 means success. */
416 (*TT_CharMap_Free_Func)( TT_Face face,
417 TT_CMapTable* cmap );
420 /*************************************************************************/
423 /* TT_Load_Table_Func */
426 /* Loads a given TrueType table. */
429 /* face :: A handle to the target face object. */
431 /* stream :: The input stream. */
434 /* FreeType error code. 0 means success. */
437 /* The function will use `face->goto_table' to seek the stream to */
438 /* the start of the table. */
441 (*TT_Load_Table_Func)( TT_Face face,
445 /*************************************************************************/
448 /* TT_Free_Table_Func */
451 /* Frees a given TrueType table. */
454 /* face :: A handle to the target face object. */
457 (*TT_Free_Table_Func)( TT_Face face );
460 /*************************************************************************/
466 /* This structure holds pointers to the functions used to load and */
467 /* free the basic tables that are required in a `sfnt' font file. */
470 /* Check the various xxx_Func() descriptions for details. */
472 typedef struct SFNT_Interface_
474 TT_Goto_Table_Func goto_table;
476 TT_Init_Face_Func init_face;
477 TT_Load_Face_Func load_face;
478 TT_Done_Face_Func done_face;
479 SFNT_Get_Interface_Func get_interface;
481 TT_Load_Any_Func load_any;
482 TT_Load_SFNT_Header_Func load_sfnt_header;
483 TT_Load_Directory_Func load_directory;
485 /* these functions are called by `load_face' but they can also */
486 /* be called from external modules, if there is a need to do so */
487 TT_Load_Table_Func load_header;
488 TT_Load_Metrics_Func load_metrics;
489 TT_Load_Table_Func load_charmaps;
490 TT_Load_Table_Func load_max_profile;
491 TT_Load_Table_Func load_os2;
492 TT_Load_Table_Func load_psnames;
494 TT_Load_Table_Func load_names;
495 TT_Free_Table_Func free_names;
497 /* optional tables */
498 TT_Load_Table_Func load_hdmx;
499 TT_Free_Table_Func free_hdmx;
501 TT_Load_Table_Func load_kerning;
502 TT_Load_Table_Func load_gasp;
503 TT_Load_Table_Func load_pclt;
506 TT_Load_Table_Func load_bitmap_header;
509 TT_Set_SBit_Strike_Func set_sbit_strike;
510 TT_Load_Table_Func load_sbits;
511 TT_Load_SBit_Image_Func load_sbit_image;
512 TT_Free_Table_Func free_sbits;
515 TT_Get_PS_Name_Func get_psname;
516 TT_Free_Table_Func free_psnames;
519 TT_CharMap_Load_Func load_charmap;
520 TT_CharMap_Free_Func free_charmap;
527 #endif /* __SFNT_H__ */