diff options
author | Werner Lemberg <wl@gnu.org> | 2003-07-25 22:09:53 +0000 |
---|---|---|
committer | Werner Lemberg <wl@gnu.org> | 2003-07-25 22:09:53 +0000 |
commit | e7df0f905d732235f821f45cc82be4415908969b (patch) | |
tree | ae799d0934f2f9cbfb3de4e1262823eb63a58371 | |
parent | 083aec66a5a19837cb56a1eaee448ee85eb750eb (diff) | |
download | freetype2-e7df0f905d732235f821f45cc82be4415908969b.tar.gz |
Make reference valid HTML 4.01 transitional.
* src/tools/docmaker/tohtml.py (html_header_1): Add doctype
and charset.
(html_header_2): Fix style elements and add some more.
Fix syntax.
(block_header, block_footer, description_header, description_footer,
marker_header, marker_footer, source_header, source_footer,
chapter_header, chapter_footer): Don't use <center>...</center> but
`align=center' table attribute.
Use double quotes around table widths given in percent.
(keyword_prefix, keyword_suffix): Don't change font colour directly
but use a new <span> class.
(section_synopsis_header, section_synopsis_footer): Don't change
colour.
(print_html_field): <tr> gets the `valign' attribute, not <table>.
(print_html_field_list): Ditto.
(index_exit): Don't use <center>...</center> but `align=center'
table attribute.
(toc_exit, section_enter): Ditto.
(block_enter): Use <h4><a>, not <a><h4>.
This change reimplements fix from 2003-05-30 without breaking
binary compatibility.
* include/freetype/t1tables.h (PS_FontInfoRec): `italic_angle',
`is_fixed_pitch', `underline_position', `underline_thickness' are
reverted to be normal values.
* include/freetype/internal/psaux.h (T1_FieldType): Remove
`T1_FIELD_TYPE_BOOL_P', `T1_FIELD_TYPE_INTEGER_P',
`T1_FIELD_TYPE_FIXED_P', `T1_FIELD_TYPE_FIXED_1000_P'.
(T1_FIELD_TYPE_BOOL_P, T1_FIELD_NUM_P, T1_FIELD_FIXED_P,
T1_FIELD_FIXED_1000_P): Removed.
(T1_FIELD_TYPE_BOOL): Renamed to...
(T1_FIELD_BOOL): New macro. Updated all callers.
* src/type42/t42parse.c: `italic_angle', `is_fixed_pitch',
`underline_position', `underline_thickness', `paint_type',
`stroke_width' are reverted to be normal values.
(T42_KEYWORD_COUNT): New macro.
(t42_parse_dict): New array `keyword_flags' to mark that a value has
already been assigned to a dictionary entry.
* src/type42/t42objs.c (T42_Face_Init, T42_Face_Done): Updated.
* src/cid/cidtoken.h: `italic_angle', `is_fixed_pitch',
`underline_position', `underline_thickness' are reverted to be
normal values.
* src/cid/cidobjs.c (cid_face_done, cid_face_init): Updated.
* src/psaux/psobjs.c (ps_parser_load_field): Updated.
* src/type1/t1tokens.h: `italic_angle', `is_fixed_pitch',
`underline_position', `underline_thickness', `paint_type',
`stroke_width' are reverted to be normal values.
* src/type1/t1objs.c (T1_Face_Done, T1_Face_Init): Updated.
* src/type1/t1load.c (T1_FIELD_COUNT): New macro.
(parse_dict): Add parameter for keyword flags.
Record only first instance of a field.
(T1_Open_Face): New array `keyword_flags'.
-rw-r--r-- | ChangeLog | 65 | ||||
-rw-r--r-- | include/freetype/freetype.h | 2 | ||||
-rw-r--r-- | include/freetype/ftbdf.h | 15 | ||||
-rw-r--r-- | include/freetype/internal/psaux.h | 18 | ||||
-rw-r--r-- | include/freetype/t1tables.h | 8 | ||||
-rw-r--r-- | src/cid/cidobjs.c | 15 | ||||
-rw-r--r-- | src/cid/cidtoken.h | 18 | ||||
-rw-r--r-- | src/psaux/psobjs.c | 93 | ||||
-rw-r--r-- | src/tools/docmaker/tohtml.py | 81 | ||||
-rw-r--r-- | src/type1/t1load.c | 43 | ||||
-rw-r--r-- | src/type1/t1objs.c | 15 | ||||
-rw-r--r-- | src/type1/t1tokens.h | 26 | ||||
-rw-r--r-- | src/type42/t42objs.c | 15 | ||||
-rw-r--r-- | src/type42/t42parse.c | 57 |
14 files changed, 233 insertions, 238 deletions
@@ -1,3 +1,68 @@ +2003-07-25 Werner Lemberg <wl@gnu.org> + + Make reference valid HTML 4.01 transitional. + + * src/tools/docmaker/tohtml.py (html_header_1): Add doctype + and charset. + (html_header_2): Fix style elements and add some more. + Fix syntax. + (block_header, block_footer, description_header, description_footer, + marker_header, marker_footer, source_header, source_footer, + chapter_header, chapter_footer): Don't use <center>...</center> but + `align=center' table attribute. + Use double quotes around table widths given in percent. + (keyword_prefix, keyword_suffix): Don't change font colour directly + but use a new <span> class. + (section_synopsis_header, section_synopsis_footer): Don't change + colour. + (print_html_field): <tr> gets the `valign' attribute, not <table>. + (print_html_field_list): Ditto. + (index_exit): Don't use <center>...</center> but `align=center' + table attribute. + (toc_exit, section_enter): Ditto. + (block_enter): Use <h4><a>, not <a><h4>. + +2003-07-25 David Turner <david@freetype.org> + + This change reimplements fix from 2003-05-30 without breaking + binary compatibility. + + * include/freetype/t1tables.h (PS_FontInfoRec): `italic_angle', + `is_fixed_pitch', `underline_position', `underline_thickness' are + reverted to be normal values. + + * include/freetype/internal/psaux.h (T1_FieldType): Remove + `T1_FIELD_TYPE_BOOL_P', `T1_FIELD_TYPE_INTEGER_P', + `T1_FIELD_TYPE_FIXED_P', `T1_FIELD_TYPE_FIXED_1000_P'. + (T1_FIELD_TYPE_BOOL_P, T1_FIELD_NUM_P, T1_FIELD_FIXED_P, + T1_FIELD_FIXED_1000_P): Removed. + (T1_FIELD_TYPE_BOOL): Renamed to... + (T1_FIELD_BOOL): New macro. Updated all callers. + + * src/type42/t42parse.c: `italic_angle', `is_fixed_pitch', + `underline_position', `underline_thickness', `paint_type', + `stroke_width' are reverted to be normal values. + (T42_KEYWORD_COUNT): New macro. + (t42_parse_dict): New array `keyword_flags' to mark that a value has + already been assigned to a dictionary entry. + * src/type42/t42objs.c (T42_Face_Init, T42_Face_Done): Updated. + + * src/cid/cidtoken.h: `italic_angle', `is_fixed_pitch', + `underline_position', `underline_thickness' are reverted to be + normal values. + * src/cid/cidobjs.c (cid_face_done, cid_face_init): Updated. + + * src/psaux/psobjs.c (ps_parser_load_field): Updated. + + * src/type1/t1tokens.h: `italic_angle', `is_fixed_pitch', + `underline_position', `underline_thickness', `paint_type', + `stroke_width' are reverted to be normal values. + * src/type1/t1objs.c (T1_Face_Done, T1_Face_Init): Updated. + * src/type1/t1load.c (T1_FIELD_COUNT): New macro. + (parse_dict): Add parameter for keyword flags. + Record only first instance of a field. + (T1_Open_Face): New array `keyword_flags'. + 2003-07-24 Werner Lemberg <wl@gnu.org> * include/freetype/freetype.h (FREETYPE_PATCH): Set to 5. diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h index 17b40132b..7f1b0b8a5 100644 --- a/include/freetype/freetype.h +++ b/include/freetype/freetype.h @@ -920,7 +920,7 @@ FT_BEGIN_HEADER /* FT_FACE_FLAG_SCALABLE :: */ /* Indicates that the face provides vectorial outlines. This */ /* doesn't prevent embedded bitmaps, i.e., a face can have both */ - /* this bit and @FT_FACE_FLAG_FIXED_SIZES set */ + /* this bit and @FT_FACE_FLAG_FIXED_SIZES set. */ /* */ /* FT_FACE_FLAG_FIXED_SIZES :: */ /* Indicates that the face contains `fixed sizes', i.e., bitmap */ diff --git a/include/freetype/ftbdf.h b/include/freetype/ftbdf.h index f16c0750f..3d2d04b3d 100644 --- a/include/freetype/ftbdf.h +++ b/include/freetype/ftbdf.h @@ -95,12 +95,17 @@ FT_BEGIN_HEADER * This structure models a given BDF/PCF property. * * @fields: - * type :: The property type. + * type :: + * The property type. * - * u.atom :: The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. - * u.integer :: A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. - * u.cardinal :: An unsigned integer, if type is - * @BDF_PROPERTY_TYPE_CARDINAL. + * u.atom :: + * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. + * + * u.integer :: + * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. + * + * u.cardinal :: + * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. */ typedef struct BDF_PropertyRec_ { diff --git a/include/freetype/internal/psaux.h b/include/freetype/internal/psaux.h index 71e033185..c7093fe54 100644 --- a/include/freetype/internal/psaux.h +++ b/include/freetype/internal/psaux.h @@ -175,13 +175,9 @@ FT_BEGIN_HEADER { T1_FIELD_TYPE_NONE = 0, T1_FIELD_TYPE_BOOL, - T1_FIELD_TYPE_BOOL_P, T1_FIELD_TYPE_INTEGER, - T1_FIELD_TYPE_INTEGER_P, T1_FIELD_TYPE_FIXED, - T1_FIELD_TYPE_FIXED_P, T1_FIELD_TYPE_FIXED_1000, - T1_FIELD_TYPE_FIXED_1000_P, T1_FIELD_TYPE_STRING, T1_FIELD_TYPE_KEY, T1_FIELD_TYPE_BBOX, @@ -267,30 +263,18 @@ FT_BEGIN_HEADER }, -#define T1_FIELD_TYPE_BOOL( _ident, _fname ) \ +#define T1_FIELD_BOOL( _ident, _fname ) \ T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL, _fname ) -#define T1_FIELD_TYPE_BOOL_P( _ident, _fname ) \ - T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_BOOL_P, _fname ) - #define T1_FIELD_NUM( _ident, _fname ) \ T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER, _fname ) -#define T1_FIELD_NUM_P( _ident, _fname ) \ - T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_INTEGER_P, _fname ) - #define T1_FIELD_FIXED( _ident, _fname ) \ T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED, _fname ) -#define T1_FIELD_FIXED_P( _ident, _fname ) \ - T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_P, _fname ) - #define T1_FIELD_FIXED_1000( _ident, _fname ) \ T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_1000, _fname ) -#define T1_FIELD_FIXED_1000_P( _ident, _fname ) \ - T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_FIXED_1000_P, _fname ) - #define T1_FIELD_STRING( _ident, _fname ) \ T1_NEW_SIMPLE_FIELD( _ident, T1_FIELD_TYPE_STRING, _fname ) diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h index dd971c764..daf3e8874 100644 --- a/include/freetype/t1tables.h +++ b/include/freetype/t1tables.h @@ -67,10 +67,10 @@ FT_BEGIN_HEADER FT_String* full_name; FT_String* family_name; FT_String* weight; - FT_Fixed* italic_angle; - FT_Bool* is_fixed_pitch; - FT_Fixed* underline_position; - FT_Fixed* underline_thickness; + FT_Fixed italic_angle; + FT_Bool is_fixed_pitch; + FT_Fixed underline_position; + FT_Fixed underline_thickness; } PS_FontInfoRec, *PS_FontInfo; diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c index 784107fd1..313d31505 100644 --- a/src/cid/cidobjs.c +++ b/src/cid/cidobjs.c @@ -223,11 +223,6 @@ FT_FREE( info->family_name ); FT_FREE( info->weight ); - FT_FREE( info->italic_angle ); - FT_FREE( info->underline_position ); - FT_FREE( info->underline_thickness ); - FT_FREE( info->is_fixed_pitch ); - /* release font dictionaries */ FT_FREE( cid->font_dicts ); cid->num_dicts = 0; @@ -352,7 +347,7 @@ root->face_flags |= FT_FACE_FLAG_HORIZONTAL; - if ( info->is_fixed_pitch && *info->is_fixed_pitch ) + if ( info->is_fixed_pitch ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; /* XXX: TODO: add kerning with .afm support */ @@ -402,7 +397,7 @@ /* compute style flags */ root->style_flags = 0; - if ( info->italic_angle && *info->italic_angle ) + if ( info->italic_angle ) root->style_flags |= FT_STYLE_FLAG_ITALIC; if ( info->weight ) { @@ -428,10 +423,8 @@ root->height = (FT_Short)( ( ( root->ascender - root->descender ) * 12 ) / 10 ); - if ( info->underline_position ) - root->underline_position = *info->underline_position >> 16; - if ( info->underline_thickness ) - root->underline_thickness = *info->underline_thickness >> 16; + root->underline_position = info->underline_position >> 16; + root->underline_thickness = info->underline_thickness >> 16; root->internal->max_points = 0; root->internal->max_contours = 0; diff --git a/src/cid/cidtoken.h b/src/cid/cidtoken.h index ff2a89d7f..05434c551 100644 --- a/src/cid/cidtoken.h +++ b/src/cid/cidtoken.h @@ -39,15 +39,15 @@ #undef T1CODE #define T1CODE T1_FIELD_LOCATION_FONT_INFO - T1_FIELD_STRING ( "version", version ) - T1_FIELD_STRING ( "Notice", notice ) - T1_FIELD_STRING ( "FullName", full_name ) - T1_FIELD_STRING ( "FamilyName", family_name ) - T1_FIELD_STRING ( "Weight", weight ) - T1_FIELD_FIXED_P ( "ItalicAngle", italic_angle ) - T1_FIELD_TYPE_BOOL_P( "isFixedPitch", is_fixed_pitch ) - T1_FIELD_FIXED_P ( "UnderlinePosition", underline_position ) - T1_FIELD_FIXED_P ( "UnderlineThickness", underline_thickness ) + T1_FIELD_STRING( "version", version ) + T1_FIELD_STRING( "Notice", notice ) + T1_FIELD_STRING( "FullName", full_name ) + T1_FIELD_STRING( "FamilyName", family_name ) + T1_FIELD_STRING( "Weight", weight ) + T1_FIELD_FIXED ( "ItalicAngle", italic_angle ) + T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch ) + T1_FIELD_FIXED ( "UnderlinePosition", underline_position ) + T1_FIELD_FIXED ( "UnderlineThickness", underline_thickness ) #undef FT_STRUCTURE diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c index c88e3e4a7..fca38baf5 100644 --- a/src/psaux/psobjs.c +++ b/src/psaux/psobjs.c @@ -987,34 +987,18 @@ val = t1_tobool( &cur, limit ); goto Store_Integer; - case T1_FIELD_TYPE_BOOL_P: - val = t1_tobool( &cur, limit ); - goto Store_Integer_P; - case T1_FIELD_TYPE_FIXED: val = t1_tofixed( &cur, limit, 0 ); goto Store_Integer; - case T1_FIELD_TYPE_FIXED_P: - val = t1_tofixed( &cur, limit, 0 ); - goto Store_Integer_P; - case T1_FIELD_TYPE_FIXED_1000: val = t1_tofixed( &cur, limit, 3 ); goto Store_Integer; - case T1_FIELD_TYPE_FIXED_1000_P: - val = t1_tofixed( &cur, limit, 3 ); - goto Store_Integer_P; - case T1_FIELD_TYPE_INTEGER: val = t1_toint( &cur, limit ); goto Store_Integer; - case T1_FIELD_TYPE_INTEGER_P: - val = t1_toint( &cur, limit ); - goto Store_Integer_P; - Store_Integer: switch ( field->size ) { @@ -1035,83 +1019,6 @@ } break; - Store_Integer_P: - switch ( field->size ) - { - case 1: - { - FT_Memory memory = parser->memory; - FT_Byte* p; - - - /* with synthetic fonts, it's possible to find a field twice */ - if ( *(FT_Byte**)q ) - break; - - if ( FT_ALLOC( p, 1 ) ) - goto Exit; - - *p = val; - *(FT_Byte**)q = p; - break; - } - - case 2: - { - FT_Memory memory = parser->memory; - FT_UShort* p; - - - /* with synthetic fonts, it's possible to find a field twice */ - if ( *(FT_UShort**)q ) - break; - - if ( FT_ALLOC( p, 2 ) ) - goto Exit; - - *p = val; - *(FT_UShort**)q = p; - break; - } - - case 4: - { - FT_Memory memory = parser->memory; - FT_UInt32* p; - - - /* with synthetic fonts, it's possible to find a field twice */ - if ( *(FT_UInt32**)q ) - break; - - if ( FT_ALLOC( p, 4 ) ) - goto Exit; - - *p = val; - *(FT_UInt32**)q = p; - break; - } - - default: - { - FT_Memory memory = parser->memory; - FT_Long* p; - - - /* with synthetic fonts, it's possible to find a field twice */ - if ( *(FT_Long**)q ) - break; - - if ( FT_ALLOC( p, 8 ) ) - goto Exit; - - *p = val; - *(FT_Long**)q = p; - break; - } - } - break; - case T1_FIELD_TYPE_STRING: case T1_FIELD_TYPE_KEY: { diff --git a/src/tools/docmaker/tohtml.py b/src/tools/docmaker/tohtml.py index 4bc11d8be..7f08e8d92 100644 --- a/src/tools/docmaker/tohtml.py +++ b/src/tools/docmaker/tohtml.py @@ -7,23 +7,34 @@ import time # The following defines the HTML header used by all generated pages. # html_header_1 = """\ +<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" +"http://www.w3.org/TR/html4/loose.dtd"> <html> -<header> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>""" html_header_2= """ API Reference</title> -<basefont face="Verdana,Geneva,Arial,Helvetica"> -<style content="text/css"> - P { text-align=justify } - H1 { text-align=center } - LI { text-align=justify } +<style type="text/css"> + body { font-family: Verdana, Geneva, Arial, Helvetica, serif; + color: #000000; + background: #FFFFFF; } + + p { text-align: justify; } + h1 { text-align: center; } + li { text-align: justify; } + + a:link { color: #0000EF; } + a:visited { color: #51188E; } + a:hover { color: #FF0000; } + + span.keyword { font-family: monospace; + text-align: left; + white-space: pre; + color: darkblue; } </style> -</header> -<body text=#000000 - bgcolor=#FFFFFF - link=#0000EF - vlink=#51188E - alink=#FF0000> +</head> +<body> <center><h1>""" html_header_3=""" API Reference</h1></center> @@ -54,39 +65,39 @@ para_footer = "</p>" # Block header and footer. # -block_header = "<center><table width=75%><tr><td>" -block_footer = "</td></tr></table><hr width=75%></center>" +block_header = '<table align=center width="75%"><tr><td>' +block_footer = '</td></tr></table><hr width="75%">' # Description header/footer. # -description_header = "<center><table width=87%><tr><td>" -description_footer = "</td></tr></table></center><br>" +description_header = '<table align=center width="87%"><tr><td>' +description_footer = "</td></tr></table><br>" # Marker header/inter/footer combination. # -marker_header = "<center><table width=87% cellpadding=5><tr bgcolor=#EEEEFF><td><em><b>" +marker_header = '<table align=center width="87%" cellpadding=5><tr bgcolor="#EEEEFF"><td><em><b>' marker_inter = "</b></em></td></tr><tr><td>" -marker_footer = "</td></tr></table></center>" +marker_footer = "</td></tr></table>" # Source code extracts header/footer. # -source_header = "<center><table width=87%><tr bgcolor=#D6E8FF width=100%><td><pre>\n" -source_footer = "\n</pre></table></center><br>" +source_header = '<table align=center width="87%"><tr bgcolor="#D6E8FF"><td><pre>\n' +source_footer = "\n</pre></table><br>" # Chapter header/inter/footer. # -chapter_header = "<br><center><table width=75%><tr><td><h2>" +chapter_header = '<br><table align=center width="75%"><tr><td><h2>' chapter_inter = "</h2><ul>" -chapter_footer = "</ul></td></tr></table></center>" +chapter_footer = "</ul></td></tr></table>" # source language keyword coloration/styling # -keyword_prefix = '<font color="darkblue">' -keyword_suffix = '</font>' +keyword_prefix = '<span class="keyword">' +keyword_suffix = '</span>' -section_synopsis_header = '<h2>Synopsis</h2><font color="cyan">' -section_synopsis_footer = '</font>' +section_synopsis_header = '<h2>Synopsis</h2>' +section_synopsis_footer = '' # Translate a single line of source to HTML. This will convert # a "<" into "<.", ">" into ">.", etc. @@ -231,7 +242,7 @@ class HtmlFormatter(Formatter): def print_html_field( self, field ): if field.name: - print "<table valign=top><tr><td><b>"+field.name+"</b></td><td>" + print "<table><tr valign=top><td><b>"+field.name+"</b></td><td>" print self.make_html_items( field.items ) @@ -273,7 +284,7 @@ class HtmlFormatter(Formatter): def print_html_field_list( self, fields ): - print "<table valign=top cellpadding=3>" + print "<table cellpadding=3>" for field in fields: print "<tr valign=top><td><b>" + field.name + "</b></td><td>" self.print_html_items( field.items ) @@ -320,7 +331,7 @@ class HtmlFormatter(Formatter): count = len( self.block_index ) rows = (count + self.columns - 1)/self.columns - print "<center><table border=0 cellpadding=0 cellspacing=0>" + print "<table align=center border=0 cellpadding=0 cellspacing=0>" for r in range(rows): line = "<tr>" for c in range(self.columns): @@ -334,7 +345,7 @@ class HtmlFormatter(Formatter): line = line + "</tr>" print line - print "</table></center>" + print "</table>" print self.html_footer self.index_items = {} @@ -374,7 +385,7 @@ class HtmlFormatter(Formatter): print chapter_header + '<a href="' + index_filename + '">Global Index</a>' + chapter_inter + chapter_footer def toc_exit( self ): - print "</table></center>" + print "</table>" print self.html_footer def toc_dump( self, toc_filename = None, index_filename = None ): @@ -398,7 +409,7 @@ class HtmlFormatter(Formatter): # print section synopsys print section_synopsis_header - print "<center><table cellspacing=5 cellpadding=0 border=0>" + print "<table align=center cellspacing=5 cellpadding=0 border=0>" maxwidth = 0 for b in section.blocks.values(): @@ -425,7 +436,7 @@ class HtmlFormatter(Formatter): line = line + "</tr>" print line - print "</table></center><br><br>" + print "</table><br><br>" print section_synopsis_footer print description_header @@ -437,9 +448,7 @@ class HtmlFormatter(Formatter): # place html anchor if needed if block.name: - print '<a name="' + block.name + '">' - print "<h4>" + block.name + "</h4>" - print "</a>" + print '<h4><a name="' + block.name + '">' + block.name + '</a></h4>' # dump the block C source lines now if block.code: diff --git a/src/type1/t1load.c b/src/type1/t1load.c index 3e3850e5e..6bc7b9285 100644 --- a/src/type1/t1load.c +++ b/src/type1/t1load.c @@ -1450,11 +1450,16 @@ }; +#define T1_FIELD_COUNT \ + ( sizeof ( t1_keywords ) / sizeof ( t1_keywords[0] ) ) + + static FT_Error parse_dict( T1_Face face, T1_Loader loader, FT_Byte* base, - FT_Long size ) + FT_Long size, + FT_Byte* keyword_flags ) { T1_Parser parser = &loader->parser; @@ -1519,7 +1524,8 @@ { { /* now, compare the immediate name to the keyword table */ - T1_Field keyword = (T1_Field)t1_keywords; + T1_Field keyword = (T1_Field)t1_keywords; + FT_Byte* keyword_flag = keyword_flags; for (;;) @@ -1546,17 +1552,25 @@ /* we found it -- run the parsing callback! */ parser->root.cursor = cur2; T1_Skip_Spaces( parser ); - parser->root.error = t1_load_keyword( face, - loader, - keyword ); - if ( parser->root.error ) - return parser->root.error; + + /* we only record the first instance of any */ + /* field to deal adequately with synthetic fonts */ + if ( keyword_flag[0] == 0 ) + { + parser->root.error = t1_load_keyword( face, + loader, + keyword ); + if ( parser->root.error ) + return parser->root.error; + } + keyword_flag[0] = 1; cur = parser->root.cursor; break; } } keyword++; + keyword_flag++; } } } @@ -1612,6 +1626,7 @@ T1_Parser parser; T1_Font type1 = &face->type1; FT_Error error; + FT_Byte keyword_flags[T1_FIELD_COUNT]; PSAux_Service psaux = (PSAux_Service)face->psaux; @@ -1632,7 +1647,16 @@ if ( error ) goto Exit; - error = parse_dict( face, &loader, parser->base_dict, parser->base_len ); + { + FT_UInt n; + + + for ( n = 0; n < T1_FIELD_COUNT; n++ ) + keyword_flags[n] = 0; + } + + error = parse_dict( face, &loader, parser->base_dict, parser->base_len, + keyword_flags ); if ( error ) goto Exit; @@ -1641,7 +1665,8 @@ goto Exit; error = parse_dict( face, &loader, parser->private_dict, - parser->private_len ); + parser->private_len, + keyword_flags ); if ( error ) goto Exit; diff --git a/src/type1/t1objs.c b/src/type1/t1objs.c index 547af263d..c62e72b7e 100644 --- a/src/type1/t1objs.c +++ b/src/type1/t1objs.c @@ -211,11 +211,6 @@ FT_FREE( info->full_name ); FT_FREE( info->family_name ); FT_FREE( info->weight ); - - FT_FREE( info->italic_angle ); - FT_FREE( info->underline_position ); - FT_FREE( info->underline_thickness ); - FT_FREE( info->is_fixed_pitch ); } /* release top dictionary */ @@ -341,7 +336,7 @@ root->face_flags |= FT_FACE_FLAG_HORIZONTAL; root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES; - if ( info->is_fixed_pitch && *info->is_fixed_pitch ) + if ( info->is_fixed_pitch ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; if ( face->blend ) @@ -394,7 +389,7 @@ /* compute style flags */ root->style_flags = 0; - if ( info->italic_angle && *info->italic_angle ) + if ( info->italic_angle ) root->style_flags |= FT_STYLE_FLAG_ITALIC; if ( info->weight ) { @@ -439,10 +434,8 @@ root->max_advance_height = root->height; - if ( info->underline_position ) - root->underline_position = *info->underline_position >> 16; - if ( info->underline_thickness ) - root->underline_thickness = *info->underline_thickness >> 16; + root->underline_position = info->underline_position >> 16; + root->underline_thickness = info->underline_thickness >> 16; root->internal->max_points = 0; root->internal->max_contours = 0; diff --git a/src/type1/t1tokens.h b/src/type1/t1tokens.h index 5308df146..b09f4b9b3 100644 --- a/src/type1/t1tokens.h +++ b/src/type1/t1tokens.h @@ -21,17 +21,17 @@ #undef T1CODE #define T1CODE T1_FIELD_LOCATION_FONT_INFO - T1_FIELD_STRING ( "version", version ) - T1_FIELD_STRING ( "Notice", notice ) - T1_FIELD_STRING ( "FullName", full_name ) - T1_FIELD_STRING ( "FamilyName", family_name ) - T1_FIELD_STRING ( "Weight", weight ) + T1_FIELD_STRING( "version", version ) + T1_FIELD_STRING( "Notice", notice ) + T1_FIELD_STRING( "FullName", full_name ) + T1_FIELD_STRING( "FamilyName", family_name ) + T1_FIELD_STRING( "Weight", weight ) /* we use pointers to detect modifications made by synthetic fonts */ - T1_FIELD_FIXED_P ( "ItalicAngle", italic_angle ) - T1_FIELD_TYPE_BOOL_P( "isFixedPitch", is_fixed_pitch ) - T1_FIELD_FIXED_P ( "UnderlinePosition", underline_position ) - T1_FIELD_FIXED_P ( "UnderlineThickness", underline_thickness ) + T1_FIELD_FIXED ( "ItalicAngle", italic_angle ) + T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch ) + T1_FIELD_FIXED ( "UnderlinePosition", underline_position ) + T1_FIELD_FIXED ( "UnderlineThickness", underline_thickness ) #undef FT_STRUCTURE @@ -66,10 +66,10 @@ #undef T1CODE #define T1CODE T1_FIELD_LOCATION_FONT_DICT - T1_FIELD_KEY ( "FontName", font_name ) - T1_FIELD_NUM_P ( "PaintType", paint_type ) - T1_FIELD_NUM ( "FontType", font_type ) - T1_FIELD_FIXED_P( "StrokeWidth", stroke_width ) + T1_FIELD_KEY ( "FontName", font_name ) + T1_FIELD_NUM ( "PaintType", paint_type ) + T1_FIELD_NUM ( "FontType", font_type ) + T1_FIELD_FIXED( "StrokeWidth", stroke_width ) #undef FT_STRUCTURE #define FT_STRUCTURE FT_BBox diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c index 44da0e5a6..bb4120571 100644 --- a/src/type42/t42objs.c +++ b/src/type42/t42objs.c @@ -203,7 +203,7 @@ root->face_flags |= FT_FACE_FLAG_HORIZONTAL; root->face_flags |= FT_FACE_FLAG_GLYPH_NAMES; - if ( info->is_fixed_pitch && *info->is_fixed_pitch ) + if ( info->is_fixed_pitch ) root->face_flags |= FT_FACE_FLAG_FIXED_WIDTH; /* XXX: TODO -- add kerning with .afm support */ @@ -278,17 +278,15 @@ root->max_advance_width = face->ttf_face->max_advance_width; root->max_advance_height = face->ttf_face->max_advance_height; - if ( info->underline_position ) - root->underline_position = *info->underline_position >> 16; - if ( info->underline_thickness ) - root->underline_thickness = *info->underline_thickness >> 16; + root->underline_position = info->underline_position >> 16; + root->underline_thickness = info->underline_thickness >> 16; root->internal->max_points = 0; root->internal->max_contours = 0; /* compute style flags */ root->style_flags = 0; - if ( info->italic_angle && *info->italic_angle ) + if ( info->italic_angle ) root->style_flags |= FT_STYLE_FLAG_ITALIC; if ( face->ttf_face->style_flags & FT_STYLE_FLAG_BOLD ) @@ -388,11 +386,6 @@ FT_FREE( info->family_name ); FT_FREE( info->weight ); - FT_FREE( info->italic_angle ); - FT_FREE( info->underline_position ); - FT_FREE( info->underline_thickness ); - FT_FREE( info->is_fixed_pitch ); - /* release top dictionary */ FT_FREE( type1->charstrings_len ); FT_FREE( type1->charstrings ); diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c index 66d46358d..8e4bbeaca 100644 --- a/src/type42/t42parse.c +++ b/src/type42/t42parse.c @@ -57,25 +57,25 @@ #undef T1CODE #define T1CODE T1_FIELD_LOCATION_FONT_INFO - T1_FIELD_STRING ( "version", version ) - T1_FIELD_STRING ( "Notice", notice ) - T1_FIELD_STRING ( "FullName", full_name ) - T1_FIELD_STRING ( "FamilyName", family_name ) - T1_FIELD_STRING ( "Weight", weight ) - T1_FIELD_FIXED_P ( "ItalicAngle", italic_angle ) - T1_FIELD_TYPE_BOOL_P( "isFixedPitch", is_fixed_pitch ) - T1_FIELD_FIXED_P ( "UnderlinePosition", underline_position ) - T1_FIELD_FIXED_P ( "UnderlineThickness", underline_thickness ) + T1_FIELD_STRING( "version", version ) + T1_FIELD_STRING( "Notice", notice ) + T1_FIELD_STRING( "FullName", full_name ) + T1_FIELD_STRING( "FamilyName", family_name ) + T1_FIELD_STRING( "Weight", weight ) + T1_FIELD_FIXED ( "ItalicAngle", italic_angle ) + T1_FIELD_BOOL ( "isFixedPitch", is_fixed_pitch ) + T1_FIELD_FIXED ( "UnderlinePosition", underline_position ) + T1_FIELD_FIXED ( "UnderlineThickness", underline_thickness ) #undef FT_STRUCTURE #define FT_STRUCTURE T1_FontRec #undef T1CODE #define T1CODE T1_FIELD_LOCATION_FONT_DICT - T1_FIELD_KEY ( "FontName", font_name ) - T1_FIELD_NUM_P ( "PaintType", paint_type ) - T1_FIELD_NUM ( "FontType", font_type ) - T1_FIELD_FIXED_P( "StrokeWidth", stroke_width ) + T1_FIELD_KEY ( "FontName", font_name ) + T1_FIELD_NUM ( "PaintType", paint_type ) + T1_FIELD_NUM ( "FontType", font_type ) + T1_FIELD_FIXED( "StrokeWidth", stroke_width ) #undef FT_STRUCTURE #define FT_STRUCTURE FT_BBox @@ -93,6 +93,10 @@ }; +#define T42_KEYWORD_COUNT \ + ( sizeof ( t42_keywords ) / sizeof ( t42_keywords[0] ) ) + + #define T1_Add_Table( p, i, o, l ) (p)->funcs.add( (p), i, o, l ) #define T1_Done_Table( p ) \ do \ @@ -814,7 +818,16 @@ FT_Byte* limit = cur + size; FT_UInt n_keywords = (FT_UInt)( sizeof ( t42_keywords ) / sizeof ( t42_keywords[0] ) ); + + FT_Byte keyword_flags[T42_KEYWORD_COUNT]; + + { + FT_UInt n; + + for ( n = 0; n < T42_KEYWORD_COUNT; n++ ) + keyword_flags[n] = 0; + } parser->root.cursor = base; parser->root.limit = base + size; @@ -887,11 +900,19 @@ /* we found it -- run the parsing callback! */ parser->root.cursor = cur2; T1_Skip_Spaces( parser ); - parser->root.error = t42_load_keyword(face, - loader, - keyword ); - if ( parser->root.error ) - return parser->root.error; + + /* only record the first instance of each field/keyword */ + /* to deal with synthetic fonts correctly */ + if ( keyword_flags[i] == 0 ) + { + parser->root.error = t42_load_keyword(face, + loader, + keyword ); + if ( parser->root.error ) + return parser->root.error; + } + keyword_flags[i] = 1; + cur = parser->root.cursor; break; } |