static FT_Error tt_size_request( FT_Size size, FT_Size_Request req ) { TT_Size ttsize = (TT_Size)size; FT_Error error = TT_Err_Ok; #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS if ( FT_HAS_FIXED_SIZES( size->face ) ) { TT_Face ttface = (TT_Face)size->face; SFNT_Service sfnt = (SFNT_Service) ttface->sfnt; FT_ULong strike_index; error = sfnt->set_sbit_strike( ttface, req, &strike_index ); if ( error ) ttsize->strike_index = 0xFFFFFFFFUL; else return tt_size_select( size, strike_index ); } #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ FT_Request_Metrics( size->face, req ); if ( FT_IS_SCALABLE( size->face ) ) error = tt_size_reset( ttsize ); return error; }
static FT_Error tt_size_request( FT_Size size, FT_Size_Request req ) { TT_Size ttsize = (TT_Size)size; FT_Error error = FT_Err_Ok; #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS if ( FT_HAS_FIXED_SIZES( size->face ) ) { TT_Face ttface = (TT_Face)size->face; SFNT_Service sfnt = (SFNT_Service)ttface->sfnt; FT_ULong strike_index; error = sfnt->set_sbit_strike( ttface, req, &strike_index ); if ( error ) ttsize->strike_index = 0xFFFFFFFFUL; else return tt_size_select( size, strike_index ); } #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ FT_Request_Metrics( size->face, req ); if ( FT_IS_SCALABLE( size->face ) ) { error = tt_size_reset( ttsize ); ttsize->root.metrics = ttsize->metrics; #ifdef TT_USE_BYTECODE_INTERPRETER /* for the `MPS' bytecode instruction we need the point size */ { FT_UInt resolution = ttsize->metrics.x_ppem > ttsize->metrics.y_ppem ? req->horiResolution : req->vertResolution; /* if we don't have a resolution value, assume 72dpi */ if ( req->type == FT_SIZE_REQUEST_TYPE_SCALES || !resolution ) resolution = 72; ttsize->point_size = FT_MulDiv( ttsize->ttmetrics.ppem, 64 * 72, resolution ); } #endif } return error; }
cff_size_request( FT_Size size, FT_Size_Request req ) { CFF_Size cffsize = (CFF_Size)size; PSH_Globals_Funcs funcs; #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS if ( FT_HAS_FIXED_SIZES( size->face ) ) { CFF_Face cffface = (CFF_Face)size->face; SFNT_Service sfnt = (SFNT_Service)cffface->sfnt; FT_ULong strike_index; if ( sfnt->set_sbit_strike( cffface, req, &strike_index ) ) cffsize->strike_index = 0xFFFFFFFFUL; else return cff_size_select( size, strike_index ); } #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */ FT_Request_Metrics( size->face, req ); funcs = cff_size_get_globals_funcs( cffsize ); if ( funcs ) { CFF_Face cffface = (CFF_Face)size->face; CFF_Font font = (CFF_Font)cffface->extra.data; CFF_Internal internal = (CFF_Internal)size->internal; FT_ULong top_upm = font->top_font.font_dict.units_per_em; FT_UInt i; funcs->set_scale( internal->topfont, size->metrics.x_scale, size->metrics.y_scale, 0, 0 ); for ( i = font->num_subfonts; i > 0; i-- ) { CFF_SubFont sub = font->subfonts[i - 1]; FT_ULong sub_upm = sub->font_dict.units_per_em; FT_Pos x_scale, y_scale; if ( top_upm != sub_upm ) { x_scale = FT_MulDiv( size->metrics.x_scale, top_upm, sub_upm ); y_scale = FT_MulDiv( size->metrics.y_scale, top_upm, sub_upm ); } else { x_scale = size->metrics.x_scale; y_scale = size->metrics.y_scale; } funcs->set_scale( internal->subfonts[i - 1], x_scale, y_scale, 0, 0 ); } } return FT_Err_Ok; }
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_Service sfnt; metrics = &size->metrics; if ( size->strike_index != 0xFFFFU ) return TT_Err_Ok; face = (TT_Face)size->root.face; sfnt = (SFNT_Service)face->sfnt; sbit_metrics = &size->strike_metrics; error = sfnt->set_sbit_strike( face, metrics->x_ppem, metrics->y_ppem, &strike_index ); if ( !error ) { /* XXX: TODO: move this code to the SFNT module where it belongs */ #ifdef FT_OPTIMIZE_MEMORY FT_Byte* strike = face->sbit_table + 8 + strike_index*48; sbit_metrics->ascender = (FT_Char)strike[16] << 6; /* hori.ascender */ sbit_metrics->descender = (FT_Char)strike[17] << 6; /* hori.descender */ /* XXX: Is this correct? */ sbit_metrics->max_advance = ( (FT_Char)strike[22] + /* min_origin_SB */ strike[18] + /* max_width */ (FT_Char)strike[23] /* min_advance_SB */ ) << 6; #else /* !FT_OPTIMIZE_MEMORY */ TT_SBit_Strike strike = face->sbit_strikes + strike_index; sbit_metrics->ascender = strike->hori.ascender << 6; sbit_metrics->descender = strike->hori.descender << 6; /* XXX: Is this correct? */ sbit_metrics->max_advance = ( strike->hori.min_origin_SB + strike->hori.max_width + strike->hori.min_advance_SB ) << 6; #endif /* !FT_OPTIMIZE_MEMORY */ /* XXX: Is this correct? */ sbit_metrics->height = sbit_metrics->ascender - sbit_metrics->descender; sbit_metrics->x_ppem = metrics->x_ppem; sbit_metrics->y_ppem = metrics->y_ppem; size->strike_index = (FT_UInt)strike_index; } else { size->strike_index = 0xFFFFU; 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; } return error; }
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_Service sfnt; metrics = &size->root.metrics; if ( size->strike_index != 0xFFFFU ) return TT_Err_Ok; face = (TT_Face)size->root.face; sfnt = (SFNT_Service)face->sfnt; sbit_metrics = &size->strike_metrics; error = sfnt->set_sbit_strike(face, metrics->x_ppem, metrics->y_ppem, &strike_index); if ( !error ) { TT_SBit_Strike strike = face->sbit_strikes + strike_index; sbit_metrics->x_ppem = metrics->x_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 = strike->hori.ascender << 6; sbit_metrics->descender = strike->hori.descender << 6; /* XXX: Is this correct? */ sbit_metrics->height = sbit_metrics->ascender - sbit_metrics->descender; /* XXX: Is this correct? */ sbit_metrics->max_advance = ( strike->hori.min_origin_SB + strike->hori.max_width + strike->hori.min_advance_SB ) << 6; size->strike_index = strike_index; } else { size->strike_index = 0xFFFFU; 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; } return error; }