#94319 Symbolic fonts do not display properly, need generic solution rather than adding each new font to fontencoding.properties

using the flag set by CSS#94319 Symbolic fonts do not display properly, need generic solution rather than adding each new font to fontencoding.properties
using the flag set by CSS, we only decode symbol font using win-1252 for windows symbol font.
r=ftang, sr=rbs
This commit is contained in:
shanjian%netscape.com 2002-11-14 02:58:54 +00:00
Родитель 6f7c14c2ad
Коммит b105fc6fe8
2 изменённых файлов: 32 добавлений и 18 удалений

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

@ -37,7 +37,6 @@
# - the 'value' is the case-sensitive charset string used when setting up the
# corresponding Unicode Converter in the intl/uconv library.
# Symbol font
encoding.symbol.ttf = Adobe-Symbol-Encoding
@ -79,8 +78,3 @@ encoding.math5monobold.ttf = x-mathematica5
# MathType Extra
encoding.mtextra.ttf = x-mtextra
# Hack for compatibility with Nav4.x (bug 77265, 91171)
# Treat these Symbol fonts as if they have the given encoding
encoding.wingdings.ttf = windows-1252
encoding.webdings.ttf = windows-1252

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

@ -61,6 +61,8 @@
#include "nsUnicharUtils.h"
#include "nsUnicodeRange.h"
#define DEFAULT_TTF_SYMBOL_ENCODING "windows-1252"
#define NOT_SETUP 0x33
static PRBool gIsWIN95OR98 = NOT_SETUP;
@ -1165,6 +1167,26 @@ GetEncoding(const char* aFontName, nsString& aValue)
// This function uses the charset converter manager to get a pointer on the
// converter for the font whose name is given. The caller holds a reference
// to the converter, and should take care of the release...
static nsresult
GetConverterCommon(nsString& aEncoding, nsIUnicodeEncoder** aConverter)
{
*aConverter = nsnull;
nsCOMPtr<nsIAtom> charset;
nsresult rv = gCharsetManager->GetCharsetAtom(aEncoding.get(), getter_AddRefs(charset));
if (NS_FAILED(rv)) return rv;
rv = gCharsetManager->GetUnicodeEncoder(charset, aConverter);
if (NS_FAILED(rv)) return rv;
return (*aConverter)->SetOutputErrorBehavior((*aConverter)->kOnError_Replace, nsnull, '?');
}
static nsresult
GetDefaultConverterForTTFSymbolEncoding(nsIUnicodeEncoder** aConverter)
{
nsAutoString value;
value.AssignWithConversion(DEFAULT_TTF_SYMBOL_ENCODING);
return GetConverterCommon(value, aConverter);
}
static nsresult
GetConverter(const char* aFontName, nsIUnicodeEncoder** aConverter)
{
@ -1173,14 +1195,7 @@ GetConverter(const char* aFontName, nsIUnicodeEncoder** aConverter)
nsAutoString value;
nsresult rv = GetEncoding(aFontName, value);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIAtom> charset;
rv = gCharsetManager->GetCharsetAtom(value.get(), getter_AddRefs(charset));
if (NS_FAILED(rv)) return rv;
rv = gCharsetManager->GetUnicodeEncoder(charset, aConverter);
if (NS_FAILED(rv)) return rv;
return (*aConverter)->SetOutputErrorBehavior((*aConverter)->kOnError_Replace, nsnull, '?');
return GetConverterCommon(value, aConverter);
}
// This function uses the charset converter manager to fill the map for the
@ -1190,11 +1205,14 @@ GetCCMapThroughConverter(const char* aFontName)
{
// see if we know something about the converter of this font
nsCOMPtr<nsIUnicodeEncoder> converter;
if (NS_SUCCEEDED(GetConverter(aFontName, getter_AddRefs(converter)))) {
// we don't check "familyNameQuirks" here because we are only generating CCMAP.
// the flag will be checked later when the font is about to be loaded.
if (NS_SUCCEEDED(GetConverter(aFontName, getter_AddRefs(converter))) ||
NS_SUCCEEDED(GetDefaultConverterForTTFSymbolEncoding(getter_AddRefs(converter)))) {
nsCOMPtr<nsICharRepresentable> mapper(do_QueryInterface(converter));
if (mapper)
return MapperToCCMap(mapper);
}
}
return nsnull;
}
@ -2078,9 +2096,11 @@ nsFontMetricsWin::LoadFont(HDC aDC, nsString* aName)
}
else if (eFontType_NonUnicode == fontType) {
nsCOMPtr<nsIUnicodeEncoder> converter;
if (NS_SUCCEEDED(GetConverter(logFont.lfFaceName, getter_AddRefs(converter)))) {
if (NS_SUCCEEDED(GetConverter(logFont.lfFaceName, getter_AddRefs(converter))))
font = new nsFontWinNonUnicode(&logFont, hfont, ccmap, converter);
}
else if (mFont.familyNameQuirks)
if (NS_SUCCEEDED(GetDefaultConverterForTTFSymbolEncoding(getter_AddRefs(converter))))
font = new nsFontWinNonUnicode(&logFont, hfont, ccmap, converter);
}
}
}