Completely revised Type 42 parser. It now handles both fonts

produced with ttftot42 (tested version 0.3.1) and
TrueTypeToType42.ps (tested version May 2001; it is necessary to
fix the broken header comment to be `%!PS-TrueTypeFont...').

* src/type42/t42objs.c (T42_GlyphSlot_Load): Change fourth
parameter to `FT_UInt'.
* src/type42/t42objs.h: Updated.

* src/type42/t42parse.h (T42_ParserRec): Change type of `in_memory'
to FT_Bool.
(T42_Loader): Change type of `num_chars' and `num_glyphs' to
FT_UInt.
Add `swap_table' element.
* src/type42/t42parse.c (T42_KEYWORD_COUNT, T1_ToFixed,
T1_ToCoordArray, T1_ToTokenArray): Removed.
(T1_ToBytes): New macro.
(t42_is_alpha, t42_hexval): Removed.
(t42_is_space): Handle `\0'.
(t42_parse_encoding): Updated to use new PostScript parser routines
from psaux.
Handle `/Encoding [ ... ]' also.
(T42_Load_Status): New enumeration.
(t42_parse_sfnts): Updated to use new PostScript parser routines
from psaux.
(t42_parse_charstrings): Updated to use new PostScript parser
routines from psaux.
Handle `/CharStrings << ... >>' also.
Don't expect that /.notdef is the first element in dictionary.  Copy
code from type1 module to handle this.
(t42_parse_dict): Updated to use new PostScript parser routines
from psaux.
Remove code for synthetic fonts (which can't occur in Type 42
fonts).
(t42_loader_done): Release `swap_table'.

* src/psaux/psobjs.c (skip_string): Increase `cur' properly.

* src/type1/t1load.c (parse_charstrings): Make test for `.notdef'
faster.
This commit is contained in:
Werner Lemberg 2003-10-16 15:48:39 +00:00
parent 15ee9b5542
commit e3f41982a2
8 changed files with 555 additions and 364 deletions

View File

@ -1,4 +1,47 @@
2003-10-15: Graham Asher <graham.asher@btinternet.com>
2003-10-16 Werner Lemberg <wl@gnu.org>
Completely revised Type 42 parser. It now handles both fonts
produced with ttftot42 (tested version 0.3.1) and
TrueTypeToType42.ps (tested version May 2001; it is necessary to
fix the broken header comment to be `%!PS-TrueTypeFont...').
* src/type42/t42objs.c (T42_GlyphSlot_Load): Change fourth
parameter to `FT_UInt'.
* src/type42/t42objs.h: Updated.
* src/type42/t42parse.h (T42_ParserRec): Change type of `in_memory'
to FT_Bool.
(T42_Loader): Change type of `num_chars' and `num_glyphs' to
FT_UInt.
Add `swap_table' element.
* src/type42/t42parse.c (T42_KEYWORD_COUNT, T1_ToFixed,
T1_ToCoordArray, T1_ToTokenArray): Removed.
(T1_ToBytes): New macro.
(t42_is_alpha, t42_hexval): Removed.
(t42_is_space): Handle `\0'.
(t42_parse_encoding): Updated to use new PostScript parser routines
from psaux.
Handle `/Encoding [ ... ]' also.
(T42_Load_Status): New enumeration.
(t42_parse_sfnts): Updated to use new PostScript parser routines
from psaux.
(t42_parse_charstrings): Updated to use new PostScript parser
routines from psaux.
Handle `/CharStrings << ... >>' also.
Don't expect that /.notdef is the first element in dictionary. Copy
code from type1 module to handle this.
(t42_parse_dict): Updated to use new PostScript parser routines
from psaux.
Remove code for synthetic fonts (which can't occur in Type 42
fonts).
(t42_loader_done): Release `swap_table'.
* src/psaux/psobjs.c (skip_string): Increase `cur' properly.
* src/type1/t1load.c (parse_charstrings): Make test for `.notdef'
faster.
2003-10-15 Graham Asher <graham.asher@btinternet.com>
* src/autohint/ahglobal.c (blue_chars), src/winfonts/winfnt.c
(fnt_cmap_class_rec, fnt_cmap_class), src/bdf/bdflib.c (empty,

View File

@ -410,9 +410,7 @@
FT_Byte* limit = parser->limit;
cur++;
while ( cur < limit )
while ( ++cur < limit )
{
int d;

View File

@ -1190,9 +1190,7 @@
/* the format is simple: */
/* `/glyphname' + binary data */
/* */
/* note that we stop when we find a `def' */
/* */
T1_Skip_Spaces( parser );
cur = parser->root.cursor;
@ -1236,8 +1234,9 @@
/* add a trailing zero to the name table */
name_table->elements[n][len] = '\0';
/* record index of /.notdef */
if ( ft_strcmp( (const char*)".notdef",
/* record index of /.notdef */
if ( *cur == '.' &&
ft_strcmp( ".notdef",
(const char*)(name_table->elements[n]) ) == 0 )
{
notdef_index = n;
@ -1274,7 +1273,7 @@
loader->num_glyphs = n;
/* if /.notdef is found but does not occupy index 0, do our magic. */
/* if /.notdef is found but does not occupy index 0, do our magic. */
if ( ft_strcmp( (const char*)".notdef",
(const char*)name_table->elements[0] ) &&
notdef_found )

View File

@ -24,10 +24,9 @@
/* 2) Incremental fonts making use of the GlyphDirectory keyword */
/* will be loaded, but the rendering will be using the TrueType */
/* tables. */
/* 3) The sfnts array is expected to be ASCII, not binary. */
/* 4) As for Type1 fonts, CDevProc is not supported. */
/* 5) The Metrics dictionary is not supported. */
/* 6) AFM metrics are not supported. */
/* 3) As for Type1 fonts, CDevProc is not supported. */
/* 4) The Metrics dictionary is not supported. */
/* 5) AFM metrics are not supported. */
/* */
/* In other words, this driver supports Type42 fonts derived from */
/* TrueType fonts in a non-CID manner, as done by usual conversion */

View File

@ -53,7 +53,8 @@
if ( error )
goto Exit;
error = t42_parse_dict( face, &loader, parser->base_dict, parser->base_len );
error = t42_parse_dict( face, &loader,
parser->base_dict, parser->base_len );
if ( type1->font_type != 42 )
{
@ -65,7 +66,8 @@
/* to the Type1 data */
type1->num_glyphs = loader.num_glyphs;
if ( !loader.charstrings.init ) {
if ( !loader.charstrings.init )
{
FT_ERROR(( "T42_Open_Face: no charstrings array in face!\n" ));
error = T42_Err_Invalid_File_Format;
}
@ -121,8 +123,10 @@
if ( ft_strcmp( (const char*)".notdef",
(const char*)glyph_name ) != 0 )
{
if ( charcode < min_char ) min_char = charcode;
if ( charcode > max_char ) max_char = charcode;
if ( charcode < min_char )
min_char = charcode;
if ( charcode > max_char )
max_char = charcode;
}
break;
}
@ -149,12 +153,12 @@
FT_Int num_params,
FT_Parameter* params )
{
FT_Error error;
FT_Error error;
FT_Service_PsNames psnames;
PSAux_Service psaux;
FT_Face root = (FT_Face)&face->root;
T1_Font type1 = &face->type1;
PS_FontInfo info = &type1->font_info;
PSAux_Service psaux;
FT_Face root = (FT_Face)&face->root;
T1_Font type1 = &face->type1;
PS_FontInfo info = &type1->font_info;
FT_UNUSED( num_params );
FT_UNUSED( params );
@ -189,7 +193,7 @@
goto Exit;
}
/* Now, load the font program into the face object */
/* Now load the font program into the face object */
/* Init the face object fields */
/* Now set up root face fields */
@ -350,7 +354,7 @@
#if 0
/* Select default charmap */
if (root->num_charmaps)
if ( root->num_charmaps )
root->charmap = root->charmaps[0];
#endif
}
@ -452,8 +456,6 @@
}
FT_LOCAL_DEF( FT_Error )
T42_Size_Init( T42_Size size )
{
@ -601,7 +603,7 @@
FT_LOCAL_DEF( FT_Error )
T42_GlyphSlot_Load( FT_GlyphSlot glyph,
FT_Size size,
FT_Int glyph_index,
FT_UInt glyph_index,
FT_Int32 load_flags )
{
FT_Error error;

View File

@ -102,7 +102,7 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
T42_GlyphSlot_Load( FT_GlyphSlot glyph,
FT_Size size,
FT_Int glyph_index,
FT_UInt glyph_index,
FT_Int32 load_flags );
FT_LOCAL( void )

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ FT_BEGIN_HEADER
FT_Byte* base_dict;
FT_Long base_len;
FT_Byte in_memory;
FT_Bool in_memory;
} T42_ParserRec, *T42_Parser;
@ -42,13 +42,14 @@ FT_BEGIN_HEADER
{
T42_ParserRec parser; /* parser used to read the stream */
FT_Int num_chars; /* number of characters in encoding */
FT_UInt num_chars; /* number of characters in encoding */
PS_TableRec encoding_table; /* PS_Table used to store the */
/* encoding character names */
FT_Int num_glyphs;
FT_UInt num_glyphs;
PS_TableRec glyph_names;
PS_TableRec charstrings;
PS_TableRec swap_table; /* For moving .notdef glyph to index 0. */
} T42_LoaderRec, *T42_Loader;