This fix is a improvement for sfnt wrapped sbit font files. * No base API functions changed. * Improve on handling sfnt wrapped sbit files We now use sbit files for WindowsCE. * (FT_Size_Metrics*)size->driver.data is filled sbit line metrics. Because it is differs from size->metrics. It is usefull when we want to use sbit metrics. And when we use sfnt wrapped sbit font files (without any outlines), size->metrics is identified the above metrics. * add sbit_strike in TT_Size_Metrics. TT_SBit_Strike_index { FT_UShort index; FT_Bool valid; }; * rewrite TT_Reset_Size. * minor fixes and add some comments. * fix some typo in freetype/freetype.h (?_resolution are not defined in FT_Size_Metrics) * cosmetics fixes and tests are needed. If you want to try this patch, you can obtain a sfnt wrapped sbit font (for WindowsCE, redistribution freely) from http://www.softclub.co.jp/~zoro/k12x10/k12x10ttf.lzh Please review and commit it. diff -ur ../freetype2/include/freetype/freetype.h ./freetype2/include/freetype/freetype.h --- ../freetype2/include/freetype/freetype.h Thu Oct 26 07:35:44 2000 +++ ./freetype2/include/freetype/freetype.h Sun Nov 5 13:30:47 2000 @@ -876,16 +876,6 @@ /* to scale vertical distances expressed in font */ /* units to fractional (26.6) pixel coordinates. */ /* */ - /* x_resolution :: The horizontal device resolution for this size */ - /* object, expressed in integer dots per inches */ - /* (dpi). As a convention, fixed font formats set */ - /* this value to 72. */ - /* */ - /* y_resolution :: The vertical device resolution for this size */ - /* object, expressed in integer dots per inches */ - /* (dpi). As a convention, fixed font formats set */ - /* this value to 72. */ - /* */ /* ascender :: The ascender, expressed in 26.6 fixed point */ /* pixels. Always positive. */ /* */ @@ -955,6 +945,7 @@ FT_Generic generic; /* generic pointer for client uses */ FT_Size_Metrics metrics; /* size metrics */ + FT_Generic driver; /* generic pointer for font drivers */ } FT_SizeRec; diff -ur ../freetype2/include/freetype/internal/sfnt.h ./freetype2/include/freetype/internal/sfnt.h --- ../freetype2/include/freetype/internal/sfnt.h Sat Aug 5 07:05:01 2000 +++ ./freetype2/include/freetype/internal/sfnt.h Sun Nov 5 12:57:01 2000 @@ -281,14 +281,18 @@ /* */ typedef FT_Error (*TT_Load_SBit_Image_Func)( TT_Face face, - FT_Int x_ppem, - FT_Int y_ppem, + FT_ULong strike_index, FT_UInt glyph_index, FT_UInt load_flags, FT_Stream stream, FT_Bitmap* map, TT_SBit_Metrics* metrics ); + typedef + FT_Error (*TT_Set_SBit_Strike_Func)( TT_Face face, + FT_Int x_ppem, + FT_Int y_ppem, + FT_ULong* astrike_index ); /*************************************************************************/ /* */ @@ -473,8 +477,10 @@ TT_Load_Table_Func load_kerning; TT_Load_Table_Func load_gasp; - TT_Load_Table_Func load_pclt; + TT_Load_Table_Func load_pclt; + TT_Load_Table_Func load_bitmap_header; + TT_Set_SBit_Strike_Func set_sbit_strike; /* see `ttsbit.h' */ TT_Load_Table_Func load_sbits; TT_Load_SBit_Image_Func load_sbit_image; diff -ur ../freetype2/include/freetype/internal/tttypes.h ./freetype2/include/freetype/internal/tttypes.h --- ../freetype2/include/freetype/internal/tttypes.h Sun Oct 29 01:34:23 2000 +++ ./freetype2/include/freetype/internal/tttypes.h Sat Nov 4 20:53:25 2000 @@ -492,7 +492,7 @@ /* */ /* A structure used to hold the big metrics of a given glyph bitmap */ /* in a TrueType or OpenType font. These are usually found in the */ - /* `EBDT' (Microsoft) or `bdat' (Apple) table. */ + /* `EBDT' (Microsoft) or `bloc' (Apple) table. */ /* */ /* */ /* height :: The glyph height in pixels. */ @@ -700,7 +700,11 @@ /* */ /* index_ranges :: An array of glyph index ranges. */ /* */ - /* color_ref :: Unused. A color reference? */ + /* color_ref :: Unused. color_ref is put in for future */ + /* enhancements, but these fields are already */ + /* in use by other platforms (e.g. Newton). */ + /* For details, please see */ + /* http://fonts.apple.com/TTRefMan/RM06/Chap6bloc.html */ /* */ /* hori :: The line metrics for horizontal layouts. */ /* */ @@ -718,6 +722,8 @@ /* and 8. */ /* */ /* flags :: Is this a vertical or horizontal strike? */ + /* For details, please see */ + /* http://fonts.apple.com/TTRefMan/RM06/Chap6bloc.html */ /* */ typedef struct TT_SBit_Strike_ { diff -ur ../freetype2/include/freetype/tttags.h ./freetype2/include/freetype/tttags.h --- ../freetype2/include/freetype/tttags.h Sat Aug 5 07:04:56 2000 +++ ./freetype2/include/freetype/tttags.h Sat Nov 4 15:52:34 2000 @@ -32,6 +32,7 @@ #define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) #define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) #define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) +#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' ) #define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' ) #define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) #define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' ) diff -ur ../freetype2/src/sfnt/sfdriver.c ./freetype2/src/sfnt/sfdriver.c --- ../freetype2/src/sfnt/sfdriver.c Sat Aug 5 07:05:33 2000 +++ ./freetype2/src/sfnt/sfdriver.c Sun Nov 5 12:58:46 2000 @@ -172,13 +172,18 @@ #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + /* see `ttload.h` */ + TT_Load_Bitmap_Header, /* see `ttsbit.h' */ + TT_Set_SBit_Strike, TT_Load_SBit_Strikes, TT_Load_SBit_Image, TT_Free_SBit_Strikes, #else /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + 0, + 0, 0, 0, 0, diff -ur ../freetype2/src/sfnt/sfobjs.c ./freetype2/src/sfnt/sfobjs.c --- ../freetype2/src/sfnt/sfobjs.c Sat Sep 23 21:16:30 2000 +++ ./freetype2/src/sfnt/sfobjs.c Sun Nov 5 13:15:04 2000 @@ -255,7 +255,11 @@ FT_Parameter* params ) { FT_Error error; - FT_Bool missing_outline = 0; + FT_Bool header_loaded = FALSE; +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + FT_Bool has_outline = TRUE; + FT_Bool is_apple_sbit = FALSE; +#endif SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt; FT_UNUSED( face_index ); @@ -265,18 +269,32 @@ /* Load tables */ - /* 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; + /* + * Is this SFNT wrapeed sbit fonts files? + * I don't know whether this criteria is always valid.... + */ + if ( !TT_LookUp_Table( face, TTAG_glyf ) ) + has_outline = FALSE; + /* + * XXX: + * We must load 'bdat' table when we use "Apple" a SFNT wrapped sbit font. + * We might load 'head' for "WindowsCE" one. Is it true? + */ + if ( has_outline != TRUE ) + if (!LOAD_( bitmap_header )) + { + header_loaded = TRUE; + is_apple_sbit = TRUE; + } #endif + if ( header_loaded != TRUE ) + { + if (LOAD_( header ) ) + goto Exit; + else + header_loaded = TRUE; } if ( LOAD_( max_profile ) || @@ -285,19 +303,20 @@ 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 ) || - LOAD_( os2 ) ) - { - + /* If you load "Apple" SFNT wrapped sbit font files, */ + /* it will fail if you want to read the `hhea' and `vhea' tables. */ #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - missing_outline = 1; -#else - goto Exit; + if ( is_apple_sbit != TRUE ) #endif - + { + 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 || + LOAD_( os2 ) ) + { + goto Exit; + } } /* the optional tables */ @@ -308,10 +327,9 @@ if ( sfnt->load_sbits && LOAD_( sbits ) ) { if ( !( ( error == TT_Err_Table_Missing ) && /* missing SBit */ - ( missing_outline == 0 ) ) ) /* find outline */ + ( has_outline == TRUE ) ) ) /* find outline */ goto Exit; } - #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ if ( LOAD_( hdmx ) || @@ -343,7 +361,7 @@ /* */ /* Compute face flags. */ /* */ - if ( missing_outline == 0 ) + if ( has_outline == TRUE ) flags = FT_FACE_FLAG_SCALABLE; /* scalable outlines */ flags |= FT_FACE_FLAG_SFNT | /* SFNT file format */ @@ -374,7 +392,7 @@ /* Compute style flags. */ /* */ flags = 0; - if ( missing_outline == 0 ) + if ( has_outline == TRUE ) { if ( face->os2.version != 0xFFFF ) { @@ -439,7 +457,7 @@ root->face_flags |= FT_FACE_FLAG_FIXED_SIZES; #if 0 /* I don't know criteria whether layout is horizontal or vertical */ - if ( missing_outline ) + if ( has_outline.... ) { ... root->face_flags |= FT_FACE_FLAG_VERTICAL; @@ -472,7 +490,7 @@ /* */ /* Set up metrics. */ /* */ - if ( missing_outline == 0 ) + if ( has_outline == TRUE ) { /* XXX What about if outline header is missing */ /* (e.g. sfnt wrapped outline)? */ diff -ur ../freetype2/src/sfnt/ttload.c ./freetype2/src/sfnt/ttload.c --- ../freetype2/src/sfnt/ttload.c Wed Aug 23 09:28:07 2000 +++ ./freetype2/src/sfnt/ttload.c Sun Nov 5 13:27:27 2000 @@ -459,8 +459,9 @@ /* FreeType error code. 0 means success. */ /* */ LOCAL_FUNC - FT_Error TT_Load_Header( TT_Face face, - FT_Stream stream ) + FT_Error TT_Load_Generic_Header( TT_Face face, + FT_Stream stream, + FT_ULong tag ) { FT_Error error; TT_Header* header; @@ -496,7 +497,7 @@ FT_TRACE2(( "Load_TT_Header: %08p\n", face )); - error = face->goto_table( face, TTAG_head, stream, 0 ); + error = face->goto_table( face, tag, stream, 0 ); if ( error ) { FT_TRACE0(( "Font Header is missing!\n" )); @@ -516,6 +517,21 @@ return error; } + LOCAL_FUNC + FT_Error TT_Load_Header( TT_Face face, + FT_Stream stream ) + { + return TT_Load_Generic_Header( face, stream, TTAG_head ); + } + +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + LOCAL_FUNC + FT_Error TT_Load_Bitmap_Header( TT_Face face, + FT_Stream stream ) + { + return TT_Load_Generic_Header( face, stream, TTAG_bhed ); + } +#endif /*************************************************************************/ /* */ diff -ur ../freetype2/src/sfnt/ttload.h ./freetype2/src/sfnt/ttload.h --- ../freetype2/src/sfnt/ttload.h Sat Jul 8 05:24:55 2000 +++ ./freetype2/src/sfnt/ttload.h Sun Nov 5 13:27:38 2000 @@ -120,6 +120,11 @@ FT_Error TT_Load_Gasp( TT_Face face, FT_Stream stream ); +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + LOCAL_DEF + FT_Error TT_Load_Bitmap_Header( TT_Face face, + FT_Stream stream ); +#endif #ifdef __cplusplus } diff -ur ../freetype2/src/sfnt/ttsbit.c ./freetype2/src/sfnt/ttsbit.c --- ../freetype2/src/sfnt/ttsbit.c Sun Aug 6 23:33:12 2000 +++ ./freetype2/src/sfnt/ttsbit.c Sun Nov 5 12:55:12 2000 @@ -627,6 +627,30 @@ face->num_sbit_strikes = 0; } + LOCAL_FUNC + FT_Error TT_Set_SBit_Strike( TT_Face face, + FT_Int x_ppem, + FT_Int y_ppem, + FT_ULong* astrike_index ) + { + FT_ULong i; + + if ( x_ppem < 0 || x_ppem > 255 || + y_ppem < 1 || y_ppem > 255 ) + return TT_Err_Invalid_PPem; + + for ( i = 0; i < face->num_sbit_strikes; i++ ) + { + if ( ( face->sbit_strikes[i].y_ppem == y_ppem ) && + ( ( x_ppem == 0 ) || + ( face->sbit_strikes[i].x_ppem == x_ppem ))) + { + *astrike_index = i; + return TT_Err_Ok; + } + } + return TT_Err_Invalid_PPem; + } /*************************************************************************/ /* */ @@ -736,13 +760,12 @@ /* */ /* */ /* Checks whether an embedded bitmap (an `sbit') exists for a given */ - /* glyph, at given x and y ppems. */ + /* glyph, at a given strike. */ /* */ /* */ /* face :: The target face object. */ /* glyph_index :: The glyph index. */ - /* x_ppem :: The horizontal resolution in points per EM. */ - /* y_ppem :: The vertical resolution in points per EM. */ + /* strike_index :: The current strike index. */ /* */ /* */ /* arange :: The SBit range containing the glyph index. */ @@ -756,37 +779,28 @@ static FT_Error Find_SBit_Image( TT_Face face, FT_UInt glyph_index, - FT_Int x_ppem, - FT_Int y_ppem, + FT_ULong strike_index, TT_SBit_Range** arange, TT_SBit_Strike** astrike, FT_ULong* aglyph_offset ) { - TT_SBit_Strike* strike = face->sbit_strikes; - TT_SBit_Strike* strike_limit = strike + face->num_sbit_strikes; - + FT_Error error; + TT_SBit_Strike* strike; - if ( !strike ) + if ( !face->sbit_strikes || ( face->num_sbit_strikes <= strike_index ) ) goto Fail; - for ( ; strike < strike_limit; strike++ ) - { - if ( strike->x_ppem == x_ppem && strike->y_ppem == y_ppem ) - { - FT_Error error; + strike = &face->sbit_strikes[strike_index]; + error = Find_SBit_Range( glyph_index, strike, + arange, aglyph_offset ); + if ( error ) + goto Fail; - error = Find_SBit_Range( glyph_index, strike, - arange, aglyph_offset ); - if ( error ) - goto Fail; - - *astrike = strike; + *astrike = strike; - return TT_Err_Ok; - } - } + return TT_Err_Ok; Fail: /* no embedded bitmap for this glyph in face */ @@ -1353,9 +1367,7 @@ /* */ /* face :: The target face object. */ /* */ - /* x_ppem :: The horizontal resolution in points per EM. */ - /* */ - /* y_ppem :: The vertical resolution in points per EM. */ + /* strike_index :: The current strike index. */ /* */ /* glyph_index :: The current glyph index. */ /* */ @@ -1378,8 +1390,7 @@ /* */ LOCAL_FUNC FT_Error TT_Load_SBit_Image( TT_Face face, - FT_Int x_ppem, - FT_Int y_ppem, + FT_ULong strike_index, FT_UInt glyph_index, FT_UInt load_flags, FT_Stream stream, @@ -1395,7 +1406,7 @@ /* Check whether there is a glyph sbit for the current index */ - error = Find_SBit_Image( face, glyph_index, x_ppem, y_ppem, + error = Find_SBit_Image( face, glyph_index, strike_index, &range, &strike, &glyph_offset ); if ( error ) goto Exit; diff -ur ../freetype2/src/sfnt/ttsbit.h ./freetype2/src/sfnt/ttsbit.h --- ../freetype2/src/sfnt/ttsbit.h Thu Jul 13 23:59:50 2000 +++ ./freetype2/src/sfnt/ttsbit.h Sat Nov 4 23:01:01 2000 @@ -44,9 +44,13 @@ void TT_Free_SBit_Strikes( TT_Face face ); LOCAL_DEF + FT_Error TT_Set_SBit_Strike( TT_Face face, + FT_Int x_ppem, + FT_Int y_ppem, + FT_ULong* astrike_index ); + LOCAL_DEF FT_Error TT_Load_SBit_Image( TT_Face face, - FT_Int x_ppem, - FT_Int y_ppem, + FT_ULong strike_index, FT_UInt glyph_index, FT_UInt load_flags, FT_Stream stream, diff -ur ../freetype2/src/truetype/ttdriver.c ./freetype2/src/truetype/ttdriver.c --- ../freetype2/src/truetype/ttdriver.c Sat Aug 5 07:05:43 2000 +++ ./freetype2/src/truetype/ttdriver.c Sun Nov 5 03:01:58 2000 @@ -225,6 +225,7 @@ } size->ttmetrics.valid = FALSE; + size->sbit_strike.valid = FALSE; return TT_Reset_Size( size ); } @@ -261,6 +262,7 @@ /* many things have been pre-computed by the base layer */ size->ttmetrics.valid = FALSE; + size->sbit_strike.valid = FALSE; return TT_Reset_Size( size ); } diff -ur ../freetype2/src/truetype/ttgload.c ./freetype2/src/truetype/ttgload.c --- ../freetype2/src/truetype/ttgload.c Sun Sep 3 11:47:57 2000 +++ ./freetype2/src/truetype/ttgload.c Sun Nov 5 00:03:53 2000 @@ -1345,18 +1345,24 @@ glyph->num_subglyphs = 0; #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - - /* try to load embedded bitmap if any */ + /* + * try to load embedded bitmap if any + * + * XXX: The convention should be emphasized in + * the documents. Because some application + * developpers confuse. + */ if ( size && - ( load_flags & FT_LOAD_NO_BITMAP ) == 0 && - sfnt->load_sbits ) + size->sbit_strike.valid && + sfnt->load_sbits && + ( load_flags & FT_LOAD_NO_BITMAP ) == 0 ) + { TT_SBit_Metrics metrics; error = sfnt->load_sbit_image( face, - size->root.metrics.x_ppem, - size->root.metrics.y_ppem, + size->sbit_strike.index, glyph_index, load_flags, stream, diff -ur ../freetype2/src/truetype/ttobjs.c ./freetype2/src/truetype/ttobjs.c --- ../freetype2/src/truetype/ttobjs.c Sat Sep 23 21:16:47 2000 +++ ./freetype2/src/truetype/ttobjs.c Sun Nov 5 13:30:25 2000 @@ -450,10 +450,31 @@ #endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */ +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + { + FT_Size_Metrics* sbit_metrics; + TT_SBit_Strike_Index* strike = &size->sbit_strike; + + if ( ALLOC(sbit_metrics, sizeof(FT_Size_Metrics) ) ) + goto Fail_Memory; + + sbit_metrics->x_ppem = 0; + sbit_metrics->y_ppem = 0; + sbit_metrics->x_scale = 0; + sbit_metrics->y_scale = 0; + + size->root.driver.data = (void*)sbit_metrics; + size->root.driver.finalizer = NULL; + + strike->index = 0; + strike->valid = FALSE; + } +#endif + size->ttmetrics.valid = FALSE; return error; -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER +#if defined(TT_CONFIG_OPTION_BYTECODE_INTERPRETER) || defined(TT_CONFIG_OPTION_EMBEDDED_BITMAPS) Fail_Exec: if ( !size->debug ) @@ -520,23 +541,25 @@ #endif size->ttmetrics.valid = FALSE; +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + { + FT_Size_Metrics* sbit_metrics; + + sbit_metrics = (FT_Size_Metrics*)size->root.driver.data; + + FREE( sbit_metrics ); + size->root.driver.data = 0; + size->root.driver.finalizer = NULL; + + size->sbit_strike.index = 0; + size->sbit_strike.valid = FALSE; + } +#endif } - /*************************************************************************/ - /* */ - /* */ - /* TT_Reset_Size */ - /* */ - /* */ - /* Resets a TrueType size when resolutions and character dimensions */ - /* have been changed. */ - /* */ - /* */ - /* size :: A handle to the target size object. */ - /* */ - LOCAL_DEF - FT_Error TT_Reset_Size( TT_Size size ) + static + FT_Error Reset_Outline_Size( TT_Size size ) { TT_Face face; FT_Error error = TT_Err_Ok; @@ -575,46 +598,6 @@ } /* Compute root ascender, descender, test height, and max_advance */ - -#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS - - if ( ( !( face->root.face_flags & FT_FACE_FLAG_SCALABLE ) && - ( face->root.face_flags & FT_FACE_FLAG_FIXED_SIZES ) ) ) - { - FT_Int i; - - - for ( i = 0; i < face->root.num_fixed_sizes; i++ ) - { - if ( ( face->sbit_strikes[i].x_ppem == metrics->x_ppem ) && - ( face->sbit_strikes[i].y_ppem == metrics->y_ppem ) ) - { - /* - * XXX: We now set horizontal metrics, - * but this is not valid if we use vertical layout style - */ - metrics->ascender = - face->sbit_strikes[i].hori.ascender * 64; - metrics->descender = - face->sbit_strikes[i].hori.descender * 64; - metrics->height = - ( face->sbit_strikes[i].hori.ascender - - face->sbit_strikes[i].hori.descender ) * 64; - /* XXX: Is this correct? */ - metrics->max_advance = - ( face->sbit_strikes[i].hori.min_origin_SB + - face->sbit_strikes[i].hori.max_width + - face->sbit_strikes[i].hori.min_advance_SB ) * 64; - break; - } - } - if ( i == face->root.num_fixed_sizes ) - return TT_Err_Invalid_PPem; - } - else - -#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ - { metrics->ascender = ( FT_MulFix( face->root.ascender, metrics->y_scale ) + 32 ) & -64; @@ -708,6 +691,123 @@ return error; } +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + static + FT_Error Reset_SBit_Size( TT_Size size ) + { + TT_Face face; + FT_Error error = TT_Err_Ok; + + FT_ULong strike_index; + FT_Size_Metrics* metrics; + FT_Size_Metrics* sbit_metrics; + SFNT_Interface* sfnt; + + metrics = &size->root.metrics; + + if (size->sbit_strike.valid) + return TT_Err_Ok; + + face = (TT_Face)size->root.face; + sfnt = (SFNT_Interface*)face->sfnt; + + sbit_metrics = (FT_Size_Metrics*)size->root.driver.data; + error = sfnt->set_sbit_strike(face, + metrics->x_ppem, metrics->y_ppem, + &strike_index); + + if (!error) + { + sbit_metrics->x_ppem = metrics->y_ppem; + sbit_metrics->y_ppem = metrics->y_ppem; +#if 0 + /* + * sbit_metrics->?_scale + * are not used now. + */ + sbit_metrics->x_scale = 1 << 16; + sbit_metrics->y_scale = 1 << 16; +#endif + sbit_metrics->ascender = + face->sbit_strikes[strike_index].hori.ascender << 6; + sbit_metrics->descender = + face->sbit_strikes[strike_index].hori.descender << 6; + sbit_metrics->height = + ( face->sbit_strikes[strike_index].hori.ascender - + face->sbit_strikes[strike_index].hori.descender ) << 6; + /* XXX: Is this correct? */ + sbit_metrics->max_advance = + ( face->sbit_strikes[strike_index].hori.min_origin_SB + + face->sbit_strikes[strike_index].hori.max_width + + face->sbit_strikes[strike_index].hori.min_advance_SB ) << 6; + + size->sbit_strike.index = strike_index; + size->sbit_strike.valid = TRUE; + } + else + { + sbit_metrics->x_ppem = 0; + sbit_metrics->y_ppem = 0; + sbit_metrics->ascender = 0; + sbit_metrics->descender = 0; + sbit_metrics->height = 0; + sbit_metrics->max_advance = 0; + + size->sbit_strike.valid = FALSE; + } + + return error; + } +#endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ + + /*************************************************************************/ + /* */ + /* */ + /* TT_Reset_Size */ + /* */ + /* */ + /* Resets a TrueType size when resolutions and character dimensions */ + /* have been changed. */ + /* */ + /* */ + /* size :: A handle to the target size object. */ + /* */ + LOCAL_DEF + FT_Error TT_Reset_Size( TT_Size size ) + { + FT_Face face; + FT_Error error = TT_Err_Ok; + + face = size->root.face; + + if ( face->face_flags & FT_FACE_FLAG_SCALABLE ) + { + if ( !size->ttmetrics.valid ) + error = Reset_Outline_Size( size ); + + if ( error ) + return error; + } + +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + if ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES ) + { + FT_Size_Metrics* sbit_metrics; + + if ( !size->sbit_strike.valid ) + error = Reset_SBit_Size( size ); + + sbit_metrics = (FT_Size_Metrics*)size->root.driver.data; + + if ((!error) && !( face->face_flags & FT_FACE_FLAG_SCALABLE )) + size->root.metrics = *sbit_metrics; + } +#endif + if (face->face_flags & FT_FACE_FLAG_SCALABLE) + return TT_Err_Ok; + else + return error; + } /*************************************************************************/ /* */ diff -ur ../freetype2/src/truetype/ttobjs.h ./freetype2/src/truetype/ttobjs.h --- ../freetype2/src/truetype/ttobjs.h Mon Jul 31 00:43:08 2000 +++ ./freetype2/src/truetype/ttobjs.h Sat Nov 4 23:50:23 2000 @@ -303,6 +303,15 @@ } TT_Size_Metrics; +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + typedef struct TT_SBit_Strike_Index_ + { + FT_ULong index; + + FT_Bool valid; + } TT_SBit_Strike_Index; +#endif + /*************************************************************************/ /* */ /* TrueType size class. */ @@ -312,6 +321,10 @@ FT_SizeRec root; TT_Size_Metrics ttmetrics; + +#ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS + TT_SBit_Strike_Index sbit_strike; +#endif #ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER