Strengthen the detection of the appropriate error status to avoid building on a false assumption that a font is bitmap when there is a real error, b=113779, r+sr=roc

This commit is contained in:
rbs%maths.uq.edu.au 2003-06-30 18:05:00 +00:00
Родитель a0c42e6953
Коммит 4a05aa5b52
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -655,9 +655,9 @@ GetGlyphIndex(PRUint16 segCount, PRUint16* endCode, PRUint16* startCode,
enum eGetNameError enum eGetNameError
{ {
eGetName_OK = 0, eGetName_OK = 0, // exit code for a TrueType font
eGetName_GDIError, eGetName_GDIError, // we use this internally to flag a raster (bitmap) font
eGetName_OtherError eGetName_OtherError // unknown error, the font can't be used
}; };
static eGetNameError static eGetNameError
@ -665,7 +665,11 @@ GetNAME(HDC aDC, nsString* aName)
{ {
DWORD len = GetFontData(aDC, NAME, 0, nsnull, 0); DWORD len = GetFontData(aDC, NAME, 0, nsnull, 0);
if (len == GDI_ERROR) { if (len == GDI_ERROR) {
return eGetName_GDIError; TEXTMETRIC metrics;
if (::GetTextMetrics(aDC, &metrics) == 0) // can fail here -- see bug 113779#c81
return eGetName_OtherError;
return (metrics.tmPitchAndFamily & TMPF_TRUETYPE) ?
eGetName_OtherError : eGetName_GDIError;
} }
if (!len) { if (!len) {
return eGetName_OtherError; return eGetName_OtherError;