summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPale Moon <git-repo@palemoon.org>2018-02-21 00:14:03 +0100
committerPale Moon <git-repo@palemoon.org>2018-02-21 00:14:03 +0100
commit1d10949dea684ee9309a7388bf08f3d02854d02d (patch)
tree6c60b577a054ae188754dd39de9f77ecfb6ab560
parent410afd43ab9d4109a7ee0c7886eadfff3dec3fb0 (diff)
downloadpalemoon-1d10949dea684ee9309a7388bf08f3d02854d02d.tar.gz
Issue #1610 Part 3: Bypass GDI table loading for embedded fonts.
This is required for DirectWrite because otherwise the font is seen as having no emoji entries due to the fact that GDI data isn't populated (It isn't loaded through the GDI system like system fontsand GDI as a result doesn't know anything about the font, and will likely use random data from the last-loaded font instead).
-rw-r--r--gfx/thebes/gfxDWriteFontList.cpp40
1 files changed, 19 insertions, 21 deletions
diff --git a/gfx/thebes/gfxDWriteFontList.cpp b/gfx/thebes/gfxDWriteFontList.cpp
index 8d0ae818b..df704cab8 100644
--- a/gfx/thebes/gfxDWriteFontList.cpp
+++ b/gfx/thebes/gfxDWriteFontList.cpp
@@ -384,6 +384,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag,
FallibleTArray<uint8_t> &aBuffer)
{
gfxDWriteFontList *pFontList = gfxDWriteFontList::PlatformFontList();
+ const uint32_t tagBE = NativeEndian::swapToBigEndian(aTableTag);
// Don't use GDI table loading for symbol fonts or for
// italic fonts in Arabic-script system locales because of
@@ -394,27 +395,22 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag,
!mFont->IsSymbolFont())
{
LOGFONTW logfont = { 0 };
- if (!InitLogFont(mFont, &logfont))
- return NS_ERROR_FAILURE;
-
- AutoDC dc;
- AutoSelectFont font(dc.GetDC(), &logfont);
- if (font.IsValid()) {
- uint32_t tableSize =
- ::GetFontData(dc.GetDC(),
- NativeEndian::swapToBigEndian(aTableTag), 0,
- nullptr, 0);
- if (tableSize != GDI_ERROR) {
- if (aBuffer.SetLength(tableSize)) {
- ::GetFontData(dc.GetDC(),
- NativeEndian::swapToBigEndian(aTableTag), 0,
- aBuffer.Elements(), aBuffer.Length());
- return NS_OK;
+ if (InitLogFont(mFont, &logfont)) {
+ AutoDC dc;
+ AutoSelectFont font(dc.GetDC(), &logfont);
+ if (font.IsValid()) {
+ uint32_t tableSize =
+ ::GetFontData(dc.GetDC(), tagBE, 0, nullptr, 0);
+ if (tableSize != GDI_ERROR) {
+ if (aBuffer.SetLength(tableSize)) {
+ ::GetFontData(dc.GetDC(), tagBE, 0,
+ aBuffer.Elements(), aBuffer.Length());
+ return NS_OK;
+ }
+ return NS_ERROR_OUT_OF_MEMORY;
}
- return NS_ERROR_OUT_OF_MEMORY;
}
}
- return NS_ERROR_FAILURE;
}
nsRefPtr<IDWriteFontFace> fontFace;
@@ -428,8 +424,7 @@ gfxDWriteFontEntry::CopyFontTable(uint32_t aTableTag,
void *tableContext = nullptr;
BOOL exists;
HRESULT hr =
- fontFace->TryGetFontTable(NativeEndian::swapToBigEndian(aTableTag),
- (const void**)&tableData, &len,
+ fontFace->TryGetFontTable(tagBE, (const void**)&tableData, &len,
&tableContext, &exists);
if (FAILED(hr) || !exists) {
return NS_ERROR_FAILURE;
@@ -646,7 +641,10 @@ gfxDWriteFontEntry::InitLogFont(IDWriteFont *aFont, LOGFONTW *aLogFont)
IDWriteGdiInterop *gdi =
gfxDWriteFontList::PlatformFontList()->GetGDIInterop();
hr = gdi->ConvertFontToLOGFONT(aFont, aLogFont, &isInSystemCollection);
- return (FAILED(hr) ? false : true);
+ // If the font is not in the system collection, GDI will be unable to
+ // select it and load its tables, so we return false here to indicate
+ // failure, and let CopyFontTable fall back to DWrite native methods.
+ return (SUCCEEDED(hr) && isInSystemCollection);
}
bool