[truetype] Tweak size management.

* include/freetype/internal/services/svmetric.h (FT_Size_Reset_Func):
Update typedef, do not return error.
* src/truetype/ttobjs.c (tt_size_reset_height): Move the PPem error
handling from here...
(tt_size_reset): ... to here to improve readability.
src/truetype/ttobjs.h (tt_size_reset_height): Update prototype.
This commit is contained in:
Alexei Podtelezhnikov 2025-07-29 22:21:42 -04:00
parent 8ceba9bbc5
commit 64a0c64a04
3 changed files with 11 additions and 16 deletions

View file

@ -77,7 +77,7 @@ FT_BEGIN_HEADER
typedef void
(*FT_Metrics_Adjust_Func)( FT_Face face );
typedef FT_Error
typedef void
(*FT_Size_Reset_Func)( FT_Size size );

View file

@ -1182,19 +1182,13 @@
* function must take `FT_Size` as a result. The passed `FT_Size` is
* expected to point to a `TT_Size`.
*/
FT_LOCAL_DEF( FT_Error )
FT_LOCAL_DEF( void )
tt_size_reset_height( FT_Size ft_size )
{
TT_Size size = (TT_Size)ft_size;
TT_Face face = (TT_Face)size->root.face;
TT_Face face = (TT_Face)ft_size->face;
FT_Size_Metrics* size_metrics = &size->hinted_metrics;
/* copy the result from base layer */
*size_metrics = size->root.metrics;
if ( size_metrics->x_ppem < 1 || size_metrics->y_ppem < 1 )
return FT_THROW( Invalid_PPem );
/* This bit flag, if set, indicates that the ppems must be */
/* rounded to integers. Nearly all TrueType fonts have this bit */
/* set, as hinting won't work really well otherwise. */
@ -1212,8 +1206,6 @@
FT_MulFix( face->root.height,
size_metrics->y_scale ) );
}
return FT_Err_Ok;
}
@ -1233,7 +1225,6 @@
FT_LOCAL_DEF( FT_Error )
tt_size_reset( TT_Size size )
{
FT_Error error;
TT_Face face = (TT_Face)size->root.face;
FT_Size_Metrics* size_metrics = &size->hinted_metrics;
@ -1241,9 +1232,13 @@
/* invalidate the size object first */
size->ttmetrics.ppem = 0;
error = tt_size_reset_height( (FT_Size)size );
if ( error )
return error;
if ( size->root.metrics.x_ppem == 0 || size->root.metrics.y_ppem == 0 )
return FT_THROW( Invalid_PPem );
/* copy the result from base layer */
*size_metrics = size->root.metrics;
tt_size_reset_height( (FT_Size)size );
if ( face->header.Flags & 8 )
{

View file

@ -299,7 +299,7 @@ FT_BEGIN_HEADER
#endif /* TT_USE_BYTECODE_INTERPRETER */
FT_LOCAL( FT_Error )
FT_LOCAL( void )
tt_size_reset_height( FT_Size size );
FT_LOCAL( FT_Error )