bug 458634 part 2 - use 'smcp' feature in Graphite fonts if available. r=jdaggett

This commit is contained in:
Jonathan Kew 2014-05-28 11:35:14 +01:00
parent 65d2b0d641
commit 4355cc9848
2 changed files with 19 additions and 2 deletions

View File

@ -123,6 +123,7 @@ gfxFontEntry::gfxFontEntry() :
mHasSpaceFeaturesNonKerning(false),
mSkipDefaultFeatureSpaceCheck(false),
mCheckedForGraphiteTables(false),
mCheckedForGraphiteSmallCaps(false),
mHasCmapTable(false),
mGrFaceInitialized(false),
mCheckedForColorGlyph(false),
@ -156,6 +157,7 @@ gfxFontEntry::gfxFontEntry(const nsAString& aName, bool aIsStandardFace) :
mHasSpaceFeaturesNonKerning(false),
mSkipDefaultFeatureSpaceCheck(false),
mCheckedForGraphiteTables(false),
mCheckedForGraphiteSmallCaps(false),
mHasCmapTable(false),
mGrFaceInitialized(false),
mCheckedForColorGlyph(false),
@ -949,6 +951,19 @@ gfxFontEntry::SupportsOpenTypeSmallCaps(int32_t aScript)
return result;
}
bool
gfxFontEntry::SupportsGraphiteSmallCaps()
{
if (!mCheckedForGraphiteSmallCaps) {
gr_face* face = GetGrFace();
mHasGraphiteSmallCaps =
gr_face_find_fref(face, TRUETYPE_TAG('s','m','c','p')) != nullptr;
ReleaseGrFace(face);
mCheckedForGraphiteSmallCaps = true;
}
return mHasGraphiteSmallCaps;
}
bool
gfxFontEntry::GetColorLayersInfo(uint32_t aGlyphId,
nsTArray<uint16_t>& aLayerGlyphs,
@ -2687,8 +2702,7 @@ bool
gfxFont::SupportsSmallCaps(int32_t aScript)
{
if (mGraphiteShaper && gfxPlatform::GetPlatform()->UseGraphiteShaping()) {
// we don't currently support real small caps via graphite
return false;
return GetFontEntry()->SupportsGraphiteSmallCaps();
}
return GetFontEntry()->SupportsOpenTypeSmallCaps(aScript);

View File

@ -274,6 +274,7 @@ public:
bool IgnoreGSUB() const { return mIgnoreGSUB; }
bool SupportsOpenTypeSmallCaps(int32_t aScript);
bool SupportsGraphiteSmallCaps();
virtual bool IsSymbolFont();
@ -543,6 +544,8 @@ public:
bool mSkipDefaultFeatureSpaceCheck : 1;
bool mHasGraphiteTables : 1;
bool mCheckedForGraphiteTables : 1;
bool mHasGraphiteSmallCaps : 1;
bool mCheckedForGraphiteSmallCaps : 1;
bool mHasCmapTable : 1;
bool mGrFaceInitialized : 1;
bool mCheckedForColorGlyph : 1;