< prev index next >

src/java.desktop/share/native/libfreetype/src/truetype/ttgload.c

Print this page

        

*** 80,89 **** --- 80,98 ---- #define OVERLAP_COMPOUND 0x0400 /* we ignore this value */ #define SCALED_COMPONENT_OFFSET 0x0800 #define UNSCALED_COMPONENT_OFFSET 0x1000 + #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + #define IS_DEFAULT_INSTANCE( _face ) \ + ( !( FT_IS_NAMED_INSTANCE( _face ) || \ + FT_IS_VARIATION( _face ) ) ) + #else + #define IS_DEFAULT_INSTANCE( _face ) 1 + #endif + + /************************************************************************** * * Return the horizontal metrics in font units for a given glyph. */ FT_LOCAL_DEF( void )
*** 925,934 **** --- 934,948 ---- FT_GlyphLoader gloader = loader->gloader; FT_Error error = FT_Err_Ok; FT_Outline* outline; FT_Int n_points; + #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Memory memory = loader->face->root.memory; + FT_Vector* unrounded = NULL; + #endif + outline = &gloader->current.outline; n_points = outline->n_points; /* set phantom points */
*** 945,974 **** n_points += 4; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT ! if ( FT_IS_NAMED_INSTANCE( FT_FACE( loader->face ) ) || ! FT_IS_VARIATION( FT_FACE( loader->face ) ) ) { /* Deltas apply to the unscaled data. */ error = TT_Vary_Apply_Glyph_Deltas( loader->face, loader->glyph_index, outline, (FT_UInt)n_points ); /* recalculate linear horizontal and vertical advances */ /* if we don't have HVAR and VVAR, respectively */ if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) ! loader->linear = outline->points[n_points - 3].x - ! outline->points[n_points - 4].x; if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) ! loader->vadvance = outline->points[n_points - 1].x - ! outline->points[n_points - 2].x; if ( error ) ! return error; } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ if ( IS_HINTED( loader->load_flags ) ) --- 959,994 ---- n_points += 4; #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT ! if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) ) { + if ( FT_NEW_ARRAY( unrounded, n_points ) ) + goto Exit; + /* Deltas apply to the unscaled data. */ error = TT_Vary_Apply_Glyph_Deltas( loader->face, loader->glyph_index, outline, + unrounded, (FT_UInt)n_points ); /* recalculate linear horizontal and vertical advances */ /* if we don't have HVAR and VVAR, respectively */ + + /* XXX: change all FreeType modules to store `linear' and `vadvance' */ + /* in 26.6 format before the `base' module scales them to 16.16 */ if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) ! loader->linear = FT_PIX_ROUND( unrounded[n_points - 3].x - ! unrounded[n_points - 4].x ) / 64; if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) ! loader->vadvance = FT_PIX_ROUND( unrounded[n_points - 1].x - ! unrounded[n_points - 2].x ) / 64; if ( error ) ! goto Exit; } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ if ( IS_HINTED( loader->load_flags ) )
*** 1019,1032 **** --- 1039,1065 ---- y_scale = loader->size->metrics->y_scale; /* compensate for any scaling by de/emboldening; */ /* the amount was determined via experimentation */ if ( x_scale_factor != 1000 && ppem > 11 ) + { + #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + FT_Vector* orig_points = outline->points; + + + if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) ) + outline->points = unrounded; + #endif FT_Outline_EmboldenXY( outline, FT_MulFix( 1280 * ppem, 1000 - x_scale_factor ), 0 ); + #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) ) + outline->points = orig_points; + #endif + } do_scale = TRUE; } } else
*** 1043,1058 **** --- 1076,1107 ---- } } if ( do_scale ) { + #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + if ( !IS_DEFAULT_INSTANCE( FT_FACE( loader->face ) ) ) + { + FT_Vector* u = unrounded; + + + for ( ; vec < limit; vec++, u++ ) + { + vec->x = ( FT_MulFix( u->x, x_scale ) + 32 ) >> 6; + vec->y = ( FT_MulFix( u->y, y_scale ) + 32 ) >> 6; + } + } + else + #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ + { for ( ; vec < limit; vec++ ) { vec->x = FT_MulFix( vec->x, x_scale ); vec->y = FT_MulFix( vec->y, y_scale ); } } + } #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT /* if we have a HVAR table, `pp1' and/or `pp2' are already adjusted */ if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) || !IS_HINTED( loader->load_flags ) )
*** 1078,1087 **** --- 1127,1141 ---- loader->zone.n_points += 4; error = TT_Hint_Glyph( loader, 0 ); } + #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT + Exit: + FT_FREE( unrounded ); + #endif + return error; } /**************************************************************************
*** 1679,1688 **** --- 1733,1745 ---- FT_Vector points[4]; char tags[4] = { 1, 1, 1, 1 }; short contours[4] = { 0, 1, 2, 3 }; FT_Outline outline; + /* unrounded values */ + FT_Vector unrounded[4] = { {0, 0}, {0, 0}, {0, 0}, {0, 0} }; + points[0].x = loader->pp1.x; points[0].y = loader->pp1.y; points[1].x = loader->pp2.x; points[1].y = loader->pp2.y;
*** 1700,1709 **** --- 1757,1767 ---- /* this must be done before scaling */ error = TT_Vary_Apply_Glyph_Deltas( loader->face, glyph_index, &outline, + unrounded, (FT_UInt)outline.n_points ); if ( error ) goto Exit; loader->pp1.x = points[0].x;
*** 1717,1729 **** loader->pp4.y = points[3].y; /* recalculate linear horizontal and vertical advances */ /* if we don't have HVAR and VVAR, respectively */ if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) ! loader->linear = loader->pp2.x - loader->pp1.x; if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) ! loader->vadvance = loader->pp4.x - loader->pp3.x; } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ /* scale phantom points, if necessary; */ --- 1775,1789 ---- loader->pp4.y = points[3].y; /* recalculate linear horizontal and vertical advances */ /* if we don't have HVAR and VVAR, respectively */ if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) ! loader->linear = FT_PIX_ROUND( unrounded[1].x - ! unrounded[0].x ) / 64; if ( !( loader->face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) ! loader->vadvance = FT_PIX_ROUND( unrounded[3].x - ! unrounded[2].x ) / 64; } #endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */ /* scale phantom points, if necessary; */
*** 1862,1871 **** --- 1922,1932 ---- FT_Outline outline; FT_Vector* points = NULL; char* tags = NULL; short* contours = NULL; + FT_Vector* unrounded = NULL; limit = (short)gloader->current.num_subglyphs; /* construct an outline structure for */
*** 1877,1887 **** outline.tags = NULL; outline.contours = NULL; if ( FT_NEW_ARRAY( points, outline.n_points ) || FT_NEW_ARRAY( tags, outline.n_points ) || ! FT_NEW_ARRAY( contours, outline.n_points ) ) goto Exit1; subglyph = gloader->current.subglyphs; for ( i = 0; i < limit; i++, subglyph++ ) --- 1938,1949 ---- outline.tags = NULL; outline.contours = NULL; if ( FT_NEW_ARRAY( points, outline.n_points ) || FT_NEW_ARRAY( tags, outline.n_points ) || ! FT_NEW_ARRAY( contours, outline.n_points ) || ! FT_NEW_ARRAY( unrounded, outline.n_points ) ) goto Exit1; subglyph = gloader->current.subglyphs; for ( i = 0; i < limit; i++, subglyph++ )
*** 1926,1935 **** --- 1988,1998 ---- /* for each component's translation */ if ( FT_SET_ERROR( TT_Vary_Apply_Glyph_Deltas( face, glyph_index, &outline, + unrounded, (FT_UInt)outline.n_points ) ) ) goto Exit1; subglyph = gloader->current.subglyphs;
*** 1953,1970 **** loader->pp4.y = points[i + 3].y; /* recalculate linear horizontal and vertical advances */ /* if we don't have HVAR and VVAR, respectively */ if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) ! loader->linear = loader->pp2.x - loader->pp1.x; if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) ! loader->vadvance = loader->pp4.x - loader->pp3.x; Exit1: FT_FREE( outline.points ); FT_FREE( outline.tags ); FT_FREE( outline.contours ); if ( error ) goto Exit; } --- 2016,2038 ---- loader->pp4.y = points[i + 3].y; /* recalculate linear horizontal and vertical advances */ /* if we don't have HVAR and VVAR, respectively */ if ( !( face->variation_support & TT_FACE_FLAG_VAR_HADVANCE ) ) ! loader->linear = ! FT_PIX_ROUND( unrounded[outline.n_points - 3].x - ! unrounded[outline.n_points - 4].x ) / 64; if ( !( face->variation_support & TT_FACE_FLAG_VAR_VADVANCE ) ) ! loader->vadvance = ! FT_PIX_ROUND( unrounded[outline.n_points - 1].x - ! unrounded[outline.n_points - 2].x ) / 64; Exit1: FT_FREE( outline.points ); FT_FREE( outline.tags ); FT_FREE( outline.contours ); + FT_FREE( unrounded ); if ( error ) goto Exit; }
*** 2086,2095 **** --- 2154,2164 ---- /* process the glyph */ loader->ins_pos = ins_pos; if ( IS_HINTED( loader->load_flags ) && #ifdef TT_USE_BYTECODE_INTERPRETER + subglyph && subglyph->flags & WE_HAVE_INSTR && #endif num_points > start_point ) { error = TT_Process_Composite_Glyph( loader,
*** 2609,2623 **** } } if ( reexecute ) { - FT_UInt i; - - - for ( i = 0; i < size->cvt_size; i++ ) - size->cvt[i] = FT_MulFix( face->cvt[i], size->ttmetrics.scale ); error = tt_size_run_prep( size, pedantic ); if ( error ) return error; } --- 2678,2687 ----
*** 2716,2741 **** FT_Int32 load_flags ) { FT_Error error; TT_LoaderRec loader; - #ifdef TT_CONFIG_OPTION_GX_VAR_SUPPORT - #define IS_DEFAULT_INSTANCE ( !( FT_IS_NAMED_INSTANCE( glyph->face ) || \ - FT_IS_VARIATION( glyph->face ) ) ) - #else - #define IS_DEFAULT_INSTANCE 1 - #endif - FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index )); #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS /* try to load embedded bitmap (if any) */ if ( size->strike_index != 0xFFFFFFFFUL && ( load_flags & FT_LOAD_NO_BITMAP ) == 0 && ! IS_DEFAULT_INSTANCE ) { FT_Fixed x_scale = size->root.metrics.x_scale; FT_Fixed y_scale = size->root.metrics.y_scale; --- 2780,2798 ---- FT_Int32 load_flags ) { FT_Error error; TT_LoaderRec loader; FT_TRACE1(( "TT_Load_Glyph: glyph index %d\n", glyph_index )); #ifdef TT_CONFIG_OPTION_EMBEDDED_BITMAPS /* try to load embedded bitmap (if any) */ if ( size->strike_index != 0xFFFFFFFFUL && ( load_flags & FT_LOAD_NO_BITMAP ) == 0 && ! IS_DEFAULT_INSTANCE( glyph->face ) ) { FT_Fixed x_scale = size->root.metrics.x_scale; FT_Fixed y_scale = size->root.metrics.y_scale;
< prev index next >