mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 22:32:46 +00:00
bug 811312 - part 2 - fold CGFontEntry subclass into MacOSFontEntry. r=jdaggett
This commit is contained in:
parent
9c1f586890
commit
b4ef33a9cc
@ -26,48 +26,17 @@ class MacOSFontEntry : public gfxFontEntry
|
||||
public:
|
||||
friend class gfxMacPlatformFontList;
|
||||
|
||||
virtual ~MacOSFontEntry() {
|
||||
::CGFontRelease(mFontRef);
|
||||
}
|
||||
|
||||
virtual CGFontRef GetFontRef() = 0;
|
||||
|
||||
virtual nsresult GetFontTable(uint32_t aTableTag,
|
||||
FallibleTArray<uint8_t>& aBuffer) = 0;
|
||||
|
||||
nsresult ReadCMAP();
|
||||
|
||||
bool RequiresAATLayout() const { return mRequiresAAT; }
|
||||
|
||||
bool IsCFF();
|
||||
|
||||
protected:
|
||||
MacOSFontEntry(const nsAString& aPostscriptName, int32_t aWeight,
|
||||
gfxFontFamily *aFamily, bool aIsStandardFace = false);
|
||||
|
||||
virtual gfxFont* CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold);
|
||||
|
||||
virtual bool HasFontTable(uint32_t aTableTag) = 0;
|
||||
|
||||
CGFontRef mFontRef; // owning reference to the CGFont, released on destruction
|
||||
|
||||
bool mFontRefInitialized;
|
||||
bool mRequiresAAT;
|
||||
bool mIsCFF;
|
||||
bool mIsCFFInitialized;
|
||||
};
|
||||
|
||||
// concrete subclass of MacOSFontEntry: CGFontEntry for 10.6+
|
||||
class CGFontEntry : public MacOSFontEntry
|
||||
{
|
||||
public:
|
||||
CGFontEntry(const nsAString& aPostscriptName, int32_t aWeight,
|
||||
gfxFontFamily *aFamily, bool aIsStandardFace = false);
|
||||
|
||||
// for use with data fonts
|
||||
CGFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef,
|
||||
uint16_t aWeight, uint16_t aStretch, uint32_t aItalicStyle,
|
||||
bool aIsUserFont, bool aIsLocal);
|
||||
MacOSFontEntry(const nsAString& aPostscriptName, CGFontRef aFontRef,
|
||||
uint16_t aWeight, uint16_t aStretch, uint32_t aItalicStyle,
|
||||
bool aIsUserFont, bool aIsLocal);
|
||||
|
||||
virtual ~MacOSFontEntry() {
|
||||
::CGFontRelease(mFontRef);
|
||||
}
|
||||
|
||||
virtual CGFontRef GetFontRef();
|
||||
|
||||
@ -77,8 +46,23 @@ public:
|
||||
virtual void SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
||||
FontListSizes* aSizes) const;
|
||||
|
||||
nsresult ReadCMAP();
|
||||
|
||||
bool RequiresAATLayout() const { return mRequiresAAT; }
|
||||
|
||||
bool IsCFF();
|
||||
|
||||
protected:
|
||||
virtual gfxFont* CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold);
|
||||
|
||||
virtual bool HasFontTable(uint32_t aTableTag);
|
||||
|
||||
CGFontRef mFontRef; // owning reference to the CGFont, released on destruction
|
||||
|
||||
bool mFontRefInitialized;
|
||||
bool mRequiresAAT;
|
||||
bool mIsCFF;
|
||||
bool mIsCFFInitialized;
|
||||
};
|
||||
|
||||
class gfxMacPlatformFontList : public gfxPlatformFontList {
|
||||
@ -113,9 +97,6 @@ private:
|
||||
// special case font faces treated as font families (set via prefs)
|
||||
void InitSingleFaceList();
|
||||
|
||||
gfxFontEntry* MakePlatformFontCG(const gfxProxyFontEntry *aProxyEntry,
|
||||
const uint8_t *aFontData, uint32_t aLength);
|
||||
|
||||
static void ATSNotification(ATSFontNotificationInfoRef aInfo, void* aUserArg);
|
||||
|
||||
// search fonts system-wide for a given character, null otherwise
|
||||
|
@ -145,23 +145,8 @@ static NSString* GetNSStringForString(const nsAString& aSrc)
|
||||
|
||||
#endif // PR_LOGGING
|
||||
|
||||
/* MacOSFontEntry - abstract superclass for CG font entries */
|
||||
#pragma mark-
|
||||
|
||||
MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
|
||||
int32_t aWeight,
|
||||
gfxFontFamily *aFamily,
|
||||
bool aIsStandardFace)
|
||||
: gfxFontEntry(aPostscriptName, aFamily, aIsStandardFace),
|
||||
mFontRef(NULL),
|
||||
mFontRefInitialized(false),
|
||||
mRequiresAAT(false),
|
||||
mIsCFF(false),
|
||||
mIsCFFInitialized(false)
|
||||
{
|
||||
mWeight = aWeight;
|
||||
}
|
||||
|
||||
// Complex scripts will not render correctly unless appropriate AAT or OT
|
||||
// layout tables are present.
|
||||
// For OpenType, we also check that the GSUB table supports the relevant
|
||||
@ -356,23 +341,31 @@ MacOSFontEntry::IsCFF()
|
||||
return mIsCFF;
|
||||
}
|
||||
|
||||
/* CGFontEntry - used on Mac OS X 10.6+ */
|
||||
#pragma mark-
|
||||
|
||||
CGFontEntry::CGFontEntry(const nsAString& aPostscriptName,
|
||||
int32_t aWeight,
|
||||
gfxFontFamily *aFamily,
|
||||
bool aIsStandardFace)
|
||||
: MacOSFontEntry(aPostscriptName, aWeight, aFamily, aIsStandardFace)
|
||||
MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
|
||||
int32_t aWeight,
|
||||
gfxFontFamily *aFamily,
|
||||
bool aIsStandardFace)
|
||||
: gfxFontEntry(aPostscriptName, aFamily, aIsStandardFace),
|
||||
mFontRef(NULL),
|
||||
mFontRefInitialized(false),
|
||||
mRequiresAAT(false),
|
||||
mIsCFF(false),
|
||||
mIsCFFInitialized(false)
|
||||
{
|
||||
mWeight = aWeight;
|
||||
}
|
||||
|
||||
CGFontEntry::CGFontEntry(const nsAString& aPostscriptName,
|
||||
CGFontRef aFontRef,
|
||||
uint16_t aWeight, uint16_t aStretch,
|
||||
uint32_t aItalicStyle,
|
||||
bool aIsUserFont, bool aIsLocal)
|
||||
: MacOSFontEntry(aPostscriptName, aWeight, nullptr, false)
|
||||
MacOSFontEntry::MacOSFontEntry(const nsAString& aPostscriptName,
|
||||
CGFontRef aFontRef,
|
||||
uint16_t aWeight, uint16_t aStretch,
|
||||
uint32_t aItalicStyle,
|
||||
bool aIsUserFont, bool aIsLocal)
|
||||
: gfxFontEntry(aPostscriptName, nullptr, false),
|
||||
mFontRef(NULL),
|
||||
mFontRefInitialized(false),
|
||||
mRequiresAAT(false),
|
||||
mIsCFF(false),
|
||||
mIsCFFInitialized(false)
|
||||
{
|
||||
mFontRef = aFontRef;
|
||||
mFontRefInitialized = true;
|
||||
@ -387,7 +380,7 @@ CGFontEntry::CGFontEntry(const nsAString& aPostscriptName,
|
||||
}
|
||||
|
||||
CGFontRef
|
||||
CGFontEntry::GetFontRef()
|
||||
MacOSFontEntry::GetFontRef()
|
||||
{
|
||||
if (!mFontRefInitialized) {
|
||||
mFontRefInitialized = true;
|
||||
@ -398,7 +391,8 @@ CGFontEntry::GetFontRef()
|
||||
}
|
||||
|
||||
nsresult
|
||||
CGFontEntry::GetFontTable(uint32_t aTableTag, FallibleTArray<uint8_t>& aBuffer)
|
||||
MacOSFontEntry::GetFontTable(uint32_t aTableTag,
|
||||
FallibleTArray<uint8_t>& aBuffer)
|
||||
{
|
||||
nsAutoreleasePool localPool;
|
||||
|
||||
@ -426,7 +420,7 @@ CGFontEntry::GetFontTable(uint32_t aTableTag, FallibleTArray<uint8_t>& aBuffer)
|
||||
}
|
||||
|
||||
bool
|
||||
CGFontEntry::HasFontTable(uint32_t aTableTag)
|
||||
MacOSFontEntry::HasFontTable(uint32_t aTableTag)
|
||||
{
|
||||
nsAutoreleasePool localPool;
|
||||
|
||||
@ -445,8 +439,8 @@ CGFontEntry::HasFontTable(uint32_t aTableTag)
|
||||
}
|
||||
|
||||
void
|
||||
CGFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
MacOSFontEntry::SizeOfIncludingThis(nsMallocSizeOfFun aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
{
|
||||
aSizes->mFontListSize += aMallocSizeOf(this);
|
||||
SizeOfExcludingThis(aMallocSizeOf, aSizes);
|
||||
@ -547,8 +541,8 @@ gfxMacFontFamily::FindStyleVariations()
|
||||
|
||||
// create a font entry
|
||||
MacOSFontEntry *fontEntry =
|
||||
new CGFontEntry(postscriptFontName, cssWeight, this,
|
||||
isStandardFace);
|
||||
new MacOSFontEntry(postscriptFontName, cssWeight, this,
|
||||
isStandardFace);
|
||||
if (!fontEntry) {
|
||||
break;
|
||||
}
|
||||
@ -973,39 +967,31 @@ gfxMacPlatformFontList::LookupLocalFont(const gfxProxyFontEntry *aProxyEntry,
|
||||
NS_ASSERTION(w >= 100 && w <= 900, "bogus font weight value!");
|
||||
|
||||
newFontEntry =
|
||||
new CGFontEntry(aFontName, fontRef,
|
||||
w, aProxyEntry->mStretch,
|
||||
aProxyEntry->mItalic ?
|
||||
NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL,
|
||||
true, true);
|
||||
new MacOSFontEntry(aFontName, fontRef,
|
||||
w, aProxyEntry->mStretch,
|
||||
aProxyEntry->mItalic ?
|
||||
NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL,
|
||||
true, true);
|
||||
} else {
|
||||
newFontEntry =
|
||||
new CGFontEntry(aFontName, fontRef,
|
||||
400, 0, NS_FONT_STYLE_NORMAL,
|
||||
false, false);
|
||||
new MacOSFontEntry(aFontName, fontRef,
|
||||
400, 0, NS_FONT_STYLE_NORMAL,
|
||||
false, false);
|
||||
}
|
||||
::CFRelease(fontRef);
|
||||
|
||||
return newFontEntry;
|
||||
}
|
||||
|
||||
gfxFontEntry*
|
||||
gfxMacPlatformFontList::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
|
||||
const uint8_t *aFontData,
|
||||
uint32_t aLength)
|
||||
{
|
||||
return MakePlatformFontCG(aProxyEntry, aFontData, aLength);
|
||||
}
|
||||
|
||||
static void ReleaseData(void *info, const void *data, size_t size)
|
||||
{
|
||||
NS_Free((void*)data);
|
||||
}
|
||||
|
||||
gfxFontEntry*
|
||||
gfxMacPlatformFontList::MakePlatformFontCG(const gfxProxyFontEntry *aProxyEntry,
|
||||
const uint8_t *aFontData,
|
||||
uint32_t aLength)
|
||||
gfxMacPlatformFontList::MakePlatformFont(const gfxProxyFontEntry *aProxyEntry,
|
||||
const uint8_t *aFontData,
|
||||
uint32_t aLength)
|
||||
{
|
||||
NS_ASSERTION(aFontData, "MakePlatformFont called with null data");
|
||||
|
||||
@ -1030,12 +1016,13 @@ gfxMacPlatformFontList::MakePlatformFontCG(const gfxProxyFontEntry *aProxyEntry,
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsAutoPtr<CGFontEntry>
|
||||
newFontEntry(new CGFontEntry(uniqueName, fontRef, w,
|
||||
aProxyEntry->mStretch,
|
||||
aProxyEntry->mItalic ?
|
||||
NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL,
|
||||
true, false));
|
||||
nsAutoPtr<MacOSFontEntry>
|
||||
newFontEntry(new MacOSFontEntry(uniqueName, fontRef, w,
|
||||
aProxyEntry->mStretch,
|
||||
aProxyEntry->mItalic ?
|
||||
NS_FONT_STYLE_ITALIC :
|
||||
NS_FONT_STYLE_NORMAL,
|
||||
true, false));
|
||||
::CFRelease(fontRef);
|
||||
|
||||
// if succeeded and font cmap is good, return the new font
|
||||
|
Loading…
Reference in New Issue
Block a user