ref: 9a814fabbf7bd76da1ca978a9123c64e50dd0a1a
parent: 29a90e2610ad5dc93ae4fc24e37a74bbe751f834
author: Werner Lemberg <[email protected]>
date: Sun Aug 6 15:48:47 EDT 2000
Yamano-uchi added support for SFNT-wrapped CID bitmap font files (with minor modifications from WL).
--- a/src/sfnt/sfobjs.c
+++ b/src/sfnt/sfobjs.c
@@ -254,6 +254,7 @@
FT_Parameter* params )
{
FT_Error error;
+ FT_Bool missing_outline = 0;
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
FT_UNUSED( face_index );
@@ -262,33 +263,60 @@
/* Load tables */
- if ( LOAD_( header ) ||
- LOAD_( max_profile ) ||
- /* load the `hhea' & `hmtx' tables at once */
- ( error = sfnt->load_metrics( face, stream, 0 ) ) != TT_Err_Ok ||
+ /* If you load SFNT wrapped sbit font files, it will fail if you */
+ /* want to read the `head', `hhea', and `vhea' tables. */
+ /* */
+ if ( LOAD_( header ) )
+ {
+#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+ missing_outline = 1;
+#else
+ goto Exit;
+#endif
+
+ }
+
+ if ( LOAD_( max_profile ) ||
+ LOAD_( charmaps ) ||
+ LOAD_( names ) ||
+ LOAD_( psnames ) )
+ goto Exit;
+
+ if ( /* load the `hhea' & `hmtx' tables at once */
+ ( ( error = sfnt->load_metrics( face, stream, 0 ) ) != TT_Err_Ok ) ||
/* try to load the `vhea' & `vmtx' at once if present */
- ( error = sfnt->load_metrics( face, stream, 1 ) ) != TT_Err_Ok ||
+ ( ( error = sfnt->load_metrics( face, stream, 1 ) ) != TT_Err_Ok ) ||
+ LOAD_( os2 ) )
+ {
- LOAD_( charmaps ) ||
- LOAD_( names ) ||
- LOAD_( os2 ) ||
- LOAD_( psnames ) )
- goto Exit;
+#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+ missing_outline = 1;
+#else
+ goto Exit;
+#endif
+ }
+
/* the optional tables */
#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS
+
/* embedded bitmap support. */
if ( sfnt->load_sbits && LOAD_( sbits ) )
- goto Exit;
+ {
+ if ( !( ( error == TT_Err_Table_Missing ) && /* missing SBit */
+ ( missing_outline == 0 ) ) ) /* find outline */
+ goto Exit;
+ }
+
#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
- if ( LOAD_( hdmx ) ||
- LOAD_( gasp ) ||
- LOAD_( kerning ) ||
- LOAD_( pclt ) )
+ if ( LOAD_( hdmx ) ||
+ LOAD_( gasp ) ||
+ LOAD_( kerning ) ||
+ LOAD_( pclt ) )
goto Exit;
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
@@ -302,7 +330,7 @@
/* now set up root fields */
{
FT_Face root = &face->root;
- FT_Int flags;
+ FT_Int flags = 0;
TT_CharMap charmap;
FT_Int n;
FT_Memory memory;
@@ -314,10 +342,12 @@
/* */
/* Compute face flags. */
/* */
- flags = FT_FACE_FLAG_SCALABLE | /* scalable outlines */
- FT_FACE_FLAG_SFNT | /* SFNT file format */
- FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
+ if ( missing_outline == 0 )
+ flags = FT_FACE_FLAG_SCALABLE; /* scalable outlines */
+ flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */
+ FT_FACE_FLAG_HORIZONTAL; /* horizontal data */
+
#ifdef TT_CONFIG_OPTION_POSTSCRIPT_NAMES
/* might need more polish to detect the presence of a Postscript */
/* name table in the font */
@@ -343,24 +373,26 @@
/* Compute style flags. */
/* */
flags = 0;
-
- if ( face->os2.version != 0xFFFF )
+ if ( missing_outline == 0 )
{
- /* we have an OS/2 table; use the `fsSelection' field */
- if ( face->os2.fsSelection & 1 )
- flags |= FT_STYLE_FLAG_ITALIC;
+ if ( face->os2.version != 0xFFFF )
+ {
+ /* we have an OS/2 table; use the `fsSelection' field */
+ if ( face->os2.fsSelection & 1 )
+ flags |= FT_STYLE_FLAG_ITALIC;
- if ( face->os2.fsSelection & 32 )
- flags |= FT_STYLE_FLAG_BOLD;
- }
- else
- {
- /* this is an old Mac font, use the header field */
- if ( face->header.Mac_Style & 1 )
- flags |= FT_STYLE_FLAG_BOLD;
+ if ( face->os2.fsSelection & 32 )
+ flags |= FT_STYLE_FLAG_BOLD;
+ }
+ else
+ {
+ /* this is an old Mac font, use the header field */
+ if ( face->header.Mac_Style & 1 )
+ flags |= FT_STYLE_FLAG_BOLD;
- if ( face->header.Mac_Style & 2 )
- flags |= FT_STYLE_FLAG_ITALIC;
+ if ( face->header.Mac_Style & 2 )
+ flags |= FT_STYLE_FLAG_ITALIC;
+ }
}
root->style_flags = flags;
@@ -403,11 +435,20 @@
if ( face->num_sbit_strikes )
{
- root->num_fixed_sizes = face->num_sbit_strikes;
- if ( ALLOC_ARRAY( root->available_sizes,
- face->num_sbit_strikes,
- FT_Bitmap_Size ) )
- return error;
+ root->face_flags |= FT_FACE_FLAG_FIXED_SIZES;
+#if 0
+ /* I don't know criteria whether layout is horizontal or vertical */
+ if ( missing_outline )
+ {
+ ...
+ root->face_flags |= FT_FACE_FLAG_VERTICAL;
+ }
+#endif
+ root->num_fixed_sizes = face->num_sbit_strikes;
+ if ( ALLOC_ARRAY( root->available_sizes,
+ face->num_sbit_strikes,
+ FT_Bitmap_Size ) )
+ return error;
for ( n = 0 ; n < face->num_sbit_strikes ; n++ )
{
@@ -419,7 +460,7 @@
}
else
-#else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
+#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
{
root->num_fixed_sizes = 0;
@@ -426,46 +467,51 @@
root->available_sizes = 0;
}
-#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
-
/*********************************************************************/
/* */
/* Set up metrics. */
/* */
- root->bbox.xMin = face->header.xMin;
- root->bbox.yMin = face->header.yMin;
- root->bbox.xMax = face->header.xMax;
- root->bbox.yMax = face->header.yMax;
- root->units_per_EM = face->header.Units_Per_EM;
-
- /* The ascender/descender/height are computed from the OS/2 table */
- /* when found. Otherwise, they're taken from the horizontal header. */
- if ( face->os2.version != 0xFFFF )
+ if ( missing_outline == 0 )
{
- root->ascender = face->os2.sTypoAscender;
- root->descender = -face->os2.sTypoDescender;
- root->height = root->ascender + root->descender +
- face->os2.sTypoLineGap;
- }
- else
- {
- root->ascender = face->horizontal.Ascender;
- root->descender = face->horizontal.Descender;
- root->height = root->ascender + root->descender +
- face->horizontal.Line_Gap;
- }
+ /* XXX What about if outline header is missing */
+ /* (e.g. sfnt wrapped outline)? */
+ root->bbox.xMin = face->header.xMin;
+ root->bbox.yMin = face->header.yMin;
+ root->bbox.xMax = face->header.xMax;
+ root->bbox.yMax = face->header.yMax;
+ root->units_per_EM = face->header.Units_Per_EM;
- root->max_advance_width = face->horizontal.advance_Width_Max;
+ /* The ascender/descender/height are computed from the OS/2 table */
+ /* when found. Otherwise, they're taken from the horizontal */
+ /* header. */
+ /* */
+ if ( face->os2.version != 0xFFFF )
+ {
+ root->ascender = face->os2.sTypoAscender;
+ root->descender = -face->os2.sTypoDescender;
+ root->height = root->ascender + root->descender +
+ face->os2.sTypoLineGap;
+ }
+ else
+ {
+ root->ascender = face->horizontal.Ascender;
+ root->descender = face->horizontal.Descender;
+ root->height = root->ascender + root->descender +
+ face->horizontal.Line_Gap;
+ }
- root->max_advance_height = face->vertical_info
- ? face->vertical.advance_Height_Max
- : root->height;
+ root->max_advance_width = face->horizontal.advance_Width_Max;
- root->underline_position = face->postscript.underlinePosition;
- root->underline_thickness = face->postscript.underlineThickness;
+ root->max_advance_height = face->vertical_info
+ ? face->vertical.advance_Height_Max
+ : root->height;
- /* root->max_points -- already set up */
- /* root->max_contours -- already set up */
+ root->underline_position = face->postscript.underlinePosition;
+ root->underline_thickness = face->postscript.underlineThickness;
+
+ /* root->max_points -- already set up */
+ /* root->max_contours -- already set up */
+ }
}
Exit:
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -459,13 +459,10 @@
/* this table is optional */
error = face->goto_table( face, TTAG_EBLC, stream, 0 );
- if (error)
+ if ( error )
error = face->goto_table( face, TTAG_bloc, stream, 0 );
if ( error )
- {
- error = 0;
goto Exit;
- }
table_base = FILE_Pos();
if ( ACCESS_Frame( 8L ) )
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -212,9 +212,10 @@
if ( error )
goto Exit;
- error = TT_Load_Locations( face, stream ) ||
- TT_Load_CVT ( face, stream ) ||
- TT_Load_Programs ( face, stream );
+ if ( face->root.face_flags & FT_FACE_FLAG_SCALABLE )
+ error = TT_Load_Locations( face, stream ) ||
+ TT_Load_CVT ( face, stream ) ||
+ TT_Load_Programs ( face, stream );
/* initialize standard glyph loading routines */
TT_Init_Glyph_Loading( face );