22 #include FT_WINFONTS_H 23 #include FT_INTERNAL_DEBUG_H 24 #include FT_INTERNAL_STREAM_H 25 #include FT_INTERNAL_OBJECTS_H 26 #include FT_TRUETYPE_IDS_H 30 #include FT_SERVICE_WINFNT_H 31 #include FT_SERVICE_XFREE86_NAME_H 40 #define FT_COMPONENT trace_winfnt 46 #define FT_STRUCTURE WinMZ_HeaderRec 58 #define FT_STRUCTURE WinNE_HeaderRec 71 #define FT_STRUCTURE WinPE32_HeaderRec 91 #define FT_STRUCTURE WinPE32_SectionRec 106 #define FT_STRUCTURE WinPE_RsrcDirRec 121 #define FT_STRUCTURE WinPE_RsrcDirEntryRec 132 #define FT_STRUCTURE WinPE_RsrcDataEntryRec 145 #define FT_STRUCTURE FT_WinFNT_HeaderRec 224 if ( header->
version != 0x200 &&
227 FT_TRACE2((
" not a Windows FNT file\n" ));
228 error =
FT_THROW( Unknown_File_Format );
233 size = new_format ? 148 : 118;
237 FT_TRACE2((
" not a Windows FNT file\n" ));
238 error =
FT_THROW( Unknown_File_Format );
243 if ( header->
version == 0x200 )
255 FT_TRACE2((
"[can't handle vector FNT fonts]\n" ));
256 error =
FT_THROW( Unknown_File_Format );
271 fnt_face_get_dll_font(
FNT_Face face,
287 error =
FT_ERR( Unknown_File_Format );
300 error =
FT_ERR( Unknown_File_Format );
304 FT_ULong res_offset = mz_header.lfanew +
331 if ( type_id == 0x8008U )
339 stream->
cursor += 4 + count * 12;
344 if ( !font_count || !font_offset )
346 FT_TRACE2((
"this file doesn't contain any FNT resources\n" ));
347 error =
FT_THROW( Invalid_File_Format );
353 if ( font_count * 118UL > stream->
size )
355 FT_TRACE2((
"invalid number of faces\n" ));
356 error =
FT_THROW( Invalid_File_Format );
362 if ( face_index >= font_count )
364 error =
FT_THROW( Invalid_Argument );
367 else if ( face_index < 0 )
384 error = fnt_font_load( face->
font, stream );
394 FT_Long root_dir_offset, name_dir_offset, lang_dir_offset;
404 FT_TRACE2((
"magic %04lx, machine %02x, number_of_sections %u, " 405 "size_of_optional_header %02x\n" 406 "magic32 %02x, rsrc_virtual_address %04lx, " 415 pe32_header.
machine != 0x014c ||
419 FT_TRACE2((
"this file has an invalid PE header\n" ));
420 error =
FT_THROW( Invalid_File_Format );
432 FT_TRACE2((
"name %.8s, va %04lx, size %04lx, offset %04lx\n",
439 goto Found_rsrc_section;
442 FT_TRACE2((
"this file doesn't contain any resources\n" ));
443 error =
FT_THROW( Invalid_File_Format );
447 FT_TRACE2((
"found resources section %.8s\n", pe32_section.
name ));
463 if ( !(dir_entry1.
offset & 0x80000000UL ) )
465 error =
FT_THROW( Invalid_File_Format );
469 dir_entry1.
offset &= ~0x80000000UL;
487 if ( !(dir_entry2.
offset & 0x80000000UL ) )
489 error =
FT_THROW( Invalid_File_Format );
493 dir_entry2.
offset &= ~0x80000000UL;
511 if ( dir_entry2.
offset & 0x80000000UL )
513 error =
FT_THROW( Invalid_File_Format );
517 if ( dir_entry1.
name == 8 )
524 FT_TRACE2((
"found font #%lu, offset %04lx, " 525 "size %04lx, cp %lu\n",
542 error = fnt_font_load( face->
font, stream );
546 dir_entry2.
name, error ));
550 FT_TRACE2((
"font #%lu successfully loaded\n",
563 FT_TRACE2((
"this file doesn't contain any RT_FONT resources\n" ));
564 error =
FT_THROW( Invalid_File_Format );
570 error =
FT_THROW( Invalid_Argument );
577 fnt_font_done( face );
584 typedef struct FNT_CMapRec_
614 char_code -= cmap->first;
615 if ( char_code < cmap->
count )
618 gindex = (
FT_UInt)( char_code + 1 );
632 if ( char_code <= cmap->
first )
634 result = cmap->first;
639 char_code -= cmap->first;
640 if ( char_code < cmap->
count )
642 result = cmap->first + char_code;
643 gindex = (
FT_UInt)( char_code + 1 );
664 static FT_CMap_Class const fnt_cmap_class = &fnt_cmap_class_rec;
668 FNT_Face_Done(
FT_Face fntface )
679 fnt_font_done( face );
704 error = fnt_face_get_dll_font( face, face_index );
705 if ( !error && face_index < 0 )
708 if (
FT_ERR_EQ( error, Unknown_File_Format ) )
722 error = fnt_font_load( font, stream );
726 if ( face_index > 0 )
727 error =
FT_THROW( Invalid_Argument );
728 else if ( face_index < 0 )
795 FT_TRACE2((
"use pixel_height as the nominal height\n" ));
809 charmap.
encoding = FT_ENCODING_NONE;
817 charmap.
encoding = FT_ENCODING_APPLE_ROMAN;
838 FT_TRACE2((
"invalid number of glyphs\n" ));
839 error =
FT_THROW( Invalid_File_Format );
849 FT_TRACE2((
"invalid family name offset\n" ));
850 error =
FT_THROW( Invalid_File_Format );
888 FNT_Face_Done( fntface );
909 header->ascent ) * 64;
917 FNT_Size_Request(
FT_Size size,
928 height = ( height + 32 ) >> 6;
933 if ( height == ( ( bsize->y_ppem + 32 ) >> 6 ) )
938 if ( height == header->pixel_height )
950 return FNT_Size_Select( size, 0 );
974 error =
FT_THROW( Invalid_Argument );
983 error =
FT_THROW( Invalid_Argument );
987 if ( glyph_index > 0 )
993 len = new_format ? 6 : 4;
996 p = font->
fnt_frame + ( new_format ? 148 : 118 ) + len * glyph_index;
1008 error =
FT_THROW( Invalid_File_Format );
1023 bitmap->
pitch = pitch;
1029 FT_TRACE2((
"invalid bitmap width\n" ));
1030 error =
FT_THROW( Invalid_File_Format );
1041 for ( ; pitch > 0; pitch--, column++ )
1046 for ( write = column; p <
limit; p++, write += bitmap->
pitch )
1054 slot->
format = FT_GLYPH_FORMAT_BITMAP;
1060 slot->
metrics.horiBearingX = 0;
1064 bitmap->
rows << 6 );
1072 winfnt_get_header(
FT_Face face,
1084 static const FT_Service_WinFntRec winfnt_service_rec =
1144 #ifdef FT_CONFIG_OPTION_OLD_INTERNALS 1145 ft_stub_set_char_sizes,
1146 ft_stub_set_pixel_sizes,
#define FT_ALLOC(ptr, size)
GLint GLint GLsizei GLsizei height
ft_service_list_lookup(FT_ServiceDesc service_descriptors, const char *service_id)
for(n=1;n< outline->n_points;n++)
#define FT_SERVICE_ID_WINFNT
ft_synthesize_vertical_metrics(FT_Glyph_Metrics *metrics, FT_Pos advance)
int write(int fd, const char *buf, int nbytes)
FT_Select_Metrics(FT_Face face, FT_ULong strike_index)
struct FNT_CMapRec_ FNT_CMapRec
FT_UInt(* FT_CMap_CharIndexFunc)(FT_CMap cmap, FT_UInt32 char_code)
#define FT_NEXT_ULONG_LE(buffer)
#define FT_REQUEST_HEIGHT(req)
#define FT_XF86_FORMAT_WINFNT
return FT_THROW(Missing_Property)
void(* FT_CMap_DoneFunc)(FT_CMap cmap)
FT_Bitmap_Size * available_sizes
#define FT_FACE_FLAG_FIXED_SIZES
struct FT_SizeRec_ FT_SizeRec
FT_BEGIN_HEADER struct WinMZ_HeaderRec_ WinMZ_HeaderRec
#define FT_FRAME_BYTES(field, count)
#define FT_FRAME_ULONG_LE(f)
#define FT_GLYPH_OWN_BITMAP
FT_ULong size_of_raw_data
FT_BEGIN_HEADER typedef unsigned char FT_Bool
FT_UShort number_of_named_entries
GLenum GLuint GLint GLenum face
FT_UShort number_of_id_entries
#define FT_STYLE_FLAG_BOLD
#define FT_FRAME_SKIP_BYTES(count)
FT_WinFNT_HeaderRec header
#define FT_STREAM_READ_FIELDS(fields, object)
#define FT_FACE_FLAG_FIXED_WIDTH
FT_MulDiv(FT_Long a, FT_Long b, FT_Long c)
#define FT_SERVICE_ID_XF86_NAME
#define FT_FACE_FLAG_HORIZONTAL
#define FT_GET_USHORT_LE()
FT_Pointer FT_Module_Interface
#define FT_TRACE2(varformat)
struct FNT_FaceRec_ * FNT_Face
#define FT_FRAME_USHORT_LE(f)
#define FT_MODULE_FONT_DRIVER
#define FT_NEXT_USHORT_LE(buffer)
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
#define FT_NEW_ARRAY(ptr, count)
#define FT_STREAM_SEEK(position)
GLuint const GLchar * name
FT_Size_Request_Type type
#define FT_FRAME_RELEASE(bytes)
FT_CALLBACK_TABLE_DEF const FT_Driver_ClassRec winfnt_driver_class
#define TT_PLATFORM_MACINTOSH
#define FT_CALLBACK_TABLE_DEF
#define FT_FACE_MEMORY(x)
FT_CMap_New(FT_CMap_Class clazz, FT_Pointer init_data, FT_CharMap charmap, FT_CMap *acmap)
GLenum const GLfloat * params
#define FT_REALLOC(ptr, cursz, newsz)
#define FT_NEXT_SHORT_LE(buffer)
FT_Slot_Internal internal
#define FT_FRAME_EXTRACT(size, bytes)
#define FT_ALLOC_MULT(ptr, count, item_size)
GLenum GLenum GLvoid GLvoid * column
FT_UInt(* FT_CMap_CharNextFunc)(FT_CMap cmap, FT_UInt32 *achar_code)
#define TT_PLATFORM_APPLE_UNICODE
GLuint GLuint GLsizei count
#define FT_FRAME_ENTER(size)
FT_ULong pointer_to_raw_data
#define FT_MODULE_DRIVER_NO_OUTLINES
struct FNT_CMapRec_ * FNT_CMap
struct FT_DriverRec_ FT_DriverRec
#define FT_MEM_COPY(dest, source, count)
#define FT_STYLE_FLAG_ITALIC
FT_Error(* FT_CMap_InitFunc)(FT_CMap cmap, FT_Pointer init_data)
GLuint GLuint GLfloat weight
#define TT_APPLE_ID_DEFAULT
#define FT_FRAME_START(size)