Skip to content

Commit

Permalink
bug 874053 - ReadCMAP() must not leave the font entry's mCharacterMap…
Browse files Browse the repository at this point in the history
… pointer NULL, even if cmap table can't be read. r=roc
  • Loading branch information
jfkthame committed May 21, 2013
1 parent 0373403 commit 21e2cea
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
2 changes: 2 additions & 0 deletions gfx/thebes/gfxDWriteFontList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,8 @@ gfxDWriteFontEntry::ReadCMAP()
rv = gfxFontUtils::ReadCMAP(cmapData, cmapLen,
*charmap, mUVSOffset,
unicodeFont, symbolFont);
} else {
rv = NS_ERROR_NOT_AVAILABLE;
}

mHasCmapTable = NS_SUCCEEDED(rv);
Expand Down
7 changes: 7 additions & 0 deletions gfx/thebes/gfxFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,13 @@ class gfxFontEntry {
virtual bool TestCharacterMap(uint32_t aCh);
nsresult InitializeUVSMap();
uint16_t GetUVSGlyph(uint32_t aCh, uint32_t aVS);

// All concrete gfxFontEntry subclasses (except gfxProxyFontEntry) need
// to override this, otherwise the font will never be used as it will
// be considered to support no characters.
// ReadCMAP() must *always* set the mCharacterMap pointer to a valid
// gfxCharacterMap, even if empty, as other code assumes this pointer
// can be safely dereferenced.
virtual nsresult ReadCMAP();

bool TryGetSVGData();
Expand Down
22 changes: 12 additions & 10 deletions gfx/thebes/gfxMacPlatformFontList.mm
Original file line number Diff line number Diff line change
Expand Up @@ -232,18 +232,20 @@ static void GetStringForNSString(const NSString *aSrc, nsAString& aDist)
uint32_t kCMAP = TRUETYPE_TAG('c','m','a','p');

AutoTable cmapTable(this, kCMAP);
if (!cmapTable) {
return NS_OK; // leave it empty
}
nsresult rv;

if (cmapTable) {
bool unicodeFont = false, symbolFont = false; // currently ignored

bool unicodeFont = false, symbolFont = false; // currently ignored
uint32_t cmapLen;
const char* cmapData = hb_blob_get_data(cmapTable, &cmapLen);
rv = gfxFontUtils::ReadCMAP((const uint8_t*)cmapData, cmapLen,
*charmap, mUVSOffset,
unicodeFont, symbolFont);
} else {
rv = NS_ERROR_NOT_AVAILABLE;
}

uint32_t cmapLen;
const char* cmapData = hb_blob_get_data(cmapTable, &cmapLen);
nsresult rv = gfxFontUtils::ReadCMAP((const uint8_t*)cmapData, cmapLen,
*charmap, mUVSOffset,
unicodeFont, symbolFont);

if (NS_SUCCEEDED(rv) && !HasGraphiteTables()) {
// We assume a Graphite font knows what it's doing,
// and provides whatever shaping is needed for the
Expand Down
4 changes: 2 additions & 2 deletions gfx/thebes/gfxPangoFonts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,14 +410,14 @@ void
gfxSystemFcFontEntry::ForgetHBFace()
{
gfxFontEntry::ForgetHBFace();
MaybeReleaseFTFace();
MaybeReleaseFTFace();
}

void
gfxSystemFcFontEntry::ReleaseGrFace(gr_face* aFace)
{
gfxFontEntry::ReleaseGrFace(aFace);
MaybeReleaseFTFace();
MaybeReleaseFTFace();
}

// A namespace for @font-face family names in FcPatterns so that fontconfig
Expand Down

0 comments on commit 21e2cea

Please sign in to comment.