]>
git.saurik.com Git - wxWidgets.git/blob - src/freetype/truetype/ttpload.c
1 /***************************************************************************/
5 /* TrueType glyph data/program tables loader (body). */
7 /* Copyright 1996-2000 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 /***************************************************************************/
19 #include <freetype/internal/ftdebug.h>
20 #include <freetype/internal/ftobjs.h>
21 #include <freetype/internal/ftstream.h>
22 #include <freetype/tttags.h>
24 #ifdef FT_FLAT_COMPILE
27 #include <truetype/ttpload.h>
30 #include <freetype/internal/tterrors.h>
33 /*************************************************************************/
35 /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
36 /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
37 /* messages during execution. */
40 #define FT_COMPONENT trace_ttpload
43 /*************************************************************************/
46 /* TT_Load_Locations */
49 /* Loads the locations table. */
52 /* face :: A handle to the target face object. */
55 /* stream :: The input stream. */
58 /* FreeType error code. 0 means success. */
61 FT_Error
TT_Load_Locations( TT_Face face
,
65 FT_Memory memory
= stream
->memory
;
70 FT_TRACE2(( "Locations " ));
71 LongOffsets
= face
->header
.Index_To_Loc_Format
;
73 error
= face
->goto_table( face
, TTAG_loca
, stream
, &table_len
);
76 error
= TT_Err_Locations_Missing
;
80 if ( LongOffsets
!= 0 )
82 face
->num_locations
= (FT_UShort
)( table_len
>> 2 );
84 FT_TRACE2(( "(32bit offsets): %12d ", face
->num_locations
));
86 if ( ALLOC_ARRAY( face
->glyph_locations
,
91 if ( ACCESS_Frame( face
->num_locations
* 4L ) )
95 FT_Long
* loc
= face
->glyph_locations
;
96 FT_Long
* limit
= loc
+ face
->num_locations
;
99 for ( ; loc
< limit
; loc
++ )
107 face
->num_locations
= (FT_UShort
)( table_len
>> 1 );
109 FT_TRACE2(( "(16bit offsets): %12d ", face
->num_locations
));
111 if ( ALLOC_ARRAY( face
->glyph_locations
,
116 if ( ACCESS_Frame( face
->num_locations
* 2L ) )
119 FT_Long
* loc
= face
->glyph_locations
;
120 FT_Long
* limit
= loc
+ face
->num_locations
;
123 for ( ; loc
< limit
; loc
++ )
124 *loc
= (FT_Long
)( (FT_ULong
)GET_UShort() * 2 );
129 FT_TRACE2(( "loaded\n" ));
136 /*************************************************************************/
142 /* Loads the control value table into a face object. */
145 /* face :: A handle to the target face object. */
148 /* stream :: A handle to the input stream. */
151 /* FreeType error code. 0 means success. */
154 FT_Error
TT_Load_CVT( TT_Face face
,
158 FT_Memory memory
= stream
->memory
;
162 FT_TRACE2(( "CVT " ));
164 error
= face
->goto_table( face
, TTAG_cvt
, stream
, &table_len
);
167 FT_TRACE2(( "is missing!\n" ));
176 face
->cvt_size
= table_len
/ 2;
178 if ( ALLOC_ARRAY( face
->cvt
,
183 if ( ACCESS_Frame( face
->cvt_size
* 2L ) )
187 FT_Short
* cur
= face
->cvt
;
188 FT_Short
* limit
= cur
+ face
->cvt_size
;
191 for ( ; cur
< limit
; cur
++ )
196 FT_TRACE2(( "loaded\n" ));
203 /*************************************************************************/
206 /* TT_Load_Progams */
209 /* Loads the font program and the cvt program. */
212 /* face :: A handle to the target face object. */
215 /* stream :: A handle to the input stream. */
218 /* FreeType error code. 0 means success. */
221 FT_Error
TT_Load_Programs( TT_Face face
,
228 FT_TRACE2(( "Font program " ));
230 /* The font program is optional */
231 error
= face
->goto_table( face
, TTAG_fpgm
, stream
, &table_len
);
234 face
->font_program
= NULL
;
235 face
->font_program_size
= 0;
237 FT_TRACE2(( "is missing!\n" ));
241 face
->font_program_size
= table_len
;
242 if ( EXTRACT_Frame( table_len
, face
->font_program
) )
245 FT_TRACE2(( "loaded, %12d bytes\n", face
->font_program_size
));
248 FT_TRACE2(( "Prep program " ));
250 error
= face
->goto_table( face
, TTAG_prep
, stream
, &table_len
);
253 face
->cvt_program
= NULL
;
254 face
->cvt_program_size
= 0;
257 FT_TRACE2(( "is missing!\n" ));
261 face
->cvt_program_size
= table_len
;
262 if ( EXTRACT_Frame( table_len
, face
->cvt_program
) )
265 FT_TRACE2(( "loaded, %12d bytes\n", face
->cvt_program_size
));