bug 769194 - support src:local(...) in @font-face rules on Android/FT2FontList. r=jdaggett

This commit is contained in:
Jonathan Kew 2014-04-08 09:10:41 +01:00
Родитель c1583aa029
Коммит cfba5219ed
3 изменённых файлов: 46 добавлений и 6 удалений

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

@ -351,6 +351,14 @@ gfxAndroidPlatform::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
aLength);
}
gfxFontEntry*
gfxAndroidPlatform::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
const nsAString& aFontName)
{
return gfxPlatformFontList::PlatformFontList()->LookupLocalFont(aProxyEntry,
aFontName);
}
TemporaryRef<ScaledFont>
gfxAndroidPlatform::GetScaledFontForFont(DrawTarget* aTarget, gfxFont *aFont)
{

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

@ -49,6 +49,8 @@ public:
virtual gfxPlatformFontList* CreatePlatformFontList();
virtual gfxFontEntry* MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
const uint8_t *aFontData, uint32_t aLength);
virtual gfxFontEntry* LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
const nsAString& aFontName);
virtual void GetCommonFallbackFonts(const uint32_t aCh,
int32_t aRunScript,

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

@ -1386,7 +1386,7 @@ struct FullFontNameSearch {
{ }
nsString mFullName;
gfxFontEntry *mFontEntry;
FT2FontEntry *mFontEntry;
};
// callback called for each family name, based on the assumption that the
@ -1400,17 +1400,22 @@ FindFullName(nsStringHashKey::KeyType aKey,
// does the family name match up to the length of the family name?
const nsString& family = aFontFamily->Name();
nsString fullNameFamily;
data->mFullName.Left(fullNameFamily, family.Length());
// if so, iterate over faces in this family to see if there is a match
if (family.Equals(fullNameFamily)) {
if (family.Equals(fullNameFamily, nsCaseInsensitiveStringComparator())) {
nsTArray<nsRefPtr<gfxFontEntry> >& fontList = aFontFamily->GetFontList();
int index, len = fontList.Length();
for (index = 0; index < len; index++) {
if (fontList[index]->Name().Equals(data->mFullName)) {
data->mFontEntry = fontList[index];
gfxFontEntry* fe = fontList[index];
if (!fe) {
continue;
}
if (fe->Name().Equals(data->mFullName,
nsCaseInsensitiveStringComparator())) {
data->mFontEntry = static_cast<FT2FontEntry*>(fe);
return PL_DHASH_STOP;
}
}
@ -1428,7 +1433,32 @@ gfxFT2FontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
mFontFamilies.Enumerate(FindFullName, &data);
return data.mFontEntry;
if (!data.mFontEntry) {
return nullptr;
}
// Clone the font entry so that we can then set its style descriptors
// from the proxy rather than the actual font.
// Ensure existence of mFTFace in the original entry
data.mFontEntry->CairoFontFace();
if (!data.mFontEntry->mFTFace) {
return nullptr;
}
FT2FontEntry* fe =
FT2FontEntry::CreateFontEntry(data.mFontEntry->mFTFace,
data.mFontEntry->mFilename.get(),
data.mFontEntry->mFTFontIndex,
data.mFontEntry->Name(), nullptr);
if (fe) {
fe->mItalic = aProxyEntry->mItalic;
fe->mWeight = aProxyEntry->mWeight;
fe->mStretch = aProxyEntry->mStretch;
fe->mIsUserFont = fe->mIsLocalUserFont = true;
}
return fe;
}
gfxFontFamily*