forked from minhngoc25a/freetype2
[pcf] Use FT_ABS for some property values (#45893).
* src/pcf/pcfread.c (pcf_load_font): Take absolute values for AVERAGE_WIDTH, POINT_SIZE, PIXEL_SIZE, RESOLUTION_X, and RESOLUTION_Y. In tracing mode, add warnings.
This commit is contained in:
parent
bd0438a461
commit
9db9adda0f
|
@ -1,3 +1,11 @@
|
|||
2015-09-17 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
[pcf] Use FT_ABS for some property values (#45893).
|
||||
|
||||
* src/pcf/pcfread.c (pcf_load_font): Take absolute values for
|
||||
AVERAGE_WIDTH, POINT_SIZE, PIXEL_SIZE, RESOLUTION_X, and
|
||||
RESOLUTION_Y. In tracing mode, add warnings.
|
||||
|
||||
2015-09-16 Werner Lemberg <wl@gnu.org>
|
||||
|
||||
Minor fixes for some clang warnings.
|
||||
|
|
|
@ -1278,28 +1278,62 @@ THE SOFTWARE.
|
|||
bsize->height = (FT_Short)( face->accel.fontAscent +
|
||||
face->accel.fontDescent );
|
||||
|
||||
/* for simplicity, we take absolute values of integer properties */
|
||||
|
||||
prop = pcf_find_property( face, "AVERAGE_WIDTH" );
|
||||
if ( prop )
|
||||
bsize->width = (FT_Short)( ( prop->value.l + 5 ) / 10 );
|
||||
{
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
if ( prop->value.l < 0 )
|
||||
FT_TRACE0(( "pcf_load_font: negative average width\n" ));
|
||||
#endif
|
||||
bsize->width = (FT_Short)( ( FT_ABS( prop->value.l ) + 5 ) / 10 );
|
||||
}
|
||||
else
|
||||
bsize->width = (FT_Short)( bsize->height * 2/3 );
|
||||
bsize->width = (FT_Short)( bsize->height * 2 / 3 );
|
||||
|
||||
prop = pcf_find_property( face, "POINT_SIZE" );
|
||||
if ( prop )
|
||||
{
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
if ( prop->value.l < 0 )
|
||||
FT_TRACE0(( "pcf_load_font: negative point size\n" ));
|
||||
#endif
|
||||
/* convert from 722.7 decipoints to 72 points per inch */
|
||||
bsize->size = FT_MulDiv( prop->value.l, 64 * 7200, 72270L );
|
||||
bsize->size = FT_MulDiv( FT_ABS( prop->value.l ),
|
||||
64 * 7200,
|
||||
72270L );
|
||||
}
|
||||
|
||||
prop = pcf_find_property( face, "PIXEL_SIZE" );
|
||||
if ( prop )
|
||||
bsize->y_ppem = (FT_Short)prop->value.l << 6;
|
||||
{
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
if ( prop->value.l < 0 )
|
||||
FT_TRACE0(( "pcf_load_font: negative pixel size\n" ));
|
||||
#endif
|
||||
bsize->y_ppem = (FT_Short)FT_ABS( prop->value.l ) << 6;
|
||||
}
|
||||
|
||||
prop = pcf_find_property( face, "RESOLUTION_X" );
|
||||
if ( prop )
|
||||
resolution_x = (FT_Short)prop->value.l;
|
||||
{
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
if ( prop->value.l < 0 )
|
||||
FT_TRACE0(( "pcf_load_font: negative X resolution\n" ));
|
||||
#endif
|
||||
resolution_x = (FT_Short)FT_ABS( prop->value.l );
|
||||
}
|
||||
|
||||
prop = pcf_find_property( face, "RESOLUTION_Y" );
|
||||
if ( prop )
|
||||
resolution_y = (FT_Short)prop->value.l;
|
||||
{
|
||||
#ifdef FT_DEBUG_LEVEL_TRACE
|
||||
if ( prop->value.l < 0 )
|
||||
FT_TRACE0(( "pcf_load_font: negative Y resolution\n" ));
|
||||
#endif
|
||||
resolution_y = (FT_Short)FT_ABS( prop->value.l );
|
||||
}
|
||||
|
||||
if ( bsize->y_ppem == 0 )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue