зеркало из https://github.com/mozilla/pjs.git
backing out the previous change, which broke the tree
This commit is contained in:
Родитель
0986a87284
Коммит
9c11adcfe1
|
@ -58,9 +58,11 @@ nsFontMetricsGTK::nsFontMetricsGTK()
|
|||
mFontHandle = nsnull;
|
||||
|
||||
mHeight = 0;
|
||||
mAscent = 0;
|
||||
mDescent = 0;
|
||||
mLeading = 0;
|
||||
mEmHeight = 0;
|
||||
mEmAscent = 0;
|
||||
mEmDescent = 0;
|
||||
mMaxHeight = 0;
|
||||
mMaxAscent = 0;
|
||||
mMaxDescent = 0;
|
||||
mMaxAdvance = 0;
|
||||
|
@ -100,6 +102,7 @@ nsFontMetricsGTK::~nsFontMetricsGTK()
|
|||
mSubstituteFont = nsnull;
|
||||
}
|
||||
|
||||
mWesternFont = nsnull;
|
||||
mFontHandle = nsnull;
|
||||
|
||||
if (!--gFontMetricsGTKCount) {
|
||||
|
@ -123,7 +126,7 @@ FontEnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData)
|
|||
nsString* newPointer = new nsString[newSize];
|
||||
if (newPointer) {
|
||||
for (int i = metrics->mFontsCount - 1; i >= 0; i--) {
|
||||
newPointer[i].SetString(metrics->mFonts[i].GetUnicode());
|
||||
newPointer[i] = metrics->mFonts[i].GetUnicode();
|
||||
}
|
||||
delete [] metrics->mFonts;
|
||||
metrics->mFonts = newPointer;
|
||||
|
@ -133,7 +136,7 @@ FontEnumCallback(const nsString& aFamily, PRBool aGeneric, void *aData)
|
|||
return PR_FALSE;
|
||||
}
|
||||
}
|
||||
metrics->mFonts[metrics->mFontsCount].SetString(aFamily.GetUnicode());
|
||||
metrics->mFonts[metrics->mFontsCount] = aFamily.GetUnicode();
|
||||
metrics->mFonts[metrics->mFontsCount++].ToLowerCase();
|
||||
|
||||
return PR_TRUE;
|
||||
|
@ -183,13 +186,15 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
res = service->GetApplicationLocale(getter_AddRefs(locale));
|
||||
if (NS_SUCCEEDED(res) && locale) {
|
||||
PRUnichar* str = nsnull;
|
||||
res = locale->GetCategory(nsAutoString(NSILOCALE_CTYPE).GetUnicode(),
|
||||
res = locale->GetCategory(nsAutoString(NS_ConvertASCIItoUCS2(NSILOCALE_CTYPE)).GetUnicode(),
|
||||
&str);
|
||||
if (NS_SUCCEEDED(res) && str) {
|
||||
nsAutoString loc(str);
|
||||
loc.Truncate(2);
|
||||
loc.ToLowerCase();
|
||||
if ((loc == "ja") || (loc == "ko") || (loc == "zh")) {
|
||||
if ((loc.Equals(NS_ConvertASCIItoUCS2("ja"))) ||
|
||||
(loc.Equals(NS_ConvertASCIItoUCS2("ko"))) ||
|
||||
(loc.Equals(NS_ConvertASCIItoUCS2("zh")))) {
|
||||
// In CJK environments, we want the minimum request to be 16px,
|
||||
// since the smallest font for some of those langs is 16.
|
||||
minimum = 16;
|
||||
|
@ -199,7 +204,9 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
}
|
||||
}
|
||||
}
|
||||
mPixelSize = NSToIntRound(app2dev * factor * mFont->size);
|
||||
float textZoom = 1.0;
|
||||
mDeviceContext->GetTextZoom(textZoom);
|
||||
mPixelSize = NSToIntRound(app2dev * textZoom * factor * mFont->size);
|
||||
if (mPixelSize < minimum) {
|
||||
mPixelSize = minimum;
|
||||
}
|
||||
|
@ -208,11 +215,11 @@ NS_IMETHODIMP nsFontMetricsGTK::Init(const nsFont& aFont, nsIAtom* aLangGroup,
|
|||
|
||||
mFont->EnumerateFamilies(FontEnumCallback, this);
|
||||
|
||||
nsFontGTK* f = FindFont('a');
|
||||
if (!f) {
|
||||
mWesternFont = FindFont('a');
|
||||
if (!mWesternFont) {
|
||||
return NS_OK; // XXX
|
||||
}
|
||||
mFontHandle = f->mFont;
|
||||
mFontHandle = mWesternFont->mFont;
|
||||
|
||||
RealizeFont();
|
||||
|
||||
|
@ -290,8 +297,19 @@ void nsFontMetricsGTK::RealizeFont()
|
|||
float f;
|
||||
mDeviceContext->GetDevUnitsToAppUnits(f);
|
||||
|
||||
mAscent = nscoord(fontInfo->ascent * f);
|
||||
mDescent = nscoord(fontInfo->descent * f);
|
||||
int lineSpacing = fontInfo->ascent + fontInfo->descent;
|
||||
if (lineSpacing > mWesternFont->mSize) {
|
||||
mLeading = nscoord((lineSpacing - mWesternFont->mSize) * f);
|
||||
}
|
||||
else {
|
||||
mLeading = 0;
|
||||
}
|
||||
mEmHeight = nscoord(mWesternFont->mSize * f);
|
||||
mEmAscent = nscoord(fontInfo->ascent * mWesternFont->mSize * f / lineSpacing);
|
||||
mEmDescent = mEmHeight - mEmAscent;
|
||||
|
||||
mMaxHeight = nscoord((fontInfo->max_bounds.ascent +
|
||||
fontInfo->max_bounds.descent) * f);
|
||||
mMaxAscent = nscoord(fontInfo->max_bounds.ascent * f) ;
|
||||
mMaxDescent = nscoord(fontInfo->max_bounds.descent * f);
|
||||
|
||||
|
@ -375,8 +393,6 @@ void nsFontMetricsGTK::RealizeFont()
|
|||
/* need better way to calculate this */
|
||||
mStrikeoutOffset = NSToCoordRound(mXHeight / 2.0);
|
||||
mStrikeoutSize = mUnderlineSize;
|
||||
|
||||
mLeading = 0;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsGTK::GetXHeight(nscoord& aResult)
|
||||
|
@ -423,6 +439,30 @@ NS_IMETHODIMP nsFontMetricsGTK::GetLeading(nscoord &aLeading)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsGTK::GetEmHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = mEmHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsGTK::GetEmAscent(nscoord &aAscent)
|
||||
{
|
||||
aAscent = mEmAscent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsGTK::GetEmDescent(nscoord &aDescent)
|
||||
{
|
||||
aDescent = mEmDescent;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsGTK::GetMaxHeight(nscoord &aHeight)
|
||||
{
|
||||
aHeight = mMaxHeight;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsFontMetricsGTK::GetMaxAscent(nscoord &aAscent)
|
||||
{
|
||||
aAscent = mMaxAscent;
|
||||
|
@ -702,6 +742,8 @@ static PLHashTable* gFamilies = nsnull;
|
|||
|
||||
static PLHashTable* gFamilyNames = nsnull;
|
||||
|
||||
static nsString* gGeneric = nsnull;
|
||||
|
||||
static nsFontFamilyName gFamilyNameTable[] =
|
||||
{
|
||||
#ifdef MOZ_MATHML
|
||||
|
@ -757,13 +799,9 @@ static nsFontPropertyName gStretchNames[] =
|
|||
};
|
||||
|
||||
static PLHashTable* gCharSets = nsnull;
|
||||
#ifdef MOZ_MATHML
|
||||
static PLHashTable* gSpecialCharSets = nsnull;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
static nsFontCharSetInfo Special = { nsnull };
|
||||
#endif
|
||||
static nsFontCharSetInfo Ignore = { nsnull };
|
||||
|
||||
static gint
|
||||
|
@ -850,7 +888,7 @@ SetUpFontCharSetInfo(nsFontCharSetInfo* aSelf)
|
|||
NS_WITH_SERVICE(nsICharsetConverterManager, manager,
|
||||
NS_CHARSETCONVERTERMANAGER_PROGID, &result);
|
||||
if (manager && NS_SUCCEEDED(result)) {
|
||||
nsAutoString charset(aSelf->mCharSet);
|
||||
nsAutoString charset(NS_ConvertASCIItoUCS2(aSelf->mCharSet));
|
||||
nsIUnicodeEncoder* converter = nsnull;
|
||||
result = manager->GetUnicodeEncoder(&charset, &converter);
|
||||
if (converter && NS_SUCCEEDED(result)) {
|
||||
|
@ -870,7 +908,7 @@ SetUpFontCharSetInfo(nsFontCharSetInfo* aSelf)
|
|||
*/
|
||||
if (aSelf->Convert == DoubleByteConvert) {
|
||||
PRUint32* map = aSelf->mMap;
|
||||
for (PRUint16 i = 0; i < (0x3000 >> 5); i++) {
|
||||
for (PRUint16 i = 0; i < (0x2200 >> 5); i++) {
|
||||
map[i] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -908,6 +946,8 @@ static nsFontCharSetInfo JISX0201 =
|
|||
{ "jis_0201", SingleByteConvert, 1 };
|
||||
static nsFontCharSetInfo KOI8R =
|
||||
{ "KOI8-R", SingleByteConvert, 0 };
|
||||
static nsFontCharSetInfo KOI8U =
|
||||
{ "KOI8-U", SingleByteConvert, 0 };
|
||||
static nsFontCharSetInfo TIS620 =
|
||||
{ "TIS-620", SingleByteConvert, 0 };
|
||||
|
||||
|
@ -929,8 +969,6 @@ static nsFontCharSetInfo CNS116437 =
|
|||
{ "x-cns-11643-7", DoubleByteConvert, 1 };
|
||||
static nsFontCharSetInfo GB2312 =
|
||||
{ "gb_2312-80", DoubleByteConvert, 1 };
|
||||
static nsFontCharSetInfo GBK =
|
||||
{ "x-gbk", DoubleByteConverter, 1 };
|
||||
static nsFontCharSetInfo JISX0208 =
|
||||
{ "jis_0208-1983", DoubleByteConvert, 1 };
|
||||
static nsFontCharSetInfo JISX0212 =
|
||||
|
@ -942,14 +980,12 @@ static nsFontCharSetInfo X11Johab =
|
|||
|
||||
static nsFontCharSetInfo ISO106461 =
|
||||
{ nsnull, ISO10646Convert, 1 };
|
||||
#ifdef MOZ_MATHML
|
||||
static nsFontCharSetInfo AdobeSymbol =
|
||||
{ "Adobe-Symbol-Encoding", SingleByteConvert, 0 };
|
||||
static nsFontCharSetInfo CMCMEX =
|
||||
{ "x-cm-cmex", SingleByteConvert, 0 };
|
||||
{ "x-t1-cmex", SingleByteConvert, 0 };
|
||||
static nsFontCharSetInfo CMCMSY =
|
||||
{ "x-cm-cmsy", SingleByteConvert, 0 };
|
||||
#endif
|
||||
{ "x-t1-cmsy", SingleByteConvert, 0 };
|
||||
|
||||
/*
|
||||
* Normally, the charset of an X font can be determined simply by looking at
|
||||
|
@ -981,9 +1017,7 @@ static nsFontCharSetMap gCharSetMap[] =
|
|||
{
|
||||
{ "-ascii", &Ignore },
|
||||
{ "-ibm pc", &Ignore },
|
||||
#ifdef MOZ_MATHML
|
||||
{ "adobe-fontspecific", &Special },
|
||||
#endif
|
||||
{ "big5-0", &Big5 },
|
||||
{ "big5-1", &Big5 },
|
||||
{ "big5.et-0", &Big5 },
|
||||
|
@ -1016,7 +1050,6 @@ static nsFontCharSetMap gCharSetMap[] =
|
|||
{ "fontspecific-0", &Ignore },
|
||||
{ "gb2312.1980-0", &GB2312 },
|
||||
{ "gb2312.1980-1", &GB2312 },
|
||||
{ "gb13000.1993-1", &GBK },
|
||||
{ "hp-japanese15", &Ignore },
|
||||
{ "hp-japaneseeuc", &Ignore },
|
||||
{ "hp-roman8", &Ignore },
|
||||
|
@ -1057,10 +1090,12 @@ static nsFontCharSetMap gCharSetMap[] =
|
|||
{ "jisx0208.1990-0", &JISX0208 },
|
||||
{ "jisx0212.1990-0", &JISX0212 },
|
||||
{ "koi8-r", &KOI8R },
|
||||
{ "koi8-u", &KOI8U },
|
||||
{ "johab-1", &X11Johab },
|
||||
{ "johabs-1", &X11Johab },
|
||||
{ "johabsh-1", &X11Johab },
|
||||
{ "ksc5601.1987-0", &KSC5601 },
|
||||
{ "microsoft-cp1251", &CP1251 },
|
||||
{ "misc-fontspecific", &Ignore },
|
||||
{ "sgi-fontspecific", &Ignore },
|
||||
{ "sun-fontspecific", &Ignore },
|
||||
|
@ -1074,7 +1109,6 @@ static nsFontCharSetMap gCharSetMap[] =
|
|||
{ nsnull, nsnull }
|
||||
};
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
static nsFontCharSetMap gSpecialCharSetMap[] =
|
||||
{
|
||||
{ "symbol-adobe-fontspecific", &AdobeSymbol },
|
||||
|
@ -1083,7 +1117,6 @@ static nsFontCharSetMap gSpecialCharSetMap[] =
|
|||
|
||||
{ nsnull, nsnull }
|
||||
};
|
||||
#endif
|
||||
|
||||
#undef DEBUG_DUMP_TREE
|
||||
#ifdef DEBUG_DUMP_TREE
|
||||
|
@ -1213,7 +1246,7 @@ GetMapFor10646Font(XFontStruct* aFont)
|
|||
PRInt32 offset = (((row - minByte1) * charsPerRow) - minByte2);
|
||||
for (PRInt32 cell = minByte2; cell <= maxByte2; cell++) {
|
||||
XCharStruct* bounds = &aFont->per_char[offset + cell];
|
||||
if ((!bounds->ascent) && (!bounds->descent)) {
|
||||
if (bounds->ascent || bounds->descent) {
|
||||
SET_REPRESENTABLE(map, (row << 8) | cell);
|
||||
}
|
||||
}
|
||||
|
@ -1637,7 +1670,8 @@ PickASizeAndLoad(nsFontSearch* aSearch, nsFontStretch* aStretch,
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef MOZ_MATHML
|
||||
// XXX remove the else part after testing this for a while -- erik
|
||||
#if 1
|
||||
// CSS font-family bug fix
|
||||
// CSS font-family order is not respected without the following fix.
|
||||
// The idea is to ensure that even though the character being searched
|
||||
|
@ -1688,7 +1722,7 @@ PickASizeAndLoad(nsFontSearch* aSearch, nsFontStretch* aStretch,
|
|||
if (fontHasGlyph) {
|
||||
aSearch->mFont = s;
|
||||
}
|
||||
#else /* MOZ_MATHML */
|
||||
#else /* 1 */
|
||||
if (!aCharSet->mInfo->mCharSet) {
|
||||
if (!IS_REPRESENTABLE(s->mMap, aSearch->mChar)) {
|
||||
return;
|
||||
|
@ -1715,7 +1749,7 @@ PickASizeAndLoad(nsFontSearch* aSearch, nsFontStretch* aStretch,
|
|||
}
|
||||
m->mLoadedFonts[m->mLoadedFontsCount++] = s;
|
||||
aSearch->mFont = s;
|
||||
#endif /* !MOZ_MATHML */
|
||||
#endif /* 1 */
|
||||
|
||||
#ifdef REALLY_NOISY_FONTS
|
||||
nsFontGTK* result = s;
|
||||
|
@ -2013,7 +2047,8 @@ SearchCharSet(PLHashEntry* he, PRIntn i, void* arg)
|
|||
nsFontCharSetInfo* charSetInfo = charSet->mInfo;
|
||||
PRUint32* map = charSetInfo->mMap;
|
||||
nsFontSearch* search = (nsFontSearch*) arg;
|
||||
#ifdef MOZ_MATHML
|
||||
// XXX remove the if and endif lines after testing for a while -- erik
|
||||
#if 1
|
||||
nsFontMetricsGTK* m = search->mMetrics;
|
||||
#endif
|
||||
PRUnichar c = search->mChar;
|
||||
|
@ -2030,7 +2065,8 @@ SearchCharSet(PLHashEntry* he, PRIntn i, void* arg)
|
|||
charSetInfo->mMap = map;
|
||||
SetUpFontCharSetInfo(charSetInfo);
|
||||
}
|
||||
#ifdef MOZ_MATHML
|
||||
// XXX remove the else part after testing for a while -- erik
|
||||
#if 1
|
||||
// CSS font-family bug fix
|
||||
// Check if font has been requested from CSS font-family,
|
||||
// if so ignore IS_REPRESENTABLE. It gets tested again
|
||||
|
@ -2044,11 +2080,11 @@ SearchCharSet(PLHashEntry* he, PRIntn i, void* arg)
|
|||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
}
|
||||
#else /* MOZ_MATHML */
|
||||
#else /* 1 */
|
||||
if (!IS_REPRESENTABLE(map, c)) {
|
||||
return HT_ENUMERATE_NEXT;
|
||||
}
|
||||
#endif /* !MOZ_MATHML */
|
||||
#endif /* 1 */
|
||||
}
|
||||
|
||||
TryCharSet(search, charSet);
|
||||
|
@ -2169,7 +2205,6 @@ GetFontNames(char* aPattern)
|
|||
}
|
||||
nsFontCharSetInfo* charSetInfo =
|
||||
(nsFontCharSetInfo*) PL_HashTableLookup(gCharSets, charSetName);
|
||||
#ifdef MOZ_MATHML
|
||||
// indirection for font specific charset encoding
|
||||
if (charSetInfo == &Special) {
|
||||
char *familyCharSetName = PR_smprintf ("%s-%s", familyName, charSetName);
|
||||
|
@ -2177,7 +2212,6 @@ GetFontNames(char* aPattern)
|
|||
(gSpecialCharSets, familyCharSetName);
|
||||
PR_smprintf_free (familyCharSetName);
|
||||
}
|
||||
#endif
|
||||
if (!charSetInfo) {
|
||||
#ifdef NOISY_FONTS
|
||||
printf("cannot find charset %s\n", charSetName);
|
||||
|
@ -2189,7 +2223,8 @@ GetFontNames(char* aPattern)
|
|||
continue;
|
||||
}
|
||||
|
||||
nsAutoString familyName2(familyName);
|
||||
nsAutoString familyName2;
|
||||
familyName2.AssignWithConversion(familyName);
|
||||
family =
|
||||
(nsFontFamily*) PL_HashTableLookup(gFamilies, (nsString*) &familyName2);
|
||||
if (!family) {
|
||||
|
@ -2197,7 +2232,7 @@ GetFontNames(char* aPattern)
|
|||
if (!family) {
|
||||
continue;
|
||||
}
|
||||
nsString* copy = new nsString(familyName);
|
||||
nsString* copy = new nsString(NS_ConvertASCIItoUCS2(familyName));
|
||||
if (!copy) {
|
||||
delete family;
|
||||
continue;
|
||||
|
@ -2350,11 +2385,135 @@ GetFontNames(char* aPattern)
|
|||
}
|
||||
|
||||
static void
|
||||
FindFamily(nsFontSearch* aSearch, nsString* aName)
|
||||
FreeGlobals(void)
|
||||
{
|
||||
aSearch->mFont = nsnull;
|
||||
nsFontFamily* family =
|
||||
(nsFontFamily*) PL_HashTableLookup(gFamilies, aName);
|
||||
// XXX finish this
|
||||
|
||||
if (gGeneric) {
|
||||
delete gGeneric;
|
||||
gGeneric = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize all the font lookup hash tables and other globals
|
||||
*/
|
||||
static int
|
||||
InitFontTables(void)
|
||||
{
|
||||
gFamilies = PL_NewHashTable(0, HashKey, CompareKeys, NULL, NULL, NULL);
|
||||
if (!gFamilies) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
gFamilyNames = PL_NewHashTable(0, HashKey, CompareKeys, NULL, NULL, NULL);
|
||||
if (!gFamilyNames) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
gGeneric = new nsAutoString();
|
||||
if (!gGeneric) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
nsFontFamilyName* f = gFamilyNameTable;
|
||||
while (f->mName) {
|
||||
nsString* name = new nsString(NS_ConvertASCIItoUCS2(f->mName));
|
||||
if (!name) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
nsString* xName;
|
||||
if (f->mXName) {
|
||||
xName = new nsString(NS_ConvertASCIItoUCS2(f->mXName));
|
||||
if (!xName) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
xName = gGeneric;
|
||||
}
|
||||
if (name && xName) {
|
||||
if (!PL_HashTableAdd(gFamilyNames, name, (void*) xName)) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
f++;
|
||||
}
|
||||
gWeights = PL_NewHashTable(0, PL_HashString, PL_CompareStrings, NULL, NULL,
|
||||
NULL);
|
||||
if (!gWeights) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
nsFontPropertyName* p = gWeightNames;
|
||||
while (p->mName) {
|
||||
if (!PL_HashTableAdd(gWeights, p->mName, (void*) p->mValue)) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
gStretches = PL_NewHashTable(0, PL_HashString, PL_CompareStrings, NULL,
|
||||
NULL, NULL);
|
||||
if (!gStretches) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
p = gStretchNames;
|
||||
while (p->mName) {
|
||||
if (!PL_HashTableAdd(gStretches, p->mName, (void*) p->mValue)) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
gCharSets = PL_NewHashTable(0, PL_HashString, PL_CompareStrings, NULL, NULL,
|
||||
NULL);
|
||||
if (!gCharSets) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
nsFontCharSetMap* charSetMap = gCharSetMap;
|
||||
while (charSetMap->mName) {
|
||||
if (!PL_HashTableAdd(gCharSets, charSetMap->mName,
|
||||
(void*) charSetMap->mInfo)) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
charSetMap++;
|
||||
}
|
||||
gSpecialCharSets = PL_NewHashTable
|
||||
(0, PL_HashString, PL_CompareStrings, NULL, NULL, NULL);
|
||||
if (!gSpecialCharSets) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
nsFontCharSetMap* specialCharSetMap = gSpecialCharSetMap;
|
||||
while (specialCharSetMap->mName) {
|
||||
if (!PL_HashTableAdd (gSpecialCharSets,
|
||||
specialCharSetMap->mName,
|
||||
(void*) specialCharSetMap->mInfo)) {
|
||||
FreeGlobals();
|
||||
return 0;
|
||||
}
|
||||
specialCharSetMap++;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static nsFontFamily*
|
||||
FindFamily(const nsString* aName)
|
||||
{
|
||||
nsFontFamily* family = nsnull;
|
||||
if (!gFamilies) {
|
||||
if (!InitFontTables()) {
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
family = (nsFontFamily*) PL_HashTableLookup(gFamilies, aName);
|
||||
if (!family) {
|
||||
char name[128];
|
||||
aName->ToCString(name, sizeof(name));
|
||||
|
@ -2370,15 +2529,37 @@ FindFamily(nsFontSearch* aSearch, nsString* aName)
|
|||
}
|
||||
else {
|
||||
delete family;
|
||||
return;
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return;
|
||||
return nsnull;
|
||||
}
|
||||
}
|
||||
}
|
||||
TryFamily(aSearch, family);
|
||||
return family;
|
||||
}
|
||||
|
||||
static void
|
||||
FindFamily(nsFontSearch* aSearch, nsString* aName)
|
||||
{
|
||||
aSearch->mFont = nsnull;
|
||||
nsFontFamily* family = FindFamily(aName);
|
||||
if (family) {
|
||||
TryFamily(aSearch, family);
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFontMetricsGTK::FamilyExists(const nsString& aName)
|
||||
{
|
||||
nsAutoString familyName(aName);
|
||||
familyName.ToLowerCase();
|
||||
nsFontFamily* family = FindFamily(&familyName);
|
||||
if (family && family->mCharSets) { // need to check for dummy entry
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -2390,7 +2571,7 @@ PrefEnumCallback(const char* aName, void* aClosure)
|
|||
gPref->CopyCharPref(aName, &value);
|
||||
nsAutoString name;
|
||||
if (value) {
|
||||
name = value;
|
||||
name.AssignWithConversion(value);
|
||||
nsAllocator::Free(value);
|
||||
value = nsnull;
|
||||
FindFamily(search, &name);
|
||||
|
@ -2398,7 +2579,7 @@ PrefEnumCallback(const char* aName, void* aClosure)
|
|||
if (!search->mFont) {
|
||||
gPref->CopyDefaultCharPref(aName, &value);
|
||||
if (value) {
|
||||
name = value;
|
||||
name.AssignWithConversion(value);
|
||||
nsAllocator::Free(value);
|
||||
value = nsnull;
|
||||
FindFamily(search, &name);
|
||||
|
@ -2421,7 +2602,7 @@ nsFontMetricsGTK::FindGenericFont(nsFontSearch* aSearch)
|
|||
if (mTriedAllGenerics) {
|
||||
return;
|
||||
}
|
||||
nsAutoString prefix("font.name.");
|
||||
nsAutoString prefix(NS_ConvertASCIItoUCS2("font.name."));
|
||||
char* value = nsnull;
|
||||
if (mGeneric) {
|
||||
prefix.Append(*mGeneric);
|
||||
|
@ -2429,12 +2610,12 @@ nsFontMetricsGTK::FindGenericFont(nsFontSearch* aSearch)
|
|||
else {
|
||||
gPref->CopyCharPref("font.default", &value);
|
||||
if (value) {
|
||||
prefix.Append(value);
|
||||
prefix.AppendWithConversion(value);
|
||||
nsAllocator::Free(value);
|
||||
value = nsnull;
|
||||
}
|
||||
else {
|
||||
prefix.Append("serif");
|
||||
prefix.AppendWithConversion("serif");
|
||||
}
|
||||
}
|
||||
char name[128];
|
||||
|
@ -2448,7 +2629,7 @@ nsFontMetricsGTK::FindGenericFont(nsFontSearch* aSearch)
|
|||
gPref->CopyCharPref(name, &value);
|
||||
nsAutoString str;
|
||||
if (value) {
|
||||
str = value;
|
||||
str.AssignWithConversion(value);
|
||||
nsAllocator::Free(value);
|
||||
value = nsnull;
|
||||
FindFamily(aSearch, &str);
|
||||
|
@ -2459,7 +2640,7 @@ nsFontMetricsGTK::FindGenericFont(nsFontSearch* aSearch)
|
|||
value = nsnull;
|
||||
gPref->CopyDefaultCharPref(name, &value);
|
||||
if (value) {
|
||||
str = value;
|
||||
str.AssignWithConversion(value);
|
||||
nsAllocator::Free(value);
|
||||
value = nsnull;
|
||||
FindFamily(aSearch, &str);
|
||||
|
@ -2499,63 +2680,10 @@ nsFontMetricsGTK::FindSubstituteFont(nsFontSearch* aSearch)
|
|||
nsFontGTK*
|
||||
nsFontMetricsGTK::FindFont(PRUnichar aChar)
|
||||
{
|
||||
static nsString* gGeneric = nsnull;
|
||||
static int gInitialized = 0;
|
||||
if (!gInitialized) {
|
||||
gInitialized = 1;
|
||||
gFamilies = PL_NewHashTable(0, HashKey, CompareKeys, NULL, NULL, NULL);
|
||||
gFamilyNames = PL_NewHashTable(0, HashKey, CompareKeys, NULL, NULL, NULL);
|
||||
gGeneric = new nsAutoString();
|
||||
if (!gGeneric) {
|
||||
if (!gFamilies) {
|
||||
if (!InitFontTables()) {
|
||||
return nsnull;
|
||||
}
|
||||
nsFontFamilyName* f = gFamilyNameTable;
|
||||
while (f->mName) {
|
||||
nsString* name = new nsString(f->mName);
|
||||
nsString* xName;
|
||||
if (f->mXName) {
|
||||
xName = new nsString(f->mXName);
|
||||
}
|
||||
else {
|
||||
xName = gGeneric;
|
||||
}
|
||||
if (name && xName) {
|
||||
PL_HashTableAdd(gFamilyNames, name, (void*) xName);
|
||||
}
|
||||
f++;
|
||||
}
|
||||
gWeights = PL_NewHashTable(0, PL_HashString, PL_CompareStrings, NULL, NULL,
|
||||
NULL);
|
||||
nsFontPropertyName* p = gWeightNames;
|
||||
while (p->mName) {
|
||||
PL_HashTableAdd(gWeights, p->mName, (void*) p->mValue);
|
||||
p++;
|
||||
}
|
||||
gStretches = PL_NewHashTable(0, PL_HashString, PL_CompareStrings, NULL,
|
||||
NULL, NULL);
|
||||
p = gStretchNames;
|
||||
while (p->mName) {
|
||||
PL_HashTableAdd(gStretches, p->mName, (void*) p->mValue);
|
||||
p++;
|
||||
}
|
||||
gCharSets = PL_NewHashTable(0, PL_HashString, PL_CompareStrings, NULL, NULL,
|
||||
NULL);
|
||||
nsFontCharSetMap* charSetMap = gCharSetMap;
|
||||
while (charSetMap->mName) {
|
||||
PL_HashTableAdd(gCharSets, charSetMap->mName, (void*) charSetMap->mInfo);
|
||||
charSetMap++;
|
||||
}
|
||||
#ifdef MOZ_MATHML
|
||||
gSpecialCharSets = PL_NewHashTable
|
||||
(0, PL_HashString, PL_CompareStrings, NULL, NULL, NULL);
|
||||
nsFontCharSetMap* specialCharSetMap = gSpecialCharSetMap;
|
||||
while (specialCharSetMap->mName) {
|
||||
PL_HashTableAdd (gSpecialCharSets,
|
||||
specialCharSetMap->mName,
|
||||
(void*) specialCharSetMap->mInfo);
|
||||
specialCharSetMap++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
nsFontSearch search = { this, aChar, nsnull };
|
||||
|
|
Загрузка…
Ссылка в новой задаче