Werner
------------------------------------------------------------------------
Subject:
More thoughts on FON files
From:
George Williams <address@hidden>
Date:
Sat, 14 Dec 2002 12:45:56 -0800
To:
Werner LEMBERG <address@hidden>
Hi Werner,
I'm still not on devel, so could you forward this for me?
Hi David,
I have just added code to pfaedit for reading FON files and I
noticed the following things in freetype's FON reader
(src/winfonts/winfnt.c):
1) The fnt header structure differs between version 2 (0x200) and
version 3 (0x300)
In particular the last 6 fields are not present
in version 2 (that is flags and everything
after it are omitted).
2) According to microsoft's online docs, the printed docs are wrong
about the size of the final field in the version 3 structure.
Microsoft's online docs say that this field should be 16 bytes long,
while the printed docs say 4. I can't test this, not having any
version 3 files.
http://support.microsoft.com/default.aspx?scid=KB;en-us;q65123
(search down for dfReserved1)
So I propose the following patches. These have not been well tested.
As I said I have no version 3 fonts to test with.
------------------------------------------------------------------------
*** winfnt.c.old Sat Dec 14 12:32:06 2002
--- winfnt.c Sat Dec 14 12:41:56 2002
***************
*** 70,76 ****
#undef FT_STRUCTURE
#define FT_STRUCTURE WinFNT_HeaderRec
! FT_FRAME_START( 134 ),
FT_FRAME_USHORT_LE( version ),
FT_FRAME_ULONG_LE ( file_size ),
FT_FRAME_BYTES ( copyright, 60 ),
--- 70,76 ----
#undef FT_STRUCTURE
#define FT_STRUCTURE WinFNT_HeaderRec
! FT_FRAME_START( 146 ),
FT_FRAME_USHORT_LE( version ),
FT_FRAME_ULONG_LE ( file_size ),
FT_FRAME_BYTES ( copyright, 60 ),
***************
*** 106,112 ****
FT_FRAME_USHORT_LE( B_space ),
FT_FRAME_USHORT_LE( C_space ),
FT_FRAME_USHORT_LE( color_table_offset ),
! FT_FRAME_BYTES ( reserved, 4 ),
FT_FRAME_END
};
--- 106,112 ----
FT_FRAME_USHORT_LE( B_space ),
FT_FRAME_USHORT_LE( C_space ),
FT_FRAME_USHORT_LE( color_table_offset ),
! FT_FRAME_BYTES ( reserved, 16 ),
FT_FRAME_END
};
***************
*** 145,150 ****
--- 145,157 ----
goto Exit;
}
+ /* Version 2 doesn't have these fields */
+ if ( header->version == 0x200 )
+ {
+ header->flags = header->A_space = header->B_space = 0;
+ header->C_space = header->color_table_offset = 0;
+ }
+
if ( header->file_type & 1 )
{
FT_TRACE2(( "[can't handle vector FNT fonts]\n" ));
***************
*** 664,670 ****
len = new_format ? 6 : 4;
/* jump to glyph entry */
! p = font->fnt_frame + 118 + len * glyph_index;
bitmap->width = FT_NEXT_SHORT_LE( p );
--- 671,677 ----
len = new_format ? 6 : 4;
/* jump to glyph entry */
! p = font->fnt_frame + (new_format ? 146 : 118) + len * glyph_index;
bitmap->width = FT_NEXT_SHORT_LE( p );