From ceb1878df9624b46a1f571bc4da732144b5a7bf0 Mon Sep 17 00:00:00 2001 From: "ftang%netscape.com" Date: Fri, 5 May 2000 21:19:26 +0000 Subject: [PATCH] fix 30798, skip font start with "." and "%" for font enumeration since they are private font. git-svn-id: svn://10.0.0.236/trunk@68427 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/gfx/src/mac/nsDeviceContextMac.cpp | 70 +++++++++++----------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp index f7f73cb21c2..3578579fe5b 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp @@ -790,46 +790,48 @@ void nsDeviceContextMac :: InitFontInfoList() OSType resType; Str255 fontName; ::GetResInfo(fond, &fondID, &resType, fontName); - + if( (0 != fontName[0]) && ('.' != fontName[1]) && ('%' != fontName[1])) + { #if !TARGET_CARBON - ScriptCode script = ::FontToScript(fondID); - if (script != lastscript) - { - lastscript = script; + ScriptCode script = ::FontToScript(fondID); + if (script != lastscript) + { + lastscript = script; + + TextEncoding sourceEncoding; + err = ::UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare, + kTextRegionDontCare, NULL, &sourceEncoding); + + if (converter) + err = ::TECDisposeConverter(converter); + + err = ::TECCreateConverter(&converter, sourceEncoding, unicodeEncoding); + if (err != noErr) + converter = nil; + } - TextEncoding sourceEncoding; - err = ::UpgradeScriptInfoToTextEncoding(script, kTextLanguageDontCare, - kTextRegionDontCare, NULL, &sourceEncoding); - if (converter) - err = ::TECDisposeConverter(converter); + { + PRUnichar unicodeFontName[sizeof(fontName)]; + ByteCount actualInputLength, actualOutputLength; + err = ::TECConvertText(converter, &fontName[1], fontName[0], &actualInputLength, + (TextPtr)unicodeFontName , sizeof(unicodeFontName), &actualOutputLength); + unicodeFontName[actualOutputLength / sizeof(PRUnichar)] = '\0'; - err = ::TECCreateConverter(&converter, sourceEncoding, unicodeEncoding); - if (err != noErr) - converter = nil; - } - - if (converter) - { - PRUnichar unicodeFontName[sizeof(fontName)]; - ByteCount actualInputLength, actualOutputLength; - err = ::TECConvertText(converter, &fontName[1], fontName[0], &actualInputLength, - (TextPtr)unicodeFontName , sizeof(unicodeFontName), &actualOutputLength); - unicodeFontName[actualOutputLength / sizeof(PRUnichar)] = '\0'; - - FontNameKey key(unicodeFontName); - gFontInfoList->Put(&key, (void*)fondID); - } + FontNameKey key(unicodeFontName); + gFontInfoList->Put(&key, (void*)fondID); + } #else - // pinkerton - CreateTextEncoding() makes a carbon app exit. this is a smarmy hack - char buffer[500]; - ::BlockMoveData ( &fontName[1], buffer, *fontName ); - buffer[*fontName] = NULL; -printf("font buffer is %s\n", buffer); - FontNameKey key(buffer); - gFontInfoList->Put(&key, (void*)fondID); + // pinkerton - CreateTextEncoding() makes a carbon app exit. this is a smarmy hack + char buffer[500]; + ::BlockMoveData ( &fontName[1], buffer, *fontName ); + buffer[*fontName] = NULL; + printf("font buffer is %s\n", buffer); + FontNameKey key(buffer); + gFontInfoList->Put(&key, (void*)fondID); #endif - ::ReleaseResource(fond); + ::ReleaseResource(fond); + } } } if (converter)