mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1457103 - patch 3 - Make gfxFontEntry::GetVariationAxes and GetVariationInstances pure virtual, and provide missing subclass implementations. r=jwatt
This commit is contained in:
parent
61950f81db
commit
d384879f12
@ -635,6 +635,43 @@ FT2FontEntry::HasVariations()
|
||||
return mHasVariations;
|
||||
}
|
||||
|
||||
void
|
||||
FT2FontEntry::GetVariationAxes(nsTArray<gfxFontVariationAxis>& aAxes)
|
||||
{
|
||||
if (!HasVariations()) {
|
||||
return;
|
||||
}
|
||||
AutoFTFace face(this);
|
||||
if (!face) {
|
||||
return;
|
||||
}
|
||||
FT_MM_Var* mmVar;
|
||||
if (FT_Err_Ok != (FT_Get_MM_Var(face, &mmVar))) {
|
||||
return;
|
||||
}
|
||||
gfxFT2Utils::GetVariationAxes(mmVar, aAxes);
|
||||
FT_Done_MM_Var(FT_Face(face)->glyph->library, mmVar);
|
||||
}
|
||||
|
||||
void
|
||||
FT2FontEntry::GetVariationInstances(
|
||||
nsTArray<gfxFontVariationInstance>& aInstances)
|
||||
{
|
||||
if (!HasVariations()) {
|
||||
return;
|
||||
}
|
||||
AutoFTFace face(this);
|
||||
if (!face) {
|
||||
return;
|
||||
}
|
||||
FT_MM_Var* mmVar;
|
||||
if (FT_Err_Ok != (FT_Get_MM_Var(face, &mmVar))) {
|
||||
return;
|
||||
}
|
||||
gfxFT2Utils::GetVariationInstances(this, mmVar, aInstances);
|
||||
FT_Done_MM_Var(FT_Face(face)->glyph->library, mmVar);
|
||||
}
|
||||
|
||||
void
|
||||
FT2FontEntry::AddSizeOfExcludingThis(MallocSizeOf aMallocSizeOf,
|
||||
FontListSizes* aSizes) const
|
||||
|
@ -88,6 +88,8 @@ public:
|
||||
nsTArray<uint8_t>& aBuffer) override;
|
||||
|
||||
bool HasVariations() override;
|
||||
void GetVariationAxes(nsTArray<gfxFontVariationAxis>& aVariationAxes) override;
|
||||
void GetVariationInstances(nsTArray<gfxFontVariationInstance>& aInstances) override;
|
||||
|
||||
// Check for various kinds of brokenness, and set flags on the entry
|
||||
// accordingly so that we avoid using bad font tables
|
||||
|
@ -365,14 +365,19 @@ public:
|
||||
|
||||
bool SupportsScriptInGSUB(const hb_tag_t* aScriptTags);
|
||||
|
||||
// For variation font support; default implementations assume it is not present.
|
||||
/**
|
||||
* Font-variation query methods.
|
||||
*
|
||||
* Font backends that don't support variations should provide empty
|
||||
* implementations.
|
||||
*/
|
||||
virtual bool HasVariations() = 0;
|
||||
virtual void GetVariationAxes(nsTArray<gfxFontVariationAxis>& aVariationAxes)
|
||||
{
|
||||
}
|
||||
virtual void GetVariationInstances(nsTArray<gfxFontVariationInstance>& aInstances)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void
|
||||
GetVariationAxes(nsTArray<gfxFontVariationAxis>& aVariationAxes) = 0;
|
||||
|
||||
virtual void
|
||||
GetVariationInstances(nsTArray<gfxFontVariationInstance>& aInstances) = 0;
|
||||
|
||||
// Set up the entry's weight/stretch/style ranges according to axes found
|
||||
// by GetVariationAxes (for installed fonts; do NOT call this for user
|
||||
|
@ -163,7 +163,10 @@ public:
|
||||
|
||||
gfxFontEntry* Clone() const override;
|
||||
|
||||
// GDI backend doesn't support font variations:
|
||||
bool HasVariations() override { return false; }
|
||||
void GetVariationAxes(nsTArray<gfxFontVariationAxis>&) override {}
|
||||
void GetVariationInstances(nsTArray<gfxFontVariationInstance>&) override {}
|
||||
|
||||
// create a font entry for a font with a given name
|
||||
static GDIFontEntry* CreateFontEntry(const nsAString& aName,
|
||||
|
@ -639,7 +639,17 @@ public:
|
||||
return mSrcList;
|
||||
}
|
||||
|
||||
bool HasVariations() override { return false; }
|
||||
// The variation-query APIs should not be called on placeholders.
|
||||
bool HasVariations() override {
|
||||
MOZ_ASSERT_UNREACHABLE("not meaningful for a userfont placeholder");
|
||||
return false;
|
||||
}
|
||||
void GetVariationAxes(nsTArray<gfxFontVariationAxis>&) override {
|
||||
MOZ_ASSERT_UNREACHABLE("not meaningful for a userfont placeholder");
|
||||
}
|
||||
void GetVariationInstances(nsTArray<gfxFontVariationInstance>&) override {
|
||||
MOZ_ASSERT_UNREACHABLE("not meaningful for a userfont placeholder");
|
||||
}
|
||||
|
||||
protected:
|
||||
const uint8_t* SanitizeOpenTypeData(const uint8_t* aData,
|
||||
|
Loading…
Reference in New Issue
Block a user