Bug 1708797 - Try to make font fallback code more robust against DWrite failures. r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D114225
This commit is contained in:
Jonathan Kew 2021-05-04 14:33:51 +00:00
Родитель 8958ae3c7c
Коммит 5347f125e1
2 изменённых файлов: 14 добавлений и 2 удалений

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

@ -2109,6 +2109,9 @@ gfxFontEntry* gfxDWriteFontList::PlatformGlobalFontFallback(
if (!mFallbackRenderer) {
mFallbackRenderer = new DWriteFontFallbackRenderer(dwFactory);
}
if (!mFallbackRenderer->IsValid()) {
return nullptr;
}
// initialize text format
if (!mFallbackFormat) {
@ -2147,8 +2150,14 @@ gfxFontEntry* gfxDWriteFontList::PlatformGlobalFontFallback(
// call the draw method to invoke the DirectWrite layout functions
// which determine the fallback font
hr = fallbackLayout->Draw(nullptr, mFallbackRenderer, 50.0f, 50.0f);
if (FAILED(hr)) {
MOZ_SEH_TRY {
hr = fallbackLayout->Draw(nullptr, mFallbackRenderer, 50.0f, 50.0f);
if (FAILED(hr)) {
return nullptr;
}
}
MOZ_SEH_EXCEPT(EXCEPTION_EXECUTE_HANDLER) {
gfxCriticalNote << "Exception occurred during DWrite font fallback";
return nullptr;
}

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

@ -274,6 +274,9 @@ class DWriteFontFallbackRenderer final : public IDWriteTextRenderer {
~DWriteFontFallbackRenderer() {}
// If we don't have an mSystemFonts pointer, this renderer is unusable.
bool IsValid() const { return mSystemFonts; }
// IDWriteTextRenderer methods
IFACEMETHOD(DrawGlyphRun)
(void* clientDrawingContext, FLOAT baselineOriginX, FLOAT baselineOriginY,