[truetype] Store and use design coordinates also.
* include/freetype/internal/services/svmm.h (FT_Get_Var_Blend_Func): Add `normalizedcoords' argument. * src/truetype/ttgxvar.h (GX_BlendRec): Add `coords' field to store the design coordinates of the current instance. Updated. * src/truetype/ttgxvar.c (TT_Set_MM_Blend): Move functionality to... (tt_set_mm_blend): ... New function. Convert data in `normalizedcoords' array to `coords' array on demand. (TT_Set_Var_Design): Store argument data in `coords' array. (TT_Get_Var_Design): Get data from `coords' array. (tt_get_var_blend): Updated. (tt_done_blend): Updated. * src/cff/cffload.c, src/cff/cffload.h (cff_get_var_blend): Updated. * src/cff/cf2ft.c (cf2_getNormalizedVector): Updated. * src/cff/cffobjs.c (cff_face_init): Updated.
This commit is contained in:
parent
8dd9e9675d
commit
5eb0fd5e97
26
ChangeLog
26
ChangeLog
|
@ -1,3 +1,29 @@
|
||||||
|
2017-03-12 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
|
[truetype] Store and use design coordinates also.
|
||||||
|
|
||||||
|
* include/freetype/internal/services/svmm.h (FT_Get_Var_Blend_Func):
|
||||||
|
Add `normalizedcoords' argument.
|
||||||
|
|
||||||
|
* src/truetype/ttgxvar.h (GX_BlendRec): Add `coords' field to store
|
||||||
|
the design coordinates of the current instance.
|
||||||
|
Updated.
|
||||||
|
|
||||||
|
* src/truetype/ttgxvar.c (TT_Set_MM_Blend): Move functionality to...
|
||||||
|
(tt_set_mm_blend): ... New function.
|
||||||
|
Convert data in `normalizedcoords' array to `coords' array on
|
||||||
|
demand.
|
||||||
|
(TT_Set_Var_Design): Store argument data in `coords' array.
|
||||||
|
(TT_Get_Var_Design): Get data from `coords' array.
|
||||||
|
(tt_get_var_blend): Updated.
|
||||||
|
(tt_done_blend): Updated.
|
||||||
|
|
||||||
|
* src/cff/cffload.c, src/cff/cffload.h (cff_get_var_blend): Updated.
|
||||||
|
|
||||||
|
* src/cff/cf2ft.c (cf2_getNormalizedVector): Updated.
|
||||||
|
|
||||||
|
* src/cff/cffobjs.c (cff_face_init): Updated.
|
||||||
|
|
||||||
2017-03-12 Werner Lemberg <wl@gnu.org>
|
2017-03-12 Werner Lemberg <wl@gnu.org>
|
||||||
|
|
||||||
src/truetype/ttgxvar.[ch]: s/avar_checked/avar_loaded/.
|
src/truetype/ttgxvar.[ch]: s/avar_checked/avar_loaded/.
|
||||||
|
|
|
@ -72,6 +72,7 @@ FT_BEGIN_HEADER
|
||||||
(*FT_Get_Var_Blend_Func)( FT_Face face,
|
(*FT_Get_Var_Blend_Func)( FT_Face face,
|
||||||
FT_UInt *num_coords,
|
FT_UInt *num_coords,
|
||||||
FT_Fixed* *coords,
|
FT_Fixed* *coords,
|
||||||
|
FT_Fixed* *normalizedcoords,
|
||||||
FT_MM_Var* *mm_var );
|
FT_MM_Var* *mm_var );
|
||||||
|
|
||||||
typedef void
|
typedef void
|
||||||
|
|
|
@ -457,7 +457,7 @@
|
||||||
FT_ASSERT( decoder && decoder->builder.face );
|
FT_ASSERT( decoder && decoder->builder.face );
|
||||||
FT_ASSERT( vec && len );
|
FT_ASSERT( vec && len );
|
||||||
|
|
||||||
return cff_get_var_blend( decoder->builder.face, len, vec, NULL );
|
return cff_get_var_blend( decoder->builder.face, len, NULL, vec, NULL );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1572,12 +1572,17 @@
|
||||||
cff_get_var_blend( CFF_Face face,
|
cff_get_var_blend( CFF_Face face,
|
||||||
FT_UInt *num_coords,
|
FT_UInt *num_coords,
|
||||||
FT_Fixed* *coords,
|
FT_Fixed* *coords,
|
||||||
|
FT_Fixed* *normalizedcoords,
|
||||||
FT_MM_Var* *mm_var )
|
FT_MM_Var* *mm_var )
|
||||||
{
|
{
|
||||||
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
|
FT_Service_MultiMasters mm = (FT_Service_MultiMasters)face->mm;
|
||||||
|
|
||||||
|
|
||||||
return mm->get_var_blend( FT_FACE( face ), num_coords, coords, mm_var );
|
return mm->get_var_blend( FT_FACE( face ),
|
||||||
|
num_coords,
|
||||||
|
coords,
|
||||||
|
normalizedcoords,
|
||||||
|
mm_var );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,7 @@ FT_BEGIN_HEADER
|
||||||
cff_get_var_blend( CFF_Face face,
|
cff_get_var_blend( CFF_Face face,
|
||||||
FT_UInt *num_coords,
|
FT_UInt *num_coords,
|
||||||
FT_Fixed* *coords,
|
FT_Fixed* *coords,
|
||||||
|
FT_Fixed* *normalizedcoords,
|
||||||
FT_MM_Var* *mm_var );
|
FT_MM_Var* *mm_var );
|
||||||
|
|
||||||
FT_LOCAL( void )
|
FT_LOCAL( void )
|
||||||
|
|
|
@ -703,7 +703,7 @@
|
||||||
if ( error )
|
if ( error )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
mm->get_var_blend( cffface, NULL, NULL, &mm_var );
|
mm->get_var_blend( cffface, NULL, NULL, NULL, &mm_var );
|
||||||
|
|
||||||
if ( mm_var->namedstyle )
|
if ( mm_var->namedstyle )
|
||||||
{
|
{
|
||||||
|
|
|
@ -2259,35 +2259,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
static FT_Error
|
||||||
/* */
|
tt_set_mm_blend( TT_Face face,
|
||||||
/* <Function> */
|
|
||||||
/* TT_Set_MM_Blend */
|
|
||||||
/* */
|
|
||||||
/* <Description> */
|
|
||||||
/* Set the blend (normalized) coordinates for this instance of the */
|
|
||||||
/* font. Check that the `gvar' table is reasonable and does some */
|
|
||||||
/* initial preparation. */
|
|
||||||
/* */
|
|
||||||
/* <InOut> */
|
|
||||||
/* face :: The font. */
|
|
||||||
/* Initialize the blend structure with `gvar' data. */
|
|
||||||
/* */
|
|
||||||
/* <Input> */
|
|
||||||
/* num_coords :: The number of available coordinates. If it is */
|
|
||||||
/* larger than the number of axes, ignore the excess */
|
|
||||||
/* values. If it is smaller than the number of axes, */
|
|
||||||
/* use the default value (0) for the remaining axes. */
|
|
||||||
/* */
|
|
||||||
/* coords :: An array of `num_coords', each between [-1,1]. */
|
|
||||||
/* */
|
|
||||||
/* <Return> */
|
|
||||||
/* FreeType error code. 0 means success. */
|
|
||||||
/* */
|
|
||||||
FT_LOCAL_DEF( FT_Error )
|
|
||||||
TT_Set_MM_Blend( TT_Face face,
|
|
||||||
FT_UInt num_coords,
|
FT_UInt num_coords,
|
||||||
FT_Fixed* coords )
|
FT_Fixed* coords,
|
||||||
|
FT_Bool set_design_coords )
|
||||||
{
|
{
|
||||||
FT_Error error = FT_Err_Ok;
|
FT_Error error = FT_Err_Ok;
|
||||||
GX_Blend blend;
|
GX_Blend blend;
|
||||||
|
@ -2318,7 +2294,8 @@
|
||||||
|
|
||||||
if ( num_coords > mmvar->num_axis )
|
if ( num_coords > mmvar->num_axis )
|
||||||
{
|
{
|
||||||
FT_TRACE2(( "TT_Set_MM_Blend: only using first %d of %d coordinates\n",
|
FT_TRACE2(( "TT_Set_MM_Blend:"
|
||||||
|
" only using first %d of %d coordinates\n",
|
||||||
mmvar->num_axis, num_coords ));
|
mmvar->num_axis, num_coords ));
|
||||||
num_coords = mmvar->num_axis;
|
num_coords = mmvar->num_axis;
|
||||||
}
|
}
|
||||||
|
@ -2347,6 +2324,12 @@
|
||||||
if ( FT_SET_ERROR( ft_var_load_gvar( face ) ) )
|
if ( FT_SET_ERROR( ft_var_load_gvar( face ) ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
|
if ( !blend->coords )
|
||||||
|
{
|
||||||
|
if ( FT_NEW_ARRAY( blend->coords, mmvar->num_axis ) )
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !blend->normalizedcoords )
|
if ( !blend->normalizedcoords )
|
||||||
{
|
{
|
||||||
if ( FT_NEW_ARRAY( blend->normalizedcoords, mmvar->num_axis ) )
|
if ( FT_NEW_ARRAY( blend->normalizedcoords, mmvar->num_axis ) )
|
||||||
|
@ -2391,6 +2374,12 @@
|
||||||
coords,
|
coords,
|
||||||
num_coords * sizeof ( FT_Fixed ) );
|
num_coords * sizeof ( FT_Fixed ) );
|
||||||
|
|
||||||
|
if ( set_design_coords )
|
||||||
|
ft_var_to_design( face,
|
||||||
|
num_coords,
|
||||||
|
blend->normalizedcoords,
|
||||||
|
blend->coords );
|
||||||
|
|
||||||
face->doblend = TRUE;
|
face->doblend = TRUE;
|
||||||
|
|
||||||
if ( face->cvt )
|
if ( face->cvt )
|
||||||
|
@ -2449,6 +2438,40 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* <Function> */
|
||||||
|
/* TT_Set_MM_Blend */
|
||||||
|
/* */
|
||||||
|
/* <Description> */
|
||||||
|
/* Set the blend (normalized) coordinates for this instance of the */
|
||||||
|
/* font. Check that the `gvar' table is reasonable and does some */
|
||||||
|
/* initial preparation. */
|
||||||
|
/* */
|
||||||
|
/* <InOut> */
|
||||||
|
/* face :: The font. */
|
||||||
|
/* Initialize the blend structure with `gvar' data. */
|
||||||
|
/* */
|
||||||
|
/* <Input> */
|
||||||
|
/* num_coords :: The number of available coordinates. If it is */
|
||||||
|
/* larger than the number of axes, ignore the excess */
|
||||||
|
/* values. If it is smaller than the number of axes, */
|
||||||
|
/* use the default value (0) for the remaining axes. */
|
||||||
|
/* */
|
||||||
|
/* coords :: An array of `num_coords', each between [-1,1]. */
|
||||||
|
/* */
|
||||||
|
/* <Return> */
|
||||||
|
/* FreeType error code. 0 means success. */
|
||||||
|
/* */
|
||||||
|
FT_LOCAL_DEF( FT_Error )
|
||||||
|
TT_Set_MM_Blend( TT_Face face,
|
||||||
|
FT_UInt num_coords,
|
||||||
|
FT_Fixed* coords )
|
||||||
|
{
|
||||||
|
return tt_set_mm_blend( face, num_coords, coords, 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************/
|
/*************************************************************************/
|
||||||
/* */
|
/* */
|
||||||
/* <Function> */
|
/* <Function> */
|
||||||
|
@ -2493,7 +2516,8 @@
|
||||||
nc = num_coords;
|
nc = num_coords;
|
||||||
if ( num_coords > blend->num_axis )
|
if ( num_coords > blend->num_axis )
|
||||||
{
|
{
|
||||||
FT_TRACE2(( "TT_Get_MM_Blend: only using first %d of %d coordinates\n",
|
FT_TRACE2(( "TT_Get_MM_Blend:"
|
||||||
|
" only using first %d of %d coordinates\n",
|
||||||
blend->num_axis, num_coords ));
|
blend->num_axis, num_coords ));
|
||||||
nc = blend->num_axis;
|
nc = blend->num_axis;
|
||||||
}
|
}
|
||||||
|
@ -2546,11 +2570,16 @@
|
||||||
FT_UInt num_coords,
|
FT_UInt num_coords,
|
||||||
FT_Fixed* coords )
|
FT_Fixed* coords )
|
||||||
{
|
{
|
||||||
FT_Error error = FT_Err_Ok;
|
FT_Error error = FT_Err_Ok;
|
||||||
FT_Memory memory = face->root.memory;
|
GX_Blend blend;
|
||||||
|
FT_MM_Var* mmvar;
|
||||||
|
FT_UInt i;
|
||||||
|
FT_Memory memory = face->root.memory;
|
||||||
|
|
||||||
|
FT_Var_Axis* a;
|
||||||
|
FT_Fixed* c;
|
||||||
|
|
||||||
FT_Fixed* normalized = NULL;
|
FT_Fixed* normalized = NULL;
|
||||||
FT_UInt num_axes;
|
|
||||||
|
|
||||||
|
|
||||||
if ( !face->blend )
|
if ( !face->blend )
|
||||||
|
@ -2559,9 +2588,33 @@
|
||||||
goto Exit;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
num_axes = face->blend->mmvar->num_axis;
|
blend = face->blend;
|
||||||
|
mmvar = blend->mmvar;
|
||||||
|
|
||||||
if ( FT_NEW_ARRAY( normalized, num_axes ) )
|
if ( num_coords > mmvar->num_axis )
|
||||||
|
{
|
||||||
|
FT_TRACE2(( "TT_Set_Var_Design:"
|
||||||
|
" only using first %d of %d coordinates\n",
|
||||||
|
mmvar->num_axis, num_coords ));
|
||||||
|
num_coords = mmvar->num_axis;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !blend->coords )
|
||||||
|
{
|
||||||
|
if ( FT_NEW_ARRAY( blend->coords, mmvar->num_axis ) )
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
FT_MEM_COPY( blend->coords,
|
||||||
|
coords,
|
||||||
|
num_coords * sizeof ( FT_Fixed ) );
|
||||||
|
|
||||||
|
a = mmvar->axis + num_coords;
|
||||||
|
c = coords + num_coords;
|
||||||
|
for ( i = num_coords; i < mmvar->num_axis; i++, a++, c++ )
|
||||||
|
*c = a->def;
|
||||||
|
|
||||||
|
if ( FT_NEW_ARRAY( normalized, mmvar->num_axis ) )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
if ( !face->blend->avar_loaded )
|
if ( !face->blend->avar_loaded )
|
||||||
|
@ -2569,7 +2622,7 @@
|
||||||
|
|
||||||
ft_var_to_normalized( face, num_coords, coords, normalized );
|
ft_var_to_normalized( face, num_coords, coords, normalized );
|
||||||
|
|
||||||
error = TT_Set_MM_Blend( face, num_axes, normalized );
|
error = tt_set_mm_blend( face, mmvar->num_axis, normalized, 0 );
|
||||||
|
|
||||||
Exit:
|
Exit:
|
||||||
FT_FREE( normalized );
|
FT_FREE( normalized );
|
||||||
|
@ -2605,6 +2658,8 @@
|
||||||
FT_Fixed* coords )
|
FT_Fixed* coords )
|
||||||
{
|
{
|
||||||
FT_Error error = FT_Err_Ok;
|
FT_Error error = FT_Err_Ok;
|
||||||
|
GX_Blend blend;
|
||||||
|
FT_UInt i, nc;
|
||||||
|
|
||||||
|
|
||||||
if ( !face->blend )
|
if ( !face->blend )
|
||||||
|
@ -2613,13 +2668,30 @@
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !face->blend->avar_loaded )
|
blend = face->blend;
|
||||||
ft_var_load_avar( face );
|
|
||||||
|
|
||||||
ft_var_to_design( face,
|
nc = num_coords;
|
||||||
num_coords,
|
if ( num_coords > blend->num_axis )
|
||||||
face->blend->normalizedcoords,
|
{
|
||||||
coords );
|
FT_TRACE2(( "TT_Get_Var_Design:"
|
||||||
|
" only using first %d of %d coordinates\n",
|
||||||
|
blend->num_axis, num_coords ));
|
||||||
|
nc = blend->num_axis;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( face->doblend )
|
||||||
|
{
|
||||||
|
for ( i = 0; i < nc; i++ )
|
||||||
|
coords[i] = blend->coords[i];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for ( i = 0; i < nc; i++ )
|
||||||
|
coords[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( ; i < num_coords; i++ )
|
||||||
|
coords[i] = 0;
|
||||||
|
|
||||||
return FT_Err_Ok;
|
return FT_Err_Ok;
|
||||||
}
|
}
|
||||||
|
@ -3506,16 +3578,19 @@
|
||||||
tt_get_var_blend( TT_Face face,
|
tt_get_var_blend( TT_Face face,
|
||||||
FT_UInt *num_coords,
|
FT_UInt *num_coords,
|
||||||
FT_Fixed* *coords,
|
FT_Fixed* *coords,
|
||||||
|
FT_Fixed* *normalizedcoords,
|
||||||
FT_MM_Var* *mm_var )
|
FT_MM_Var* *mm_var )
|
||||||
{
|
{
|
||||||
if ( face->blend )
|
if ( face->blend )
|
||||||
{
|
{
|
||||||
if ( num_coords )
|
if ( num_coords )
|
||||||
*num_coords = face->blend->num_axis;
|
*num_coords = face->blend->num_axis;
|
||||||
if ( coords )
|
if ( coords )
|
||||||
*coords = face->blend->normalizedcoords;
|
*coords = face->blend->coords;
|
||||||
|
if ( normalizedcoords )
|
||||||
|
*normalizedcoords = face->blend->normalizedcoords;
|
||||||
if ( mm_var )
|
if ( mm_var )
|
||||||
*mm_var = face->blend->mmvar;
|
*mm_var = face->blend->mmvar;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3583,6 +3658,7 @@
|
||||||
/* blend->num_axis might not be set up yet */
|
/* blend->num_axis might not be set up yet */
|
||||||
num_axes = blend->mmvar->num_axis;
|
num_axes = blend->mmvar->num_axis;
|
||||||
|
|
||||||
|
FT_FREE( blend->coords );
|
||||||
FT_FREE( blend->normalizedcoords );
|
FT_FREE( blend->normalizedcoords );
|
||||||
FT_FREE( blend->normalized_stylecoords );
|
FT_FREE( blend->normalized_stylecoords );
|
||||||
FT_FREE( blend->mmvar );
|
FT_FREE( blend->mmvar );
|
||||||
|
|
|
@ -220,6 +220,11 @@ FT_BEGIN_HEADER
|
||||||
/* num_axis :: */
|
/* num_axis :: */
|
||||||
/* The number of axes along which interpolation may happen. */
|
/* The number of axes along which interpolation may happen. */
|
||||||
/* */
|
/* */
|
||||||
|
/* coords :: */
|
||||||
|
/* An array of design coordinates (in user space) indicating the */
|
||||||
|
/* contribution along each axis to the final interpolated font. */
|
||||||
|
/* `normalizedcoords' holds the same values. */
|
||||||
|
/* */
|
||||||
/* normalizedcoords :: */
|
/* normalizedcoords :: */
|
||||||
/* An array of normalized values (between [-1,1]) indicating the */
|
/* An array of normalized values (between [-1,1]) indicating the */
|
||||||
/* contribution along each axis to the final interpolated font. */
|
/* contribution along each axis to the final interpolated font. */
|
||||||
|
@ -294,6 +299,7 @@ FT_BEGIN_HEADER
|
||||||
typedef struct GX_BlendRec_
|
typedef struct GX_BlendRec_
|
||||||
{
|
{
|
||||||
FT_UInt num_axis;
|
FT_UInt num_axis;
|
||||||
|
FT_Fixed* coords;
|
||||||
FT_Fixed* normalizedcoords;
|
FT_Fixed* normalizedcoords;
|
||||||
|
|
||||||
FT_MM_Var* mmvar;
|
FT_MM_Var* mmvar;
|
||||||
|
@ -423,6 +429,7 @@ FT_BEGIN_HEADER
|
||||||
tt_get_var_blend( TT_Face face,
|
tt_get_var_blend( TT_Face face,
|
||||||
FT_UInt *num_coords,
|
FT_UInt *num_coords,
|
||||||
FT_Fixed* *coords,
|
FT_Fixed* *coords,
|
||||||
|
FT_Fixed* *normalizedcoords,
|
||||||
FT_MM_Var* *mm_var );
|
FT_MM_Var* *mm_var );
|
||||||
|
|
||||||
FT_LOCAL( void )
|
FT_LOCAL( void )
|
||||||
|
|
Loading…
Reference in New Issue