зеркало из https://github.com/mozilla/pjs.git
bug 737315 - use the proxy's name for the FT2 entry when instantiating a downloaded font. r=jdaggett
This commit is contained in:
Родитель
7a7374019e
Коммит
03f0ee0580
|
@ -177,7 +177,11 @@ FT2FontEntry::CreateFontEntry(const gfxProxyFontEntry &aProxyEntry,
|
|||
NS_Free((void*)aFontData);
|
||||
return nsnull;
|
||||
}
|
||||
FT2FontEntry* fe = FT2FontEntry::CreateFontEntry(face, nsnull, 0, aFontData);
|
||||
// Create our FT2FontEntry, which inherits the name of the proxy
|
||||
// as it's not guaranteed that the face has valid names (bug 737315)
|
||||
FT2FontEntry* fe =
|
||||
FT2FontEntry::CreateFontEntry(face, nsnull, 0, aProxyEntry.Name(),
|
||||
aFontData);
|
||||
if (fe) {
|
||||
fe->mItalic = aProxyEntry.mItalic;
|
||||
fe->mWeight = aProxyEntry.mWeight;
|
||||
|
@ -230,22 +234,12 @@ FT2FontEntry::CreateFontEntry(const FontListEntry& aFLE)
|
|||
FT2FontEntry*
|
||||
FT2FontEntry::CreateFontEntry(FT_Face aFace,
|
||||
const char* aFilename, PRUint8 aIndex,
|
||||
const nsAString& aName,
|
||||
const PRUint8 *aFontData)
|
||||
{
|
||||
static cairo_user_data_key_t key;
|
||||
|
||||
if (!aFace->family_name) {
|
||||
FT_Done_Face(aFace);
|
||||
return nsnull;
|
||||
}
|
||||
// Construct font name from family name and style name, regular fonts
|
||||
// do not have the modifier by convention.
|
||||
NS_ConvertUTF8toUTF16 fontName(aFace->family_name);
|
||||
if (aFace->style_name && strcmp("Regular", aFace->style_name)) {
|
||||
fontName.AppendLiteral(" ");
|
||||
AppendUTF8toUTF16(aFace->style_name, fontName);
|
||||
}
|
||||
FT2FontEntry *fe = new FT2FontEntry(fontName);
|
||||
FT2FontEntry *fe = new FT2FontEntry(aName);
|
||||
fe->mItalic = aFace->style_flags & FT_STYLE_FLAG_ITALIC;
|
||||
fe->mFTFace = aFace;
|
||||
int flags = gfxPlatform::GetPlatform()->FontHintingEnabled() ?
|
||||
|
@ -283,6 +277,23 @@ FT2FontEntry::CreateFontEntry(FT_Face aFace,
|
|||
return fe;
|
||||
}
|
||||
|
||||
// construct font entry name for an installed font from names in the FT_Face,
|
||||
// and then create our FT2FontEntry
|
||||
static FT2FontEntry*
|
||||
CreateNamedFontEntry(FT_Face aFace, const char* aFilename, PRUint8 aIndex)
|
||||
{
|
||||
if (!aFace->family_name) {
|
||||
return nsnull;
|
||||
}
|
||||
nsAutoString fontName;
|
||||
AppendUTF8toUTF16(aFace->family_name, fontName);
|
||||
if (aFace->style_name && strcmp("Regular", aFace->style_name)) {
|
||||
fontName.AppendLiteral(" ");
|
||||
AppendUTF8toUTF16(aFace->style_name, fontName);
|
||||
}
|
||||
return FT2FontEntry::CreateFontEntry(aFace, aFilename, aIndex, fontName);
|
||||
}
|
||||
|
||||
FT2FontEntry*
|
||||
gfxFT2Font::GetFontEntry()
|
||||
{
|
||||
|
@ -751,7 +762,7 @@ gfxFT2FontList::AppendFacesFromFontFile(nsCString& aFileName,
|
|||
continue;
|
||||
}
|
||||
FT2FontEntry* fe =
|
||||
FT2FontEntry::CreateFontEntry(face, aFileName.get(), i);
|
||||
CreateNamedFontEntry(face, aFileName.get(), i);
|
||||
if (fe) {
|
||||
NS_ConvertUTF8toUTF16 name(face->family_name);
|
||||
BuildKeyNameFromFontName(name);
|
||||
|
|
|
@ -50,13 +50,14 @@ public:
|
|||
static FT2FontEntry*
|
||||
CreateFontEntry(const FontListEntry& aFLE);
|
||||
|
||||
// create a font entry for a given freetype face; if it is an installed font,
|
||||
// Create a font entry for a given freetype face; if it is an installed font,
|
||||
// also record the filename and index
|
||||
// aFontData (if non-NULL) is NS_Malloc'ed data that aFace depends on,
|
||||
// to be freed after the face is destroyed
|
||||
static FT2FontEntry*
|
||||
CreateFontEntry(FT_Face aFace, const char *aFilename, PRUint8 aIndex,
|
||||
const nsAString& aName,
|
||||
const PRUint8 *aFontData = nsnull);
|
||||
// aFontData is NS_Malloc'ed data that aFace depends on, to be freed
|
||||
// after the face is destroyed; null if there is no such buffer
|
||||
|
||||
virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle,
|
||||
bool aNeedsBold);
|
||||
|
|
Загрузка…
Ссылка в новой задаче