Bug 1395061 - patch 3 - Clean up vestigial code that existed to support setting the gfxFontEntry::mSymbolFont flag. r=jrmuizel

This commit is contained in:
Jonathan Kew 2017-09-11 19:23:30 +01:00
Родитель 379ddad597
Коммит 82bdaf03b2
12 изменённых файлов: 27 добавлений и 81 удалений

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

@ -535,11 +535,9 @@ gfxDWriteFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
RefPtr<gfxCharacterMap> charmap;
nsresult rv;
bool symbolFont;
if (aFontInfoData && (charmap = GetCMAPFromFontInfo(aFontInfoData,
mUVSOffset,
symbolFont))) {
mUVSOffset))) {
rv = NS_OK;
} else {
uint32_t kCMAP = TRUETYPE_TAG('c','m','a','p');
@ -547,14 +545,12 @@ gfxDWriteFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
AutoTable cmapTable(this, kCMAP);
if (cmapTable) {
bool unicodeFont = false, symbolFont = false; // currently ignored
uint32_t cmapLen;
const uint8_t* cmapData =
reinterpret_cast<const uint8_t*>(hb_blob_get_data(cmapTable,
&cmapLen));
rv = gfxFontUtils::ReadCMAP(cmapData, cmapLen,
*charmap, mUVSOffset,
unicodeFont, symbolFont);
*charmap, mUVSOffset);
} else {
rv = NS_ERROR_NOT_AVAILABLE;
}
@ -1676,7 +1672,6 @@ DirectWriteFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)
if (SUCCEEDED(hr)) {
bool cmapLoaded = false;
bool unicodeFont = false, symbolFont = false;
RefPtr<gfxCharacterMap> charmap = new gfxCharacterMap();
uint32_t offset;
@ -1684,10 +1679,9 @@ DirectWriteFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)
cmapSize > 0 &&
NS_SUCCEEDED(
gfxFontUtils::ReadCMAP(cmapData, cmapSize, *charmap,
offset, unicodeFont, symbolFont))) {
offset))) {
fontData.mCharacterMap = charmap;
fontData.mUVSOffset = offset;
fontData.mSymbolFont = symbolFont;
cmapLoaded = true;
mLoadStats.cmaps++;
}

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

@ -484,11 +484,8 @@ FT2FontEntry::ReadCMAP(FontInfoData *aFontInfoData)
nsresult rv = CopyFontTable(TTAG_cmap, buffer);
if (NS_SUCCEEDED(rv)) {
bool unicodeFont;
bool symbolFont;
rv = gfxFontUtils::ReadCMAP(buffer.Elements(), buffer.Length(),
*charmap, mUVSOffset,
unicodeFont, symbolFont);
*charmap, mUVSOffset);
}
if (NS_SUCCEEDED(rv) && !HasGraphiteTables()) {

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

@ -335,11 +335,9 @@ gfxFontconfigFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
RefPtr<gfxCharacterMap> charmap;
nsresult rv;
bool symbolFont = false; // currently ignored
if (aFontInfoData && (charmap = GetCMAPFromFontInfo(aFontInfoData,
mUVSOffset,
symbolFont))) {
mUVSOffset))) {
rv = NS_OK;
} else {
uint32_t kCMAP = TRUETYPE_TAG('c','m','a','p');
@ -347,14 +345,12 @@ gfxFontconfigFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
AutoTable cmapTable(this, kCMAP);
if (cmapTable) {
bool unicodeFont = false; // currently ignored
uint32_t cmapLen;
const uint8_t* cmapData =
reinterpret_cast<const uint8_t*>(hb_blob_get_data(cmapTable,
&cmapLen));
rv = gfxFontUtils::ReadCMAP(cmapData, cmapLen,
*charmap, mUVSOffset,
unicodeFont, symbolFont);
*charmap, mUVSOffset);
} else {
rv = NS_ERROR_NOT_AVAILABLE;
}

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

@ -595,14 +595,13 @@ gfxFontEntry::ShareFontTableAndGetBlob(uint32_t aTag,
already_AddRefed<gfxCharacterMap>
gfxFontEntry::GetCMAPFromFontInfo(FontInfoData *aFontInfoData,
uint32_t& aUVSOffset,
bool& aSymbolFont)
uint32_t& aUVSOffset)
{
if (!aFontInfoData || !aFontInfoData->mLoadCmaps) {
return nullptr;
}
return aFontInfoData->GetCMAP(mName, aUVSOffset, aSymbolFont);
return aFontInfoData->GetCMAP(mName, aUVSOffset);
}
hb_blob_t *

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

@ -413,8 +413,7 @@ protected:
// lookup the cmap in cached font data
virtual already_AddRefed<gfxCharacterMap>
GetCMAPFromFontInfo(FontInfoData *aFontInfoData,
uint32_t& aUVSOffset,
bool& aSymbolFont);
uint32_t& aUVSOffset);
// helper for HasCharacter(), which is what client code should call
virtual bool TestCharacterMap(uint32_t aCh);

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

@ -21,21 +21,19 @@
// data retrieved for a given face
struct FontFaceData {
FontFaceData() : mUVSOffset(0), mSymbolFont(false) {}
FontFaceData() : mUVSOffset(0) {}
FontFaceData(const FontFaceData& aFontFaceData) {
mFullName = aFontFaceData.mFullName;
mPostscriptName = aFontFaceData.mPostscriptName;
mCharacterMap = aFontFaceData.mCharacterMap;
mUVSOffset = aFontFaceData.mUVSOffset;
mSymbolFont = aFontFaceData.mSymbolFont;
}
nsString mFullName;
nsString mPostscriptName;
RefPtr<gfxCharacterMap> mCharacterMap;
uint32_t mUVSOffset;
bool mSymbolFont;
};
// base class used to contain cached system-wide font info.
@ -78,8 +76,7 @@ public:
// fetches cmap data for a particular font from cached font data
virtual already_AddRefed<gfxCharacterMap>
GetCMAP(const nsAString& aFontName,
uint32_t& aUVSOffset,
bool& aSymbolFont)
uint32_t& aUVSOffset)
{
FontFaceData faceData;
if (!mFontFaceData.Get(aFontName, &faceData) ||
@ -88,7 +85,6 @@ public:
}
aUVSOffset = faceData.mUVSOffset;
aSymbolFont = faceData.mSymbolFont;
RefPtr<gfxCharacterMap> cmap = faceData.mCharacterMap;
return cmap.forget();
}

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

@ -413,8 +413,7 @@ gfxFontUtils::ReadCMAPTableFormat14(const uint8_t *aBuf, uint32_t aLength,
uint32_t
gfxFontUtils::FindPreferredSubtable(const uint8_t *aBuf, uint32_t aBufLength,
uint32_t *aTableOffset,
uint32_t *aUVSTableOffset,
bool *aSymbolEncoding)
uint32_t *aUVSTableOffset)
{
enum {
OffsetVersion = 0,
@ -474,17 +473,14 @@ gfxFontUtils::FindPreferredSubtable(const uint8_t *aBuf, uint32_t aBufLength,
if (isSymbol(platformID, encodingID)) {
keepFormat = format;
*aTableOffset = offset;
*aSymbolEncoding = true;
break;
} else if (format == 4 && acceptableFormat4(platformID, encodingID, keepFormat)) {
keepFormat = format;
*aTableOffset = offset;
*aSymbolEncoding = false;
} else if ((format == 10 || format == 12 || format == 13) &&
acceptableUCS4Encoding(platformID, encodingID, keepFormat)) {
keepFormat = format;
*aTableOffset = offset;
*aSymbolEncoding = false;
if (platformID > PLATFORM_ID_UNICODE || !aUVSTableOffset || *aUVSTableOffset) {
break; // we don't want to try anything else when this format is available.
}
@ -502,36 +498,23 @@ gfxFontUtils::FindPreferredSubtable(const uint8_t *aBuf, uint32_t aBufLength,
nsresult
gfxFontUtils::ReadCMAP(const uint8_t *aBuf, uint32_t aBufLength,
gfxSparseBitSet& aCharacterMap,
uint32_t& aUVSOffset,
bool& aUnicodeFont, bool& aSymbolFont)
uint32_t& aUVSOffset)
{
uint32_t offset;
bool symbol;
uint32_t format = FindPreferredSubtable(aBuf, aBufLength,
&offset, &aUVSOffset, &symbol);
&offset, &aUVSOffset);
switch (format) {
case 4:
if (symbol) {
aUnicodeFont = false;
aSymbolFont = true;
} else {
aUnicodeFont = true;
aSymbolFont = false;
}
return ReadCMAPTableFormat4(aBuf + offset, aBufLength - offset,
aCharacterMap);
case 10:
aUnicodeFont = true;
aSymbolFont = false;
return ReadCMAPTableFormat10(aBuf + offset, aBufLength - offset,
aCharacterMap);
case 12:
case 13:
aUnicodeFont = true;
aSymbolFont = false;
return ReadCMAPTableFormat12or13(aBuf + offset, aBufLength - offset,
aCharacterMap);
@ -769,9 +752,8 @@ gfxFontUtils::MapCharToGlyph(const uint8_t *aCmapBuf, uint32_t aBufLength,
uint32_t aUnicode, uint32_t aVarSelector)
{
uint32_t offset, uvsOffset;
bool symbol;
uint32_t format = FindPreferredSubtable(aCmapBuf, aBufLength, &offset,
&uvsOffset, &symbol);
&uvsOffset);
uint32_t gid;
switch (format) {

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

@ -794,14 +794,12 @@ public:
static uint32_t
FindPreferredSubtable(const uint8_t *aBuf, uint32_t aBufLength,
uint32_t *aTableOffset, uint32_t *aUVSTableOffset,
bool *aSymbolEncoding);
uint32_t *aTableOffset, uint32_t *aUVSTableOffset);
static nsresult
ReadCMAP(const uint8_t *aBuf, uint32_t aBufLength,
gfxSparseBitSet& aCharacterMap,
uint32_t& aUVSOffset,
bool& aUnicodeFont, bool& aSymbolFont);
uint32_t& aUVSOffset);
static uint32_t
MapCharToGlyphFormat4(const uint8_t *aBuf, char16_t aCh);

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

@ -166,11 +166,9 @@ GDIFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
RefPtr<gfxCharacterMap> charmap;
nsresult rv;
bool unicodeFont = false, symbolFont = false;
if (aFontInfoData && (charmap = GetCMAPFromFontInfo(aFontInfoData,
mUVSOffset,
symbolFont))) {
mUVSOffset))) {
rv = NS_OK;
} else {
uint32_t kCMAP = TRUETYPE_TAG('c','m','a','p');
@ -180,8 +178,7 @@ GDIFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
if (NS_SUCCEEDED(rv)) {
rv = gfxFontUtils::ReadCMAP(cmap.Elements(), cmap.Length(),
*charmap, mUVSOffset,
unicodeFont, symbolFont);
*charmap, mUVSOffset);
}
}
@ -1110,17 +1107,14 @@ int CALLBACK GDIFontInfo::EnumerateFontsForFamily(
cmapData.SetLength(cmapSize, fallible)) {
::GetFontData(hdc, kCMAP, 0, cmapData.Elements(), cmapSize);
bool cmapLoaded = false;
bool unicodeFont = false, symbolFont = false;
RefPtr<gfxCharacterMap> charmap = new gfxCharacterMap();
uint32_t offset;
if (NS_SUCCEEDED(gfxFontUtils::ReadCMAP(cmapData.Elements(),
cmapSize, *charmap,
offset, unicodeFont,
symbolFont))) {
offset))) {
fontData.mCharacterMap = charmap;
fontData.mUVSOffset = offset;
fontData.mSymbolFont = symbolFont;
cmapLoaded = true;
famData->mFontInfo.mLoadStats.cmaps++;
}

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

@ -109,7 +109,7 @@ class GDIFontEntry : public gfxFontEntry
public:
LPLOGFONTW GetLogFont() { return &mLogFont; }
nsresult ReadCMAP(FontInfoData *aFontInfoData = nullptr);
nsresult ReadCMAP(FontInfoData *aFontInfoData = nullptr) override;
void FillLogFont(LOGFONTW *aLogFont, uint16_t aWeight, gfxFloat aSize);
@ -194,7 +194,8 @@ protected:
void InitLogFont(const nsAString& aName, gfxWindowsFontType aFontType);
virtual gfxFont *CreateFontInstance(const gfxFontStyle *aFontStyle, bool aNeedsBold);
virtual gfxFont* CreateFontInstance(const gfxFontStyle *aFontStyle,
bool aNeedsBold) override;
virtual nsresult CopyFontTable(uint32_t aTableTag,
nsTArray<uint8_t>& aBuffer) override;

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

@ -1275,11 +1275,9 @@ gfxHarfBuzzShaper::Initialize()
}
uint32_t len;
const uint8_t* data = (const uint8_t*)hb_blob_get_data(mCmapTable, &len);
bool symbol;
mCmapFormat = gfxFontUtils::
FindPreferredSubtable(data, len,
&mSubtableOffset, &mUVSTableOffset,
&symbol);
&mSubtableOffset, &mUVSTableOffset);
if (mCmapFormat <= 0) {
return false;
}

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

@ -152,11 +152,9 @@ MacOSFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
RefPtr<gfxCharacterMap> charmap;
nsresult rv;
bool symbolFont = false; // currently ignored
if (aFontInfoData && (charmap = GetCMAPFromFontInfo(aFontInfoData,
mUVSOffset,
symbolFont))) {
mUVSOffset))) {
rv = NS_OK;
} else {
uint32_t kCMAP = TRUETYPE_TAG('c','m','a','p');
@ -164,14 +162,12 @@ MacOSFontEntry::ReadCMAP(FontInfoData *aFontInfoData)
AutoTable cmapTable(this, kCMAP);
if (cmapTable) {
bool unicodeFont = false; // currently ignored
uint32_t cmapLen;
const uint8_t* cmapData =
reinterpret_cast<const uint8_t*>(hb_blob_get_data(cmapTable,
&cmapLen));
rv = gfxFontUtils::ReadCMAP(cmapData, cmapLen,
*charmap, mUVSOffset,
unicodeFont, symbolFont);
*charmap, mUVSOffset);
} else {
rv = NS_ERROR_NOT_AVAILABLE;
}
@ -1479,16 +1475,12 @@ MacFontInfo::LoadFontFamilyData(const nsAString& aFamilyName)
uint32_t cmapLen = CFDataGetLength(cmapTable);
RefPtr<gfxCharacterMap> charmap = new gfxCharacterMap();
uint32_t offset;
bool unicodeFont = false; // ignored
bool symbolFont = false;
nsresult rv;
rv = gfxFontUtils::ReadCMAP(cmapData, cmapLen, *charmap, offset,
unicodeFont, symbolFont);
rv = gfxFontUtils::ReadCMAP(cmapData, cmapLen, *charmap, offset);
if (NS_SUCCEEDED(rv)) {
fontData.mCharacterMap = charmap;
fontData.mUVSOffset = offset;
fontData.mSymbolFont = symbolFont;
mLoadStats.cmaps++;
}
CFRelease(cmapTable);