[truetype] Provide metrics variation service.
* include/freetype/internal/services/svmetric.h (FT_Metrics_Adjust_Func): Reduce number of necessary parameters. * src/truetype/ttgxvar.c: Include FT_LIST_H. (tt_size_reset_iterator): New auxiliary function for... (tt_apply_var): New function. * src/truetype/ttgxvar.h: Updated. * src/truetype/ttdriver.c (tt_service_metrics_variations): Add `tt_apply_mvar'. * include/freetype/internal/ftserv.h (FT_ServiceCache): Add metrics variation service.
This commit is contained in:
parent
07ee1d250c
commit
d718ac4ead
19
ChangeLog
19
ChangeLog
@ -1,3 +1,22 @@
|
||||
2017-01-11 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
[truetype] Provide metrics variation service.
|
||||
|
||||
* include/freetype/internal/services/svmetric.h
|
||||
(FT_Metrics_Adjust_Func): Reduce number of necessary parameters.
|
||||
|
||||
* src/truetype/ttgxvar.c: Include FT_LIST_H.
|
||||
(tt_size_reset_iterator): New auxiliary function for...
|
||||
(tt_apply_var): New function.
|
||||
|
||||
* src/truetype/ttgxvar.h: Updated.
|
||||
|
||||
* src/truetype/ttdriver.c (tt_service_metrics_variations): Add
|
||||
`tt_apply_mvar'.
|
||||
|
||||
* include/freetype/internal/ftserv.h (FT_ServiceCache): Add metrics
|
||||
variation service.
|
||||
|
||||
2017-01-11 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
[truetype] Parse `MVAR' table.
|
||||
|
@ -714,6 +714,7 @@ FT_BEGIN_HEADER
|
||||
{
|
||||
FT_Pointer service_POSTSCRIPT_FONT_NAME;
|
||||
FT_Pointer service_MULTI_MASTERS;
|
||||
FT_Pointer service_METRICS_VARIATIONS;
|
||||
FT_Pointer service_GLYPH_DICT;
|
||||
FT_Pointer service_PFR_METRICS;
|
||||
FT_Pointer service_WINFNT;
|
||||
|
@ -74,10 +74,8 @@ FT_BEGIN_HEADER
|
||||
|
||||
/* MVAR */
|
||||
|
||||
typedef FT_Error
|
||||
(*FT_Metrics_Adjust_Func)( FT_Face face,
|
||||
FT_ULong tag,
|
||||
FT_Int *avalue );
|
||||
typedef void
|
||||
(*FT_Metrics_Adjust_Func)( FT_Face face );
|
||||
|
||||
|
||||
FT_DEFINE_SERVICE( MetricsVariations )
|
||||
|
@ -507,7 +507,7 @@
|
||||
(FT_BSB_Adjust_Func) NULL, /* bsb_adjust */
|
||||
(FT_VOrg_Adjust_Func) NULL, /* vorg_adjust */
|
||||
|
||||
(FT_Metrics_Adjust_Func) NULL /* metrics_adjust */
|
||||
(FT_Metrics_Adjust_Func) tt_apply_mvar /* metrics_adjust */
|
||||
)
|
||||
|
||||
#endif /* TT_CONFIG_OPTION_GX_VAR_SUPPORT */
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include FT_INTERNAL_SFNT_H
|
||||
#include FT_TRUETYPE_TAGS_H
|
||||
#include FT_MULTIPLE_MASTERS_H
|
||||
#include FT_LIST_H
|
||||
|
||||
#include "ttpload.h"
|
||||
#include "ttgxvar.h"
|
||||
@ -1175,6 +1176,102 @@
|
||||
}
|
||||
|
||||
|
||||
static FT_Error
|
||||
tt_size_reset_iterator( FT_ListNode node,
|
||||
void* user )
|
||||
{
|
||||
TT_Size size = (TT_Size)node->data;
|
||||
|
||||
FT_UNUSED( user );
|
||||
|
||||
|
||||
tt_size_reset( size, 1 );
|
||||
|
||||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
/* */
|
||||
/* <Function> */
|
||||
/* tt_apply_mvar */
|
||||
/* */
|
||||
/* <Description> */
|
||||
/* Apply `MVAR' table adjustments. */
|
||||
/* */
|
||||
/* <InOut> */
|
||||
/* face :: The font face. */
|
||||
/* */
|
||||
FT_LOCAL_DEF( void )
|
||||
tt_apply_mvar( TT_Face face )
|
||||
{
|
||||
GX_Blend blend = face->blend;
|
||||
GX_Value value, limit;
|
||||
|
||||
|
||||
if ( !( face->variation_support & TT_FACE_FLAG_VAR_MVAR ) )
|
||||
return;
|
||||
|
||||
value = blend->mvar_table->values;
|
||||
limit = value + blend->mvar_table->valueCount;
|
||||
|
||||
for ( ; value < limit; value++ )
|
||||
{
|
||||
FT_Short* p = ft_var_get_value_pointer( face, value->tag );
|
||||
FT_Int delta;
|
||||
|
||||
|
||||
delta = ft_var_get_item_delta( face,
|
||||
&blend->mvar_table->itemStore,
|
||||
value->outerIndex,
|
||||
value->innerIndex );
|
||||
|
||||
FT_TRACE5(( "value %c%c%c%c (%d units) adjusted by %d units (MVAR)\n",
|
||||
(FT_Char)( value->tag >> 24 ),
|
||||
(FT_Char)( value->tag >> 16 ),
|
||||
(FT_Char)( value->tag >> 8 ),
|
||||
(FT_Char)( value->tag ),
|
||||
value->unmodified,
|
||||
delta ));
|
||||
|
||||
/* since we handle both signed and unsigned values as FT_Short, */
|
||||
/* ensure proper overflow arithmetic */
|
||||
*p = (FT_Short)( value->unmodified + (FT_Short)delta );
|
||||
}
|
||||
|
||||
/* adjust all derived values */
|
||||
{
|
||||
FT_Face root = &face->root;
|
||||
|
||||
|
||||
if ( face->os2.version != 0xFFFFU )
|
||||
{
|
||||
if ( face->os2.sTypoAscender || face->os2.sTypoDescender )
|
||||
{
|
||||
root->ascender = face->os2.sTypoAscender;
|
||||
root->descender = face->os2.sTypoDescender;
|
||||
|
||||
root->height = root->ascender - root->descender +
|
||||
face->os2.sTypoLineGap;
|
||||
}
|
||||
else
|
||||
{
|
||||
root->ascender = (FT_Short)face->os2.usWinAscent;
|
||||
root->descender = -(FT_Short)face->os2.usWinDescent;
|
||||
|
||||
root->height = root->ascender - root->descender;
|
||||
}
|
||||
}
|
||||
|
||||
/* iterate over all FT_Size objects and call `tt_size_reset' */
|
||||
/* to propagate the metrics changes */
|
||||
FT_List_Iterate( &root->sizes_list,
|
||||
tt_size_reset_iterator,
|
||||
NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef struct GX_GVar_Head_
|
||||
{
|
||||
FT_Long version;
|
||||
|
@ -332,6 +332,9 @@ FT_BEGIN_HEADER
|
||||
FT_UInt gindex,
|
||||
FT_Int *adelta );
|
||||
|
||||
FT_LOCAL( void )
|
||||
tt_apply_mvar( TT_Face face );
|
||||
|
||||
FT_LOCAL( FT_Error )
|
||||
tt_get_var_blend( TT_Face face,
|
||||
FT_UInt *num_coords,
|
||||
|
Loading…
Reference in New Issue
Block a user