20 #include FT_INTERNAL_DEBUG_H
21 #include FT_INTERNAL_OBJECTS_H
22 #include FT_INTERNAL_STREAM_H
23 #include FT_TRUETYPE_TAGS_H
27 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
41 #define FT_COMPONENT trace_ttpload
71 error = face->goto_table( face,
TTAG_glyf, stream, &face->glyf_len );
75 if ( error == TT_Err_Table_Missing )
81 error = face->goto_table( face,
TTAG_loca, stream, &table_len );
84 error = TT_Err_Locations_Missing;
88 if ( face->header.Index_To_Loc_Format != 0 )
92 if ( table_len >= 0x40000L )
95 error = TT_Err_Invalid_Table;
98 face->num_locations = table_len >> shift;
104 if ( table_len >= 0x20000L )
107 error = TT_Err_Invalid_Table;
110 face->num_locations = table_len >> shift;
113 if ( face->num_locations != (
FT_ULong)face->root.num_glyphs + 1 )
115 FT_TRACE2((
"glyph count mismatch! loca: %d, maxp: %d\n",
116 face->num_locations - 1, face->root.num_glyphs ));
119 if ( face->num_locations <= (
FT_ULong)face->root.num_glyphs )
122 ( (
FT_Long)( face->root.num_glyphs ) + 1 ) << shift;
132 for ( ; entry <
limit; entry++ )
137 if ( diff > 0 && diff < dist )
141 if ( entry == limit )
144 dist = stream->size - pos;
147 if ( new_loca_len <= dist )
149 face->num_locations = face->root.num_glyphs + 1;
150 table_len = new_loca_len;
152 FT_TRACE2((
"adjusting num_locations to %d\n",
153 face->num_locations ));
184 if ( gindex < face->num_locations )
186 if ( face->header.Index_To_Loc_Format != 0 )
188 p = face->glyph_locations + gindex * 4;
189 p_limit = face->glyph_locations + face->num_locations * 4;
194 if ( p + 4 <= p_limit )
199 p = face->glyph_locations + gindex * 2;
200 p_limit = face->glyph_locations + face->num_locations * 2;
205 if ( p + 2 <= p_limit )
214 if ( pos1 > face->glyf_len )
217 " too large offset=0x%08lx found for gid=0x%04lx,"
218 " exceeding the end of glyf table (0x%08lx)\n",
219 pos1, gindex, face->glyf_len ));
224 if ( pos2 > face->glyf_len )
227 " too large offset=0x%08lx found for gid=0x%04lx,"
228 " truncate at the end of glyf table (0x%08lx)\n",
229 pos2, gindex + 1, face->glyf_len ));
230 pos2 = face->glyf_len;
242 *asize = (
FT_UInt)( pos2 - pos1 );
244 *asize = (
FT_UInt)( face->glyf_len - pos1 );
257 face->num_locations = 0;
283 #ifdef TT_USE_BYTECODE_INTERPRETER
292 error = face->goto_table( face,
TTAG_cvt, stream, &table_len );
304 face->cvt_size = table_len / 2;
317 for ( ; cur <
limit; cur++ )
324 #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT
364 #ifdef TT_USE_BYTECODE_INTERPRETER
373 error = face->goto_table( face,
TTAG_fpgm, stream, &table_len );
376 face->font_program =
NULL;
377 face->font_program_size = 0;
384 face->font_program_size = table_len;
388 FT_TRACE2((
"loaded, %12d bytes\n", face->font_program_size ));
426 #ifdef TT_USE_BYTECODE_INTERPRETER
434 error = face->goto_table( face,
TTAG_prep, stream, &table_len );
437 face->cvt_program =
NULL;
438 face->cvt_program_size = 0;
445 face->cvt_program_size = table_len;
449 FT_TRACE2((
"loaded, %12d bytes\n", face->cvt_program_size ));
496 error = face->goto_table( face,
TTAG_hdmx, stream, &table_size );
497 if ( error || table_size < 8 )
503 p = face->hdmx_table;
504 limit = p + table_size;
521 if ( record_size >= 0xFFFF0000UL )
522 record_size &= 0xFFFFU;
526 if ( version != 0 || num_records > 255 || record_size > 0x10001L )
528 error = TT_Err_Invalid_File_Format;
532 if (
FT_NEW_ARRAY( face->hdmx_record_sizes, num_records ) )
535 for ( nn = 0; nn < num_records; nn++ )
537 if ( p + record_size > limit )
540 face->hdmx_record_sizes[nn] = p[0];
544 face->hdmx_record_count = nn;
545 face->hdmx_table_size = table_size;
546 face->hdmx_record_size = record_size;
553 face->hdmx_table_size = 0;
565 FT_FREE( face->hdmx_record_sizes );
582 FT_ULong record_size = face->hdmx_record_size;
583 FT_Byte* record = face->hdmx_table + 8;
586 for ( nn = 0; nn < face->hdmx_record_count; nn++ )
587 if ( face->hdmx_record_sizes[nn] == ppem )
590 if ( gindex < record_size )
591 result = record + nn * record_size + gindex;
tt_face_load_loca(TT_Face face, FT_Stream stream)
FT_Stream_Pos(FT_Stream stream)
tt_face_get_device_metrics(TT_Face face, FT_UInt ppem, FT_UInt gindex)
tt_face_load_cvt(TT_Face face, FT_Stream stream)
#define FT_TRACE1(varformat)
tt_face_free_hdmx(TT_Face face)
tt_face_load_hdmx(TT_Face face, FT_Stream stream)
#define FT_TRACE2(varformat)
tt_face_vary_cvt(TT_Face face, FT_Stream stream)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
#define FT_NEW_ARRAY(ptr, count)
#define FT_NEXT_USHORT(buffer)
#define FT_FRAME_RELEASE(bytes)
tt_face_load_prep(TT_Face face, FT_Stream stream)
#define FT_NEXT_ULONG(buffer)
#define FT_FRAME_EXTRACT(size, bytes)
#define FT_FRAME_ENTER(size)
tt_face_load_fpgm(TT_Face face, FT_Stream stream)
tt_face_get_location(TT_Face face, FT_UInt gindex, FT_UInt *asize)
tt_face_done_loca(TT_Face face)