Fonts with an incomplete character set could cause a fault.

This commit is contained in:
Dave Hawkes 2002-08-09 19:50:20 +00:00 committed by Alexandre Julliard
parent 5ee517ac3d
commit 392c54e1c0
1 changed files with 5 additions and 3 deletions

View File

@ -1031,6 +1031,7 @@ static void XFONT_GetLeading( const LPIFONTINFO16 pFI, const XFontStruct* x_fs,
{
unsigned long height;
unsigned min = (unsigned char)pFI->dfFirstChar;
unsigned max = (unsigned char)pFI->dfLastChar;
BOOL bIsLatin = IS_LATIN_CHARSET(pFI->dfCharSet);
if( pEL ) *pEL = 0;
@ -1048,7 +1049,7 @@ static void XFONT_GetLeading( const LPIFONTINFO16 pFI, const XFontStruct* x_fs,
if( TSXGetFontProperty((XFontStruct*)x_fs, XA_CAP_HEIGHT, &height) == FALSE )
{
if( x_fs->per_char )
if( bIsLatin )
if( bIsLatin && ((unsigned char)'X' <= (max - min)) )
height = x_fs->per_char['X' - min].ascent;
else
if (x_fs->ascent >= x_fs->max_bounds.ascent)
@ -1092,8 +1093,9 @@ static INT XFONT_GetAvgCharWidth( LPIFONTINFO16 pFI, const XFontStruct* x_fs,
if( x_fs->per_char )
{
int width = 0, chars = 0, j;
if( IS_LATIN_CHARSET(pFI->dfCharSet) ||
pFI->dfCharSet == DEFAULT_CHARSET )
if( (IS_LATIN_CHARSET(pFI->dfCharSet) ||
pFI->dfCharSet == DEFAULT_CHARSET) &&
(max - min) >= (unsigned char)'z' )
{
/* FIXME - should use a weighted average */
for( j = 0; j < 26; j++ )