diff --git a/gfx/thebes/gfxGDIFont.cpp b/gfx/thebes/gfxGDIFont.cpp index a410ff974bd7..a59fb72abea1 100644 --- a/gfx/thebes/gfxGDIFont.cpp +++ b/gfx/thebes/gfxGDIFont.cpp @@ -49,7 +49,8 @@ gfxGDIFont::gfxGDIFont(GDIFontEntry *aFontEntry, mFontFace(nullptr), mMetrics(nullptr), mSpaceGlyph(0), - mNeedsBold(aNeedsBold) + mNeedsBold(aNeedsBold), + mScriptCache(nullptr) { if (FontCanSupportGraphite()) { mGraphiteShaper = new gfxGraphiteShaper(this); @@ -68,6 +69,9 @@ gfxGDIFont::~gfxGDIFont() if (mFont) { ::DeleteObject(mFont); } + if (mScriptCache) { + ScriptFreeCache(&mScriptCache); + } delete mMetrics; } @@ -448,15 +452,16 @@ gfxGDIFont::GetGlyph(uint32_t aUnicode, uint32_t aVarSelector) return gid; } - AutoDC dc; - AutoSelectFont fs(dc.GetDC(), GetHFONT()); - wchar_t ch = aUnicode; WORD glyph; - DWORD ret = GetGlyphIndicesW(dc.GetDC(), &ch, 1, &glyph, - GGI_MARK_NONEXISTING_GLYPHS); - if (ret == GDI_ERROR || glyph == 0xFFFF) { - return 0; + DWORD ret = ScriptGetCMap(nullptr, &mScriptCache, &ch, 1, 0, &glyph); + if (ret == E_PENDING) { + AutoDC dc; + AutoSelectFont fs(dc.GetDC(), GetHFONT()); + ret = ScriptGetCMap(dc.GetDC(), &mScriptCache, &ch, 1, 0, &glyph); + } + if (ret != S_OK) { + glyph = 0; } mGlyphIDs->Put(aUnicode, glyph); diff --git a/gfx/thebes/gfxGDIFont.h b/gfx/thebes/gfxGDIFont.h index 3b979c41387b..d6155f436210 100644 --- a/gfx/thebes/gfxGDIFont.h +++ b/gfx/thebes/gfxGDIFont.h @@ -14,6 +14,7 @@ #include "nsHashKeys.h" #include "cairo.h" +#include "usp10.h" class gfxGDIFont : public gfxFont { @@ -96,6 +97,7 @@ protected: // cache of glyph IDs (used for non-sfnt fonts only) nsAutoPtr > mGlyphIDs; + SCRIPT_CACHE mScriptCache; // cache of glyph widths in 16.16 fixed-point pixels nsAutoPtr > mGlyphWidths;