[SkiaPaths] Fix issue that non-Windows cannot load font correctly.
When testing on barcode_test.pdf, error "Could not create FT_Face.\n"
is triggered. This is because |m_FontData| in the temporary CFX_Font
in CFDE_TextOut::DrawString() is not initialized from |pFxFont|, which
later causes CFX_GlyphCache::GetDeviceCache() to fail at building a
valid |m_pTypeface|.
To fix this issue, initialize |m_FontData| in the temporary CFX_Font
structure with |m_FontData| from |pFxFont| to gain access to the font
data.
This CL also removes the unnecessary process of resetting |face| for
the temporary CFX_Font, since it will be destroyed automatically when
CFDE_TextOut::DrawString() finishes.
Bug: pdfium:740
Change-Id: I5e4da4e1928ce21d98393d84f81e58c2a7e479eb
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/59220
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/cfx_font.h b/core/fxge/cfx_font.h
index d5a4a7e..c7c7932 100644
--- a/core/fxge/cfx_font.h
+++ b/core/fxge/cfx_font.h
@@ -60,6 +60,7 @@
#if !defined(OS_WIN)
void SetFace(RetainPtr<CFX_Face> face);
+ void SetFontSpan(pdfium::span<uint8_t> pSpan) { m_FontData = pSpan; }
void SetSubstFont(std::unique_ptr<CFX_SubstFont> subst);
#endif // !defined(OS_WIN)
#endif // defined(PDF_ENABLE_XFA)
diff --git a/xfa/fde/cfde_textout.cpp b/xfa/fde/cfde_textout.cpp
index 6e2915e..39fcf20 100644
--- a/xfa/fde/cfde_textout.cpp
+++ b/xfa/fde/cfde_textout.cpp
@@ -82,6 +82,7 @@
CFX_Font* font;
#if !defined(OS_WIN)
FxFont.SetFace(pFxFont->GetFace());
+ FxFont.SetFontSpan(pFxFont->GetFontSpan());
font = &FxFont;
#else
font = pFxFont;
@@ -104,6 +105,7 @@
CFX_Font* font;
#if !defined(OS_WIN)
FxFont.SetFace(pFxFont->GetFace());
+ FxFont.SetFontSpan(pFxFont->GetFontSpan());
font = &FxFont;
#else
font = pFxFont;
@@ -113,10 +115,6 @@
color, FXTEXT_CLEARTYPE);
}
-#if !defined(OS_WIN)
- FxFont.SetFace(nullptr);
-#endif
-
return bRet;
}