1 /***************************************************************************/
5 /* High-level `sfnt' driver interface (specification). */
7 /* Copyright 1996-2006, 2009, 2012-2013 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 finds */
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 loads */
81 /* the common SFNT tables (head, OS/2, maxp, metrics, etc.) in the */
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_Any_Func */
134 /* Load any font table into client memory. */
137 /* face :: The face object to look for. */
139 /* tag :: The tag of table to load. Use the value 0 if you want */
140 /* to access the whole font file, else set this parameter */
141 /* to a valid TrueType table tag that you can forge with */
142 /* the MAKE_TT_TAG macro. */
144 /* offset :: The starting offset in the table (or the file if */
147 /* length :: The address of the decision variable: */
149 /* If length == NULL: */
150 /* Loads the whole table. Returns an error if */
153 /* If *length == 0: */
154 /* Exits immediately; returning the length of the given */
155 /* table or of the font file, depending on the value of */
158 /* If *length != 0: */
159 /* Loads the next `length' bytes of table or font, */
160 /* starting at offset `offset' (in table or font too). */
163 /* buffer :: The address of target buffer. */
166 /* TrueType error code. 0 means success. */
169 (*TT_Load_Any_Func
)( TT_Face face
,
176 /*************************************************************************/
179 /* TT_Find_SBit_Image_Func */
182 /* Check whether an embedded bitmap (an `sbit') exists for a given */
183 /* glyph, at a given strike. */
186 /* face :: The target face object. */
188 /* glyph_index :: The glyph index. */
190 /* strike_index :: The current strike index. */
193 /* arange :: The SBit range containing the glyph index. */
195 /* astrike :: The SBit strike containing the glyph index. */
197 /* aglyph_offset :: The offset of the glyph data in `EBDT' table. */
200 /* FreeType error code. 0 means success. Returns */
201 /* SFNT_Err_Invalid_Argument if no sbit exists for the requested */
205 (*TT_Find_SBit_Image_Func
)( TT_Face face
,
207 FT_ULong strike_index
,
208 TT_SBit_Range
*arange
,
209 TT_SBit_Strike
*astrike
,
210 FT_ULong
*aglyph_offset
);
213 /*************************************************************************/
216 /* TT_Load_SBit_Metrics_Func */
219 /* Get the big metrics for a given embedded bitmap. */
222 /* stream :: The input stream. */
224 /* range :: The SBit range containing the glyph. */
227 /* big_metrics :: A big SBit metrics structure for the glyph. */
230 /* FreeType error code. 0 means success. */
233 /* The stream cursor must be positioned at the glyph's offset within */
234 /* the `EBDT' table before the call. */
236 /* If the image format uses variable metrics, the stream cursor is */
237 /* positioned just after the metrics header in the `EBDT' table on */
241 (*TT_Load_SBit_Metrics_Func
)( FT_Stream stream
,
243 TT_SBit_Metrics metrics
);
246 /*************************************************************************/
249 /* TT_Load_SBit_Image_Func */
252 /* Load a given glyph sbit image from the font resource. This also */
253 /* returns its metrics. */
257 /* The target face object. */
259 /* strike_index :: */
260 /* The strike index. */
263 /* The current glyph index. */
266 /* The current load flags. */
269 /* The input stream. */
273 /* The target pixmap. */
276 /* A big sbit metrics structure for the glyph image. */
279 /* FreeType error code. 0 means success. Returns an error if no */
280 /* glyph sbit exists for the index. */
283 /* The `map.buffer' field is always freed before the glyph is loaded. */
286 (*TT_Load_SBit_Image_Func
)( TT_Face face
,
287 FT_ULong strike_index
,
292 TT_SBit_MetricsRec
*ametrics
);
295 /*************************************************************************/
298 /* TT_Set_SBit_Strike_Func */
301 /* Select an sbit strike for a given size request. */
304 /* face :: The target face object. */
306 /* req :: The size request. */
309 /* astrike_index :: The index of the sbit strike. */
312 /* FreeType error code. 0 means success. Returns an error if no */
313 /* sbit strike exists for the selected ppem values. */
316 (*TT_Set_SBit_Strike_Func
)( TT_Face face
,
318 FT_ULong
* astrike_index
);
321 /*************************************************************************/
324 /* TT_Load_Strike_Metrics_Func */
327 /* Load the metrics of a given strike. */
330 /* face :: The target face object. */
332 /* strike_index :: The strike index. */
335 /* metrics :: the metrics of the strike. */
338 /* FreeType error code. 0 means success. Returns an error if no */
339 /* such sbit strike exists. */
342 (*TT_Load_Strike_Metrics_Func
)( TT_Face face
,
343 FT_ULong strike_index
,
344 FT_Size_Metrics
* metrics
);
347 /*************************************************************************/
350 /* TT_Get_PS_Name_Func */
353 /* Get the PostScript glyph name of a glyph. */
356 /* idx :: The glyph index. */
358 /* PSname :: The address of a string pointer. Will be NULL in case */
359 /* of error, otherwise it is a pointer to the glyph name. */
361 /* You must not modify the returned string! */
364 /* FreeType error code. 0 means success. */
367 (*TT_Get_PS_Name_Func
)( TT_Face face
,
369 FT_String
** PSname
);
372 /*************************************************************************/
375 /* TT_Load_Metrics_Func */
378 /* Load a metrics table, which is a table with a horizontal and a */
379 /* vertical version. */
382 /* face :: A handle to the target face object. */
384 /* stream :: The input stream. */
386 /* vertical :: A boolean flag. If set, load the vertical one. */
389 /* FreeType error code. 0 means success. */
392 (*TT_Load_Metrics_Func
)( TT_Face face
,
397 /*************************************************************************/
400 /* TT_Get_Metrics_Func */
403 /* Load the horizontal or vertical header in a face object. */
406 /* face :: A handle to the target face object. */
408 /* stream :: The input stream. */
410 /* vertical :: A boolean flag. If set, load vertical metrics. */
413 /* FreeType error code. 0 means success. */
416 (*TT_Get_Metrics_Func
)( TT_Face face
,
420 FT_UShort
* aadvance
);
423 /*************************************************************************/
426 /* TT_Load_Table_Func */
429 /* Load a given TrueType table. */
432 /* face :: A handle to the target face object. */
434 /* stream :: The input stream. */
437 /* FreeType error code. 0 means success. */
440 /* The function uses `face->goto_table' to seek the stream to the */
441 /* start of the table, except while loading the font directory. */
444 (*TT_Load_Table_Func
)( TT_Face face
,
448 /*************************************************************************/
451 /* TT_Free_Table_Func */
454 /* Free a given TrueType table. */
457 /* face :: A handle to the target face object. */
460 (*TT_Free_Table_Func
)( TT_Face face
);
465 * TT_Face_GetKerningFunc
468 * Return the horizontal kerning value between two glyphs.
471 * face :: A handle to the source face object.
472 * left_glyph :: The left glyph index.
473 * right_glyph :: The right glyph index.
476 * The kerning value in font units.
479 (*TT_Face_GetKerningFunc
)( TT_Face face
,
481 FT_UInt right_glyph
);
484 /*************************************************************************/
490 /* This structure holds pointers to the functions used to load and */
491 /* free the basic tables that are required in a `sfnt' font file. */
494 /* Check the various xxx_Func() descriptions for details. */
496 typedef struct SFNT_Interface_
498 TT_Loader_GotoTableFunc goto_table
;
500 TT_Init_Face_Func init_face
;
501 TT_Load_Face_Func load_face
;
502 TT_Done_Face_Func done_face
;
503 FT_Module_Requester get_interface
;
505 TT_Load_Any_Func load_any
;
507 /* these functions are called by `load_face' but they can also */
508 /* be called from external modules, if there is a need to do so */
509 TT_Load_Table_Func load_head
;
510 TT_Load_Metrics_Func load_hhea
;
511 TT_Load_Table_Func load_cmap
;
512 TT_Load_Table_Func load_maxp
;
513 TT_Load_Table_Func load_os2
;
514 TT_Load_Table_Func load_post
;
516 TT_Load_Table_Func load_name
;
517 TT_Free_Table_Func free_name
;
519 /* this field was called `load_kerning' up to version 2.1.10 */
520 TT_Load_Table_Func load_kern
;
522 TT_Load_Table_Func load_gasp
;
523 TT_Load_Table_Func load_pclt
;
525 /* see `ttload.h'; this field was called `load_bitmap_header' up to */
527 TT_Load_Table_Func load_bhed
;
529 TT_Load_SBit_Image_Func load_sbit_image
;
532 TT_Get_PS_Name_Func get_psname
;
533 TT_Free_Table_Func free_psnames
;
535 /* starting here, the structure differs from version 2.1.7 */
537 /* this field was introduced in version 2.1.8, named `get_psname' */
538 TT_Face_GetKerningFunc get_kerning
;
540 /* new elements introduced after version 2.1.10 */
542 /* load the font directory, i.e., the offset table and */
543 /* the table directory */
544 TT_Load_Table_Func load_font_dir
;
545 TT_Load_Metrics_Func load_hmtx
;
547 TT_Load_Table_Func load_eblc
;
548 TT_Free_Table_Func free_eblc
;
550 TT_Set_SBit_Strike_Func set_sbit_strike
;
551 TT_Load_Strike_Metrics_Func load_strike_metrics
;
553 TT_Get_Metrics_Func get_metrics
;
559 typedef SFNT_Interface
* SFNT_Service
;
561 #ifndef FT_CONFIG_OPTION_PIC
563 #define FT_DEFINE_SFNT_INTERFACE( \
592 load_strike_metrics_, \
594 static const SFNT_Interface class_ = \
623 load_strike_metrics_, \
627 #else /* FT_CONFIG_OPTION_PIC */
629 #define FT_INTERNAL( a, a_ ) \
632 #define FT_DEFINE_SFNT_INTERFACE( \
661 load_strike_metrics_, \
664 FT_Init_Class_ ## class_( FT_Library library, \
665 SFNT_Interface* clazz ) \
667 FT_UNUSED( library ); \
669 clazz->goto_table = goto_table_; \
670 clazz->init_face = init_face_; \
671 clazz->load_face = load_face_; \
672 clazz->done_face = done_face_; \
673 clazz->get_interface = get_interface_; \
674 clazz->load_any = load_any_; \
675 clazz->load_head = load_head_; \
676 clazz->load_hhea = load_hhea_; \
677 clazz->load_cmap = load_cmap_; \
678 clazz->load_maxp = load_maxp_; \
679 clazz->load_os2 = load_os2_; \
680 clazz->load_post = load_post_; \
681 clazz->load_name = load_name_; \
682 clazz->free_name = free_name_; \
683 clazz->load_kern = load_kern_; \
684 clazz->load_gasp = load_gasp_; \
685 clazz->load_pclt = load_pclt_; \
686 clazz->load_bhed = load_bhed_; \
687 clazz->load_sbit_image = load_sbit_image_; \
688 clazz->get_psname = get_psname_; \
689 clazz->free_psnames = free_psnames_; \
690 clazz->get_kerning = get_kerning_; \
691 clazz->load_font_dir = load_font_dir_; \
692 clazz->load_hmtx = load_hmtx_; \
693 clazz->load_eblc = load_eblc_; \
694 clazz->free_eblc = free_eblc_; \
695 clazz->set_sbit_strike = set_sbit_strike_; \
696 clazz->load_strike_metrics = load_strike_metrics_; \
697 clazz->get_metrics = get_metrics_; \
700 #endif /* FT_CONFIG_OPTION_PIC */
704 #endif /* __SFNT_H__ */