Rescan fonts for XFA after FPDF_SetSystemFontInfo()

Otherwise some XFA documents won't render because the fonts
can't be found, since at least for the chrome embedder, the
call to FPDF_SetSystemFontInfo() happens after the CFGAS
singleton is initialized.

Bug: chromium:1273700
Change-Id: I836e1029841f800360ca9cd34e6f8494cdc9fc85
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/87590
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxge/cfx_fontmapper.cpp b/core/fxge/cfx_fontmapper.cpp
index af21273..47ccf52 100644
--- a/core/fxge/cfx_fontmapper.cpp
+++ b/core/fxge/cfx_fontmapper.cpp
@@ -281,6 +281,7 @@
   if (!pFontInfo)
     return;
 
+  m_bListLoaded = false;
   m_pFontInfo = std::move(pFontInfo);
 }
 
diff --git a/fpdfsdk/BUILD.gn b/fpdfsdk/BUILD.gn
index fe1abaa..e2b0430 100644
--- a/fpdfsdk/BUILD.gn
+++ b/fpdfsdk/BUILD.gn
@@ -100,6 +100,7 @@
 
   if (pdf_enable_xfa) {
     deps += [
+      "../xfa/fgas/font",
       "../xfa/fxfa",
       "../xfa/fxfa/parser",
       "fpdfxfa",
diff --git a/fpdfsdk/DEPS b/fpdfsdk/DEPS
index eb290eb..0e367fb 100644
--- a/fpdfsdk/DEPS
+++ b/fpdfsdk/DEPS
@@ -3,6 +3,7 @@
   '+fxjs',
   '+public',
   '+v8',
+  '+xfa/fgas/font',
   '+xfa/fgas/graphics',
   '+xfa/fwl',
   '+xfa/fxfa',
diff --git a/fpdfsdk/fpdf_sysfontinfo.cpp b/fpdfsdk/fpdf_sysfontinfo.cpp
index 0c8f245..5c87444 100644
--- a/fpdfsdk/fpdf_sysfontinfo.cpp
+++ b/fpdfsdk/fpdf_sysfontinfo.cpp
@@ -21,6 +21,11 @@
 #include "core/fxge/systemfontinfo_iface.h"
 #include "third_party/base/numerics/safe_conversions.h"
 
+#ifdef PDF_ENABLE_XFA
+#include "xfa/fgas/font/cfgas_fontmgr.h"
+#include "xfa/fgas/font/cfgas_gemodule.h"
+#endif
+
 static_assert(FXFONT_ANSI_CHARSET == static_cast<int>(FX_Charset::kANSI),
               "Charset must match");
 static_assert(FXFONT_DEFAULT_CHARSET == static_cast<int>(FX_Charset::kDefault),
@@ -155,6 +160,10 @@
 
   CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper()->SetSystemFontInfo(
       std::make_unique<CFX_ExternalFontInfo>(pFontInfoExt));
+
+#ifdef PDF_ENABLE_XFA
+  CFGAS_GEModule::Get()->GetFontMgr()->EnumFonts();
+#endif
 }
 
 FPDF_EXPORT const FPDF_CharsetFontMap* FPDF_CALLCONV FPDF_GetDefaultTTFMap() {