From 392c54e1c04696d87d6f6856460664f1523e7691 Mon Sep 17 00:00:00 2001 From: Dave Hawkes Date: Fri, 9 Aug 2002 19:50:20 +0000 Subject: [PATCH] Fonts with an incomplete character set could cause a fault. --- graphics/x11drv/xfont.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/graphics/x11drv/xfont.c b/graphics/x11drv/xfont.c index 186bde51878..2c53a25dfa2 100644 --- a/graphics/x11drv/xfont.c +++ b/graphics/x11drv/xfont.c @@ -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++ )