mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 542162 - Use fullname and Postscript name tables for src local lookups. r=jkew
This commit is contained in:
parent
dd61a69475
commit
1e792dd3a5
@ -246,6 +246,7 @@ protected:
|
||||
friend class gfxMacPlatformFontList;
|
||||
friend class gfxFcFontEntry;
|
||||
friend class gfxFontFamily;
|
||||
friend class gfxSingleFaceMacFontFamily;
|
||||
|
||||
gfxFontEntry() :
|
||||
mItalic(PR_FALSE), mFixedPitch(PR_FALSE),
|
||||
@ -284,9 +285,6 @@ struct FontSearch {
|
||||
nsRefPtr<gfxFontEntry> mBestMatch;
|
||||
};
|
||||
|
||||
// helper class for adding other family names back into font cache
|
||||
class AddOtherFamilyNameFunctor;
|
||||
|
||||
class gfxFontFamily {
|
||||
public:
|
||||
THEBES_INLINE_DECL_REFCOUNTING(gfxFontFamily)
|
||||
@ -295,6 +293,7 @@ public:
|
||||
mName(aName),
|
||||
mOtherFamilyNamesInitialized(PR_FALSE),
|
||||
mHasOtherFamilyNames(PR_FALSE),
|
||||
mFaceNamesInitialized(PR_FALSE),
|
||||
mHasStyles(PR_FALSE),
|
||||
mIsSimpleFamily(PR_FALSE),
|
||||
mIsBadUnderlineFamily(PR_FALSE)
|
||||
@ -328,7 +327,12 @@ public:
|
||||
void FindFontForChar(FontSearch *aMatchData);
|
||||
|
||||
// read in other family names, if any, and use functor to add each into cache
|
||||
virtual void ReadOtherFamilyNames(AddOtherFamilyNameFunctor& aOtherFamilyFunctor);
|
||||
virtual void ReadOtherFamilyNames(gfxPlatformFontList *aPlatformFontList);
|
||||
|
||||
// read in other localized family names, fullnames and Postscript names
|
||||
// for all faces and append to lookup tables
|
||||
virtual void ReadFaceNames(gfxPlatformFontList *aPlatformFontList,
|
||||
PRBool aNeedFullnamePostscriptNames);
|
||||
|
||||
// find faces belonging to this family (platform implementations override this;
|
||||
// should be made pure virtual once all subclasses have been updated)
|
||||
@ -370,8 +374,8 @@ protected:
|
||||
virtual PRBool FindWeightsForStyle(gfxFontEntry* aFontsForWeights[],
|
||||
PRBool anItalic, PRInt16 aStretch);
|
||||
|
||||
PRBool ReadOtherFamilyNamesForFace(AddOtherFamilyNameFunctor& aOtherFamilyFunctor,
|
||||
gfxFontEntry *aFontEntry,
|
||||
PRBool ReadOtherFamilyNamesForFace(gfxPlatformFontList *aPlatformFontList,
|
||||
nsTArray<PRUint8>& aNameTable,
|
||||
PRBool useFullName = PR_FALSE);
|
||||
|
||||
// set whether this font family is in "bad" underline offset blacklist.
|
||||
@ -388,6 +392,7 @@ protected:
|
||||
nsTArray<nsRefPtr<gfxFontEntry> > mAvailableFonts;
|
||||
PRPackedBool mOtherFamilyNamesInitialized;
|
||||
PRPackedBool mHasOtherFamilyNames;
|
||||
PRPackedBool mFaceNamesInitialized;
|
||||
PRPackedBool mHasStyles;
|
||||
PRPackedBool mIsSimpleFamily;
|
||||
PRPackedBool mIsBadUnderlineFamily;
|
||||
|
@ -195,17 +195,9 @@ gfxFT2FontList::FindFonts()
|
||||
void
|
||||
gfxFT2FontList::InitFontList()
|
||||
{
|
||||
mFontFamilies.Clear();
|
||||
mOtherFamilyNames.Clear();
|
||||
mOtherFamilyNamesInitialized = PR_FALSE;
|
||||
mPrefFonts.Clear();
|
||||
CancelLoader();
|
||||
|
||||
// initialize ranges of characters for which system-wide font search should be skipped
|
||||
mCodepointsWithNoFonts.reset();
|
||||
mCodepointsWithNoFonts.SetRange(0,0x1f); // C0 controls
|
||||
mCodepointsWithNoFonts.SetRange(0x7f,0x9f); // C1 controls
|
||||
|
||||
// reset font lists
|
||||
gfxPlatformFontList::InitFontList();
|
||||
|
||||
FindFonts();
|
||||
}
|
||||
|
||||
|
@ -154,8 +154,7 @@ gfxFontFamily::HasOtherFamilyNames()
|
||||
{
|
||||
// need to read in other family names to determine this
|
||||
if (!mOtherFamilyNamesInitialized) {
|
||||
AddOtherFamilyNameFunctor addOtherNames(gfxPlatformFontList::PlatformFontList());
|
||||
ReadOtherFamilyNames(addOtherNames); // sets mHasOtherFamilyNames
|
||||
ReadOtherFamilyNames(gfxPlatformFontList::PlatformFontList()); // sets mHasOtherFamilyNames
|
||||
}
|
||||
return mHasOtherFamilyNames;
|
||||
}
|
||||
@ -500,21 +499,14 @@ gfxFontFamily::FindFontForChar(FontSearch *aMatchData)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// returns true if other names were found, false otherwise
|
||||
PRBool
|
||||
gfxFontFamily::ReadOtherFamilyNamesForFace(AddOtherFamilyNameFunctor& aOtherFamilyFunctor,
|
||||
gfxFontEntry *aFontEntry,
|
||||
gfxFontFamily::ReadOtherFamilyNamesForFace(gfxPlatformFontList *aPlatformFontList,
|
||||
nsTArray<PRUint8>& aNameTable,
|
||||
PRBool useFullName)
|
||||
{
|
||||
const PRUint32 kNAME = TRUETYPE_TAG('n','a','m','e');
|
||||
|
||||
nsAutoTArray<PRUint8,8192> buffer;
|
||||
if (aFontEntry->GetFontTable(kNAME, buffer) != NS_OK)
|
||||
return PR_FALSE;
|
||||
|
||||
const PRUint8 *nameData = buffer.Elements();
|
||||
PRUint32 dataLength = buffer.Length();
|
||||
const PRUint8 *nameData = aNameTable.Elements();
|
||||
PRUint32 dataLength = aNameTable.Length();
|
||||
const gfxFontUtils::NameHeader *nameHeader =
|
||||
reinterpret_cast<const gfxFontUtils::NameHeader*>(nameData);
|
||||
|
||||
@ -551,7 +543,7 @@ gfxFontFamily::ReadOtherFamilyNamesForFace(AddOtherFamilyNameFunctor& aOtherFami
|
||||
otherFamilyName);
|
||||
// add if not same as canonical family name
|
||||
if (ok && otherFamilyName != mName) {
|
||||
aOtherFamilyFunctor(this, otherFamilyName);
|
||||
aPlatformFontList->AddOtherFamilyName(this, otherFamilyName);
|
||||
foundNames = PR_TRUE;
|
||||
}
|
||||
}
|
||||
@ -562,7 +554,7 @@ gfxFontFamily::ReadOtherFamilyNamesForFace(AddOtherFamilyNameFunctor& aOtherFami
|
||||
|
||||
|
||||
void
|
||||
gfxFontFamily::ReadOtherFamilyNames(AddOtherFamilyNameFunctor& aOtherFamilyFunctor)
|
||||
gfxFontFamily::ReadOtherFamilyNames(gfxPlatformFontList *aPlatformFontList)
|
||||
{
|
||||
if (mOtherFamilyNamesInitialized)
|
||||
return;
|
||||
@ -571,30 +563,104 @@ gfxFontFamily::ReadOtherFamilyNames(AddOtherFamilyNameFunctor& aOtherFamilyFunct
|
||||
FindStyleVariations();
|
||||
|
||||
// read in other family names for the first face in the list
|
||||
PRUint32 numFonts = mAvailableFonts.Length();
|
||||
PRUint32 i;
|
||||
PRUint32 i, numFonts = mAvailableFonts.Length();
|
||||
const PRUint32 kNAME = TRUETYPE_TAG('n','a','m','e');
|
||||
nsAutoTArray<PRUint8,8192> buffer;
|
||||
|
||||
for (i = 0; i < numFonts; ++i) {
|
||||
if (!mAvailableFonts[i])
|
||||
gfxFontEntry *fe = mAvailableFonts[i];
|
||||
if (!fe)
|
||||
continue;
|
||||
mHasOtherFamilyNames = ReadOtherFamilyNamesForFace(aOtherFamilyFunctor,
|
||||
mAvailableFonts[i].get());
|
||||
|
||||
if (fe->GetFontTable(kNAME, buffer) != NS_OK)
|
||||
continue;
|
||||
|
||||
mHasOtherFamilyNames = ReadOtherFamilyNamesForFace(aPlatformFontList,
|
||||
buffer);
|
||||
break;
|
||||
}
|
||||
|
||||
// read in other names for the first face in the list with the assumption
|
||||
// that if extra names don't exist in that face then they don't exist in
|
||||
// other faces for the same font
|
||||
if (mHasOtherFamilyNames) {
|
||||
// read in names for all faces, needed to catch cases where fonts have
|
||||
// family names for individual weights (e.g. Hiragino Kaku Gothic Pro W6)
|
||||
for ( ; i < numFonts; i++) {
|
||||
if (!mAvailableFonts[i])
|
||||
continue;
|
||||
ReadOtherFamilyNamesForFace(aOtherFamilyFunctor, mAvailableFonts[i].get());
|
||||
}
|
||||
if (!mHasOtherFamilyNames)
|
||||
return;
|
||||
|
||||
// read in names for all faces, needed to catch cases where fonts have
|
||||
// family names for individual weights (e.g. Hiragino Kaku Gothic Pro W6)
|
||||
for ( ; i < numFonts; i++) {
|
||||
gfxFontEntry *fe = mAvailableFonts[i];
|
||||
if (!fe)
|
||||
continue;
|
||||
|
||||
if (fe->GetFontTable(kNAME, buffer) != NS_OK)
|
||||
continue;
|
||||
|
||||
ReadOtherFamilyNamesForFace(aPlatformFontList, buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxFontFamily::ReadFaceNames(gfxPlatformFontList *aPlatformFontList,
|
||||
PRBool aNeedFullnamePostscriptNames)
|
||||
{
|
||||
// if all needed names have already been read, skip
|
||||
if (mOtherFamilyNamesInitialized &&
|
||||
(mFaceNamesInitialized || !aNeedFullnamePostscriptNames))
|
||||
return;
|
||||
|
||||
FindStyleVariations();
|
||||
|
||||
PRUint32 i, numFonts = mAvailableFonts.Length();
|
||||
const PRUint32 kNAME = TRUETYPE_TAG('n','a','m','e');
|
||||
nsAutoTArray<PRUint8,8192> buffer;
|
||||
nsAutoString fullname, psname;
|
||||
|
||||
PRBool firstTime = PR_TRUE, readAllFaces = PR_FALSE;
|
||||
for (i = 0; i < numFonts; ++i) {
|
||||
gfxFontEntry *fe = mAvailableFonts[i];
|
||||
if (!fe)
|
||||
continue;
|
||||
|
||||
if (fe->GetFontTable(kNAME, buffer) != NS_OK)
|
||||
continue;
|
||||
|
||||
if (aNeedFullnamePostscriptNames) {
|
||||
if (gfxFontUtils::ReadCanonicalName(
|
||||
buffer, gfxFontUtils::NAME_ID_FULL, fullname) == NS_OK)
|
||||
{
|
||||
aPlatformFontList->AddFullname(fe, fullname);
|
||||
}
|
||||
|
||||
if (gfxFontUtils::ReadCanonicalName(
|
||||
buffer, gfxFontUtils::NAME_ID_POSTSCRIPT, psname) == NS_OK)
|
||||
{
|
||||
aPlatformFontList->AddPostscriptName(fe, psname);
|
||||
}
|
||||
}
|
||||
|
||||
if (!mOtherFamilyNamesInitialized && (firstTime || readAllFaces)) {
|
||||
PRBool foundOtherName = ReadOtherFamilyNamesForFace(aPlatformFontList,
|
||||
buffer);
|
||||
|
||||
// if the first face has a different name, scan all faces, otherwise
|
||||
// assume the family doesn't have other names
|
||||
if (firstTime && foundOtherName) {
|
||||
mHasOtherFamilyNames = PR_TRUE;
|
||||
readAllFaces = PR_TRUE;
|
||||
}
|
||||
firstTime = PR_FALSE;
|
||||
}
|
||||
|
||||
// if not reading in any more names, skip other faces
|
||||
if (!readAllFaces && !aNeedFullnamePostscriptNames)
|
||||
break;
|
||||
}
|
||||
|
||||
mFaceNamesInitialized = PR_TRUE;
|
||||
mOtherFamilyNamesInitialized = PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
gfxFontEntry*
|
||||
gfxFontFamily::FindFont(const nsAString& aPostscriptName)
|
||||
|
@ -438,7 +438,7 @@ GDIFontFamily::FamilyAddStylesProc(const ENUMLOGFONTEXW *lpelfe,
|
||||
}
|
||||
}
|
||||
|
||||
fe = GDIFontEntry::CreateFontEntry(ff->mName, feType, (logFont.lfItalic == 0xFF),
|
||||
fe = GDIFontEntry::CreateFontEntry(nsDependentString(lpelfe->elfFullName), feType, (logFont.lfItalic == 0xFF),
|
||||
(PRUint16) (logFont.lfWeight), nsnull);
|
||||
if (!fe)
|
||||
return 1;
|
||||
@ -592,18 +592,11 @@ gfxGDIFontList::InitFontList()
|
||||
if (fc)
|
||||
fc->AgeAllGenerations();
|
||||
|
||||
mFontFamilies.Clear();
|
||||
mOtherFamilyNames.Clear();
|
||||
mOtherFamilyNamesInitialized = PR_FALSE;
|
||||
mPrefFonts.Clear();
|
||||
// reset font lists
|
||||
gfxPlatformFontList::InitFontList();
|
||||
|
||||
mFontSubstitutes.Clear();
|
||||
mNonExistingFonts.Clear();
|
||||
CancelLoader();
|
||||
|
||||
// initialize ranges of characters for which system-wide font search should be skipped
|
||||
mCodepointsWithNoFonts.reset();
|
||||
mCodepointsWithNoFonts.SetRange(0,0x1f); // C0 controls
|
||||
mCodepointsWithNoFonts.SetRange(0x7f,0x9f); // C1 controls
|
||||
|
||||
// iterate over available families
|
||||
LOGFONTW logfont;
|
||||
@ -652,63 +645,36 @@ gfxFontEntry*
|
||||
gfxGDIFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
|
||||
const nsAString& aFullname)
|
||||
{
|
||||
LOGFONTW logFont;
|
||||
memset(&logFont, 0, sizeof(LOGFONTW));
|
||||
logFont.lfCharSet = DEFAULT_CHARSET;
|
||||
PRUint32 namelen = PR_MIN(aFullname.Length(), LF_FACESIZE - 1);
|
||||
::memcpy(logFont.lfFaceName,
|
||||
nsPromiseFlatString(aFullname).get(),
|
||||
namelen * sizeof(PRUnichar));
|
||||
logFont.lfFaceName[namelen] = 0;
|
||||
PRBool found;
|
||||
gfxFontEntry *lookup;
|
||||
|
||||
AutoDC dc;
|
||||
::SetGraphicsMode(dc.GetDC(), GM_ADVANCED);
|
||||
|
||||
AutoSelectFont font(dc.GetDC(), &logFont);
|
||||
if (!font.IsValid())
|
||||
return nsnull;
|
||||
|
||||
// fetch fullname from name table (Windows takes swapped tag order)
|
||||
const PRUint32 kNameTag = NS_SWAP32(TRUETYPE_TAG('n','a','m','e'));
|
||||
nsAutoString fullName;
|
||||
|
||||
{
|
||||
DWORD len = ::GetFontData(dc.GetDC(), kNameTag, 0, nsnull, 0);
|
||||
if (len == GDI_ERROR || len == 0) // not a truetype font --
|
||||
return nsnull; // so just ignore
|
||||
|
||||
nsAutoTArray<PRUint8,1024> nameData;
|
||||
if (!nameData.AppendElements(len))
|
||||
return nsnull;
|
||||
PRUint8 *nameTable = nameData.Elements();
|
||||
|
||||
DWORD newLen = ::GetFontData(dc.GetDC(), kNameTag, 0, nameTable, len);
|
||||
if (newLen != len)
|
||||
return nsnull;
|
||||
|
||||
nsresult rv;
|
||||
rv = gfxFontUtils::ReadCanonicalName(nameData,
|
||||
gfxFontUtils::NAME_ID_FULL,
|
||||
fullName);
|
||||
if (NS_FAILED(rv))
|
||||
return nsnull;
|
||||
// initialize name lookup tables if needed
|
||||
if (!mFaceNamesInitialized) {
|
||||
InitFaceNameLists();
|
||||
}
|
||||
|
||||
// reject if different from canonical fullname
|
||||
if (!aFullname.Equals(fullName))
|
||||
// lookup in name lookup tables, return null if not found
|
||||
if (!(lookup = mPostscriptNames.GetWeak(aFullname, &found)) &&
|
||||
!(lookup = mFullnames.GetWeak(aFullname, &found)))
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
// create a new font entry
|
||||
// create a new font entry with the proxy entry style characteristics
|
||||
PRUint16 w = (aProxyEntry->mWeight == 0 ? 400 : aProxyEntry->mWeight);
|
||||
PRBool isCFF = PR_FALSE; // jtdfix -- need to determine this
|
||||
|
||||
gfxFontEntry *fe = GDIFontEntry::CreateFontEntry(aFullname,
|
||||
// use the face name from the lookup font entry, which will be the localized
|
||||
// face name which GDI mapping tables use (e.g. with the system locale set to
|
||||
// Dutch, a fullname of 'Arial Bold' will find a font entry with the face name
|
||||
// 'Arial Vet' which can be used as a key in GDI font lookups).
|
||||
gfxFontEntry *fe = GDIFontEntry::CreateFontEntry(lookup->Name(),
|
||||
gfxWindowsFontType(isCFF ? GFX_FONT_TYPE_PS_OPENTYPE : GFX_FONT_TYPE_TRUETYPE) /*type*/,
|
||||
PRUint32(aProxyEntry->mItalic ? FONT_STYLE_ITALIC : FONT_STYLE_NORMAL),
|
||||
w, nsnull);
|
||||
|
||||
if (!fe)
|
||||
return fe;
|
||||
return nsnull;
|
||||
|
||||
fe->mIsUserFont = PR_TRUE;
|
||||
return fe;
|
||||
|
@ -548,7 +548,7 @@ public:
|
||||
|
||||
virtual void LocalizedName(nsAString& aLocalizedName);
|
||||
|
||||
virtual void ReadOtherFamilyNames(AddOtherFamilyNameFunctor& aOtherFamilyFunctor);
|
||||
virtual void ReadOtherFamilyNames(gfxPlatformFontList *aPlatformFontList);
|
||||
};
|
||||
|
||||
void
|
||||
@ -575,13 +575,23 @@ gfxSingleFaceMacFontFamily::LocalizedName(nsAString& aLocalizedName)
|
||||
}
|
||||
|
||||
void
|
||||
gfxSingleFaceMacFontFamily::ReadOtherFamilyNames(AddOtherFamilyNameFunctor& aOtherFamilyFunctor)
|
||||
gfxSingleFaceMacFontFamily::ReadOtherFamilyNames(gfxPlatformFontList *aPlatformFontList)
|
||||
{
|
||||
if (mOtherFamilyNamesInitialized)
|
||||
return;
|
||||
|
||||
mHasOtherFamilyNames = ReadOtherFamilyNamesForFace(aOtherFamilyFunctor,
|
||||
mAvailableFonts[0].get(),
|
||||
gfxFontEntry *fe = mAvailableFonts[0];
|
||||
if (!fe)
|
||||
return;
|
||||
|
||||
const PRUint32 kNAME = TRUETYPE_TAG('n','a','m','e');
|
||||
nsAutoTArray<PRUint8,8192> buffer;
|
||||
|
||||
if (fe->GetFontTable(kNAME, buffer) != NS_OK)
|
||||
return;
|
||||
|
||||
mHasOtherFamilyNames = ReadOtherFamilyNamesForFace(aPlatformFontList,
|
||||
buffer,
|
||||
PR_TRUE);
|
||||
mOtherFamilyNamesInitialized = PR_TRUE;
|
||||
}
|
||||
@ -591,7 +601,7 @@ gfxSingleFaceMacFontFamily::ReadOtherFamilyNames(AddOtherFamilyNameFunctor& aOth
|
||||
#pragma mark-
|
||||
|
||||
gfxMacPlatformFontList::gfxMacPlatformFontList() :
|
||||
mATSGeneration(PRUint32(kATSGenerationInitial))
|
||||
gfxPlatformFontList(PR_FALSE), mATSGeneration(PRUint32(kATSGenerationInitial))
|
||||
{
|
||||
::ATSFontNotificationSubscribe(ATSNotification,
|
||||
kATSFontNotifyOptionDefault,
|
||||
@ -618,17 +628,9 @@ gfxMacPlatformFontList::InitFontList()
|
||||
mATSGeneration = currentGeneration;
|
||||
PR_LOG(gFontInfoLog, PR_LOG_DEBUG, ("(fontinit) updating to generation: %d", mATSGeneration));
|
||||
|
||||
mFontFamilies.Clear();
|
||||
mOtherFamilyNames.Clear();
|
||||
mOtherFamilyNamesInitialized = PR_FALSE;
|
||||
mPrefFonts.Clear();
|
||||
CancelLoader();
|
||||
|
||||
// initialize ranges of characters for which system-wide font search should be skipped
|
||||
mCodepointsWithNoFonts.reset();
|
||||
mCodepointsWithNoFonts.SetRange(0,0x1f); // C0 controls
|
||||
mCodepointsWithNoFonts.SetRange(0x7f,0x9f); // C1 controls
|
||||
|
||||
// reset font lists
|
||||
gfxPlatformFontList::InitFontList();
|
||||
|
||||
// iterate over available families
|
||||
NSEnumerator *families = [[sFontManager availableFontFamilies]
|
||||
objectEnumerator]; // returns "canonical", non-localized family name
|
||||
|
@ -103,12 +103,20 @@ gfxFontListPrefObserver::Observe(nsISupports *aSubject,
|
||||
}
|
||||
|
||||
|
||||
gfxPlatformFontList::gfxPlatformFontList()
|
||||
: mStartIndex(0), mIncrement(kNumFontsPerSlice), mNumFamilies(0)
|
||||
gfxPlatformFontList::gfxPlatformFontList(PRBool aNeedFullnamePostscriptNames)
|
||||
: mNeedFullnamePostscriptNames(aNeedFullnamePostscriptNames),
|
||||
mStartIndex(0), mIncrement(kNumFontsPerSlice), mNumFamilies(0)
|
||||
{
|
||||
mFontFamilies.Init(100);
|
||||
mOtherFamilyNames.Init(30);
|
||||
mOtherFamilyNamesInitialized = PR_FALSE;
|
||||
|
||||
if (mNeedFullnamePostscriptNames) {
|
||||
mFullnames.Init(100);
|
||||
mPostscriptNames.Init(100);
|
||||
}
|
||||
mFaceNamesInitialized = PR_FALSE;
|
||||
|
||||
mPrefFonts.Init(10);
|
||||
|
||||
mBadUnderlineFamilyNames.Init(10);
|
||||
@ -128,6 +136,26 @@ gfxPlatformFontList::gfxPlatformFontList()
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatformFontList::InitFontList()
|
||||
{
|
||||
mFontFamilies.Clear();
|
||||
mOtherFamilyNames.Clear();
|
||||
mOtherFamilyNamesInitialized = PR_FALSE;
|
||||
if (mNeedFullnamePostscriptNames) {
|
||||
mFullnames.Clear();
|
||||
mPostscriptNames.Clear();
|
||||
}
|
||||
mFaceNamesInitialized = PR_FALSE;
|
||||
mPrefFonts.Clear();
|
||||
CancelLoader();
|
||||
|
||||
// initialize ranges of characters for which system-wide font search should be skipped
|
||||
mCodepointsWithNoFonts.reset();
|
||||
mCodepointsWithNoFonts.SetRange(0,0x1f); // C0 controls
|
||||
mCodepointsWithNoFonts.SetRange(0x7f,0x9f); // C1 controls
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatformFontList::GenerateFontListKey(const nsAString& aKeyName, nsAString& aResult)
|
||||
{
|
||||
@ -150,20 +178,27 @@ gfxPlatformFontList::InitOtherFamilyNamesProc(nsStringHashKey::KeyType aKey,
|
||||
void* userArg)
|
||||
{
|
||||
gfxPlatformFontList *fc = static_cast<gfxPlatformFontList*>(userArg);
|
||||
AddOtherFamilyNameFunctor addOtherNames(fc);
|
||||
aFamilyEntry->ReadOtherFamilyNames(addOtherNames);
|
||||
aFamilyEntry->ReadOtherFamilyNames(fc);
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatformFontList::ReadOtherFamilyNamesForFamily(const nsAString& aFamilyName)
|
||||
gfxPlatformFontList::InitFaceNameLists()
|
||||
{
|
||||
gfxFontFamily *familyEntry = FindFamily(aFamilyName);
|
||||
mFaceNamesInitialized = PR_TRUE;
|
||||
|
||||
if (familyEntry) {
|
||||
AddOtherFamilyNameFunctor addOtherNames(this);
|
||||
familyEntry->ReadOtherFamilyNames(addOtherNames);
|
||||
}
|
||||
// iterate over all font families and read in other family names
|
||||
mFontFamilies.Enumerate(gfxPlatformFontList::InitFaceNameListsProc, this);
|
||||
}
|
||||
|
||||
PLDHashOperator PR_CALLBACK
|
||||
gfxPlatformFontList::InitFaceNameListsProc(nsStringHashKey::KeyType aKey,
|
||||
nsRefPtr<gfxFontFamily>& aFamilyEntry,
|
||||
void* userArg)
|
||||
{
|
||||
gfxPlatformFontList *fc = static_cast<gfxPlatformFontList*>(userArg);
|
||||
aFamilyEntry->ReadFaceNames(fc, fc->NeedFullnamePostscriptNames());
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
||||
void
|
||||
@ -181,8 +216,7 @@ gfxPlatformFontList::PreloadNamesList()
|
||||
// only search canonical names!
|
||||
gfxFontFamily *familyEntry = mFontFamilies.GetWeak(key, &found);
|
||||
if (familyEntry) {
|
||||
AddOtherFamilyNameFunctor addOtherNames(this);
|
||||
familyEntry->ReadOtherFamilyNames(addOtherNames);
|
||||
familyEntry->ReadOtherFamilyNames(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -437,6 +471,32 @@ gfxPlatformFontList::AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsAString&
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatformFontList::AddFullname(gfxFontEntry *aFontEntry, nsAString& aFullname)
|
||||
{
|
||||
PRBool found;
|
||||
|
||||
if (!mFullnames.GetWeak(aFullname, &found)) {
|
||||
mFullnames.Put(aFullname, aFontEntry);
|
||||
PR_LOG(gFontListLog, PR_LOG_DEBUG, ("(fontlist-fullname) name: %s, fullname: %s\n",
|
||||
NS_ConvertUTF16toUTF8(aFontEntry->Name()).get(),
|
||||
NS_ConvertUTF16toUTF8(aFullname).get()));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxPlatformFontList::AddPostscriptName(gfxFontEntry *aFontEntry, nsAString& aPostscriptName)
|
||||
{
|
||||
PRBool found;
|
||||
|
||||
if (!mPostscriptNames.GetWeak(aPostscriptName, &found)) {
|
||||
mPostscriptNames.Put(aPostscriptName, aFontEntry);
|
||||
PR_LOG(gFontListLog, PR_LOG_DEBUG, ("(fontlist-postscript) name: %s, psname: %s\n",
|
||||
NS_ConvertUTF16toUTF8(aFontEntry->Name()).get(),
|
||||
NS_ConvertUTF16toUTF8(aPostscriptName).get()));
|
||||
}
|
||||
}
|
||||
|
||||
PRBool
|
||||
gfxPlatformFontList::GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName)
|
||||
{
|
||||
@ -459,7 +519,6 @@ gfxPlatformFontList::RunLoader()
|
||||
PRUint32 i, endIndex = (mStartIndex + mIncrement < mNumFamilies ? mStartIndex + mIncrement : mNumFamilies);
|
||||
|
||||
// for each font family, load in various font info
|
||||
AddOtherFamilyNameFunctor addOtherNames(this);
|
||||
for (i = mStartIndex; i < endIndex; i++) {
|
||||
gfxFontFamily* familyEntry = mFontFamiliesToLoad[i];
|
||||
|
||||
@ -469,8 +528,8 @@ gfxPlatformFontList::RunLoader()
|
||||
// load the cmaps
|
||||
familyEntry->ReadCMAP();
|
||||
|
||||
// read in other family names
|
||||
familyEntry->ReadOtherFamilyNames(addOtherNames);
|
||||
// read in face names
|
||||
familyEntry->ReadFaceNames(this, mNeedFullnamePostscriptNames);
|
||||
|
||||
// check whether the family can be considered "simple" for style matching
|
||||
familyEntry->CheckForSimpleFamily();
|
||||
|
@ -95,8 +95,16 @@ public:
|
||||
PRBool GetPrefFontFamilyEntries(eFontPrefLang aLangGroup, nsTArray<nsRefPtr<gfxFontFamily> > *array);
|
||||
void SetPrefFontFamilyEntries(eFontPrefLang aLangGroup, nsTArray<nsRefPtr<gfxFontFamily> >& array);
|
||||
|
||||
// name lookup table methods
|
||||
|
||||
void AddOtherFamilyName(gfxFontFamily *aFamilyEntry, nsAString& aOtherFamilyName);
|
||||
|
||||
void AddFullname(gfxFontEntry *aFontEntry, nsAString& aFullname);
|
||||
|
||||
void AddPostscriptName(gfxFontEntry *aFontEntry, nsAString& aPostscriptName);
|
||||
|
||||
PRBool NeedFullnamePostscriptNames() { return mNeedFullnamePostscriptNames; }
|
||||
|
||||
// pure virtual functions, to be provided by concrete subclasses
|
||||
|
||||
// get the system default font
|
||||
@ -118,7 +126,7 @@ public:
|
||||
virtual PRBool GetStandardFamilyName(const nsAString& aFontName, nsAString& aFamilyName);
|
||||
|
||||
protected:
|
||||
gfxPlatformFontList();
|
||||
gfxPlatformFontList(PRBool aNeedFullnamePostscriptNames = PR_TRUE);
|
||||
|
||||
static gfxPlatformFontList *sPlatformFontList;
|
||||
|
||||
@ -126,15 +134,23 @@ protected:
|
||||
nsRefPtr<gfxFontFamily>& aFamilyEntry,
|
||||
void* userArg);
|
||||
|
||||
// initialize font lists [pure virtual]
|
||||
virtual void InitFontList() = 0;
|
||||
|
||||
// read secondary family names
|
||||
void ReadOtherFamilyNamesForFamily(const nsAString& aFamilyName);
|
||||
// initialize font lists
|
||||
virtual void InitFontList();
|
||||
|
||||
// separate initialization for reading in name tables, since this is expensive
|
||||
void InitOtherFamilyNames();
|
||||
|
||||
static PLDHashOperator InitOtherFamilyNamesProc(nsStringHashKey::KeyType aKey,
|
||||
nsRefPtr<gfxFontFamily>& aFamilyEntry,
|
||||
void* userArg);
|
||||
|
||||
// read in all fullname/Postscript names for all font faces
|
||||
void InitFaceNameLists();
|
||||
|
||||
static PLDHashOperator InitFaceNameListsProc(nsStringHashKey::KeyType aKey,
|
||||
nsRefPtr<gfxFontFamily>& aFamilyEntry,
|
||||
void* userArg);
|
||||
|
||||
// commonly used fonts for which the name table should be loaded at startup
|
||||
virtual void PreloadNamesList();
|
||||
|
||||
@ -144,10 +160,6 @@ protected:
|
||||
// explicitly set fixed-pitch flag for all faces
|
||||
void SetFixedPitch(const nsAString& aFamilyName);
|
||||
|
||||
static PLDHashOperator InitOtherFamilyNamesProc(nsStringHashKey::KeyType aKey,
|
||||
nsRefPtr<gfxFontFamily>& aFamilyEntry,
|
||||
void* userArg);
|
||||
|
||||
void GenerateFontListKey(const nsAString& aKeyName, nsAString& aResult);
|
||||
|
||||
static PLDHashOperator
|
||||
@ -160,12 +172,27 @@ protected:
|
||||
virtual PRBool RunLoader();
|
||||
virtual void FinishLoader();
|
||||
|
||||
// canonical family name ==> family entry (unique, one name per family entry)
|
||||
nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> mFontFamilies;
|
||||
// canonical family name ==> family entry (unique, one name per family entry)
|
||||
nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> mFontFamilies;
|
||||
|
||||
// flag set after InitOtherFamilyNames is called upon first name lookup miss
|
||||
PRPackedBool mOtherFamilyNamesInitialized;
|
||||
|
||||
// other family name ==> family entry (not unique, can have multiple names per
|
||||
// family entry, only names *other* than the canonical names are stored here)
|
||||
nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> mOtherFamilyNames;
|
||||
// other family name ==> family entry (not unique, can have multiple names per
|
||||
// family entry, only names *other* than the canonical names are stored here)
|
||||
nsRefPtrHashtable<nsStringHashKey, gfxFontFamily> mOtherFamilyNames;
|
||||
|
||||
// flag set after fullname and Postcript name lists are populated
|
||||
PRPackedBool mFaceNamesInitialized;
|
||||
|
||||
// whether these are needed for a given platform
|
||||
PRPackedBool mNeedFullnamePostscriptNames;
|
||||
|
||||
// fullname ==> font entry (unique, one name per font entry)
|
||||
nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> mFullnames;
|
||||
|
||||
// Postscript name ==> font entry (unique, one name per font entry)
|
||||
nsRefPtrHashtable<nsStringHashKey, gfxFontEntry> mPostscriptNames;
|
||||
|
||||
// cached pref font lists
|
||||
// maps list of family names ==> array of family entries, one per lang group
|
||||
@ -178,9 +205,6 @@ protected:
|
||||
// on pages with lots of problems
|
||||
nsString mReplacementCharFallbackFamily;
|
||||
|
||||
// flag set after InitOtherFamilyNames is called upon first name lookup miss
|
||||
PRPackedBool mOtherFamilyNamesInitialized;
|
||||
|
||||
nsTHashtable<nsStringHashKey> mBadUnderlineFamilyNames;
|
||||
|
||||
// data used as part of the font cmap loading process
|
||||
@ -190,21 +214,4 @@ protected:
|
||||
PRUint32 mNumFamilies;
|
||||
};
|
||||
|
||||
|
||||
// helper class for adding other family names back into font cache
|
||||
class AddOtherFamilyNameFunctor
|
||||
{
|
||||
public:
|
||||
AddOtherFamilyNameFunctor(gfxPlatformFontList *aFontList) :
|
||||
mFontList(aFontList)
|
||||
{}
|
||||
|
||||
void operator() (gfxFontFamily *aFamilyEntry, nsAString& aOtherName) {
|
||||
mFontList->AddOtherFamilyName(aFamilyEntry, aOtherName);
|
||||
}
|
||||
|
||||
gfxPlatformFontList *mFontList;
|
||||
};
|
||||
|
||||
|
||||
#endif /* GFXPLATFORMFONTLIST_H_ */
|
||||
|
@ -34,8 +34,9 @@ HTTP(..) == src-list-local-fallback.html src-list-local-fallback-ref.html
|
||||
# localized full fontnames should *not* match, only English ones (need locale-invariant key)
|
||||
skip HTTP(..) == src-list-local-localized.html src-list-local-localized-ref.html # 486787, 486497
|
||||
|
||||
# Postscript name lookup only supported on MacOS currently
|
||||
random-if(MOZ_WIDGET_TOOLKIT!="cocoa") == src-list-local-ps.html src-list-local-full-ref.html
|
||||
# Postscript name lookup only supported on MacOS/Windows currently
|
||||
random-if(MOZ_WIDGET_TOOLKIT=="gtk2") == src-list-local-ps.html src-list-local-full-ref.html
|
||||
# Mac-specific test of 100 weight faces
|
||||
random-if(MOZ_WIDGET_TOOLKIT!="cocoa") == helveticaneue-ultra.html helveticaneue-ultra-ref.html
|
||||
|
||||
# FIXME: The behavior here is neither mandated nor specified by the spec, but
|
||||
|
@ -26,7 +26,7 @@ body {
|
||||
|
||||
@font-face {
|
||||
font-family: test-italic;
|
||||
src: local(HelveticaNeue-Italic), local(BitstreamVeraSans-Oblique), local(ArialItalicMT);
|
||||
src: local(HelveticaNeue-Italic), local(BitstreamVeraSans-Oblique), local(Arial-ItalicMT);
|
||||
}
|
||||
|
||||
.regular { font-family: test-regular, serif; }
|
||||
|
Loading…
Reference in New Issue
Block a user