Use test_fonts for pdfium_unittests on all platforms

Bug: chromium:1250250
Change-Id: I7a654b51e8c46b8805881e2b6f329868ac949550
R=thestig
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/86511
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxge/win32/cwin32_platform.cpp b/core/fxge/win32/cwin32_platform.cpp
index f426df3..1c36a53 100644
--- a/core/fxge/win32/cwin32_platform.cpp
+++ b/core/fxge/win32/cwin32_platform.cpp
@@ -441,6 +441,14 @@
 
 std::unique_ptr<SystemFontInfoIface>
 CWin32Platform::CreateDefaultSystemFontInfo() {
+  auto** user_paths = CFX_GEModule::Get()->GetUserFontPaths();
+  if (user_paths) {
+    auto font_info = std::make_unique<CFX_Win32FallbackFontInfo>();
+    for (; *user_paths; user_paths++)
+      font_info->AddPath(*user_paths);
+    return std::move(font_info);
+  }
+
   if (pdfium::base::win::IsUser32AndGdi32Available())
     return std::make_unique<CFX_Win32FontInfo>();
 
diff --git a/testing/BUILD.gn b/testing/BUILD.gn
index 5b7215f..76f1faa 100644
--- a/testing/BUILD.gn
+++ b/testing/BUILD.gn
@@ -27,7 +27,10 @@
     "utils/hash.h",
   ]
   data = [ "resources/" ]
-  public_deps = [ ":path_service" ]
+  public_deps = [
+    ":path_service",
+    "//third_party/test_fonts",
+  ]
   deps = [
     "../:pdfium_public_headers",
     "../core/fdrm",
@@ -48,9 +51,6 @@
     ]
     configs += [ "//v8:external_startup_data" ]
   }
-  if (is_linux || is_chromeos) {
-    public_deps += [ "//third_party/test_fonts" ]
-  }
 }
 
 source_set("path_service") {
diff --git a/testing/pdf_test_environment.cpp b/testing/pdf_test_environment.cpp
index 1148d5a..93bac19 100644
--- a/testing/pdf_test_environment.cpp
+++ b/testing/pdf_test_environment.cpp
@@ -5,6 +5,7 @@
 #include "testing/pdf_test_environment.h"
 
 #include "core/fxge/cfx_gemodule.h"
+#include "testing/gtest/include/gtest/gtest.h"
 #include "testing/utils/path_service.h"
 
 PDFTestEnvironment::PDFTestEnvironment() = default;
@@ -13,16 +14,12 @@
 
 // testing::Environment:
 void PDFTestEnvironment::SetUp() {
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
-  if (PathService::GetExecutableDir(&font_path_)) {
-    font_path_ += "/test_fonts";
-    font_paths_[0] = font_path_.c_str();
-    font_paths_[1] = nullptr;
-    CFX_GEModule::Create(font_paths_);
-    return;
-  }
-#endif
-  CFX_GEModule::Create(nullptr);
+  ASSERT_TRUE(PathService::GetExecutableDir(&font_path_));
+  font_path_.push_back(PATH_SEPARATOR);
+  font_path_.append("test_fonts");
+  font_paths_[0] = font_path_.c_str();
+  font_paths_[1] = nullptr;
+  CFX_GEModule::Create(font_paths_);
 }
 
 void PDFTestEnvironment::TearDown() {
diff --git a/testing/pdf_test_environment.h b/testing/pdf_test_environment.h
index d8fda31..f422df5 100644
--- a/testing/pdf_test_environment.h
+++ b/testing/pdf_test_environment.h
@@ -7,7 +7,6 @@
 
 #include <string>
 
-#include "build/build_config.h"
 #include "testing/gtest/include/gtest/gtest.h"
 
 class PDFTestEnvironment : public testing::Environment {
@@ -20,10 +19,8 @@
   void TearDown() override;
 
  private:
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
   std::string font_path_;
   const char* font_paths_[2];
-#endif
 };
 
 #endif  // TESTING_PDF_TEST_ENVIRONMENT_H_
diff --git a/xfa/fde/cfde_texteditengine_unittest.cpp b/xfa/fde/cfde_texteditengine_unittest.cpp
index 6c5cdec..36c4d35 100644
--- a/xfa/fde/cfde_texteditengine_unittest.cpp
+++ b/xfa/fde/cfde_texteditengine_unittest.cpp
@@ -4,7 +4,6 @@
 
 #include "xfa/fde/cfde_texteditengine.h"
 
-#include "build/build_config.h"
 #include "core/fxcrt/fx_codepage.h"
 #include "core/fxcrt/fx_extension.h"
 #include "core/fxge/text_char_pos.h"
@@ -40,11 +39,7 @@
   ~CFDE_TextEditEngineTest() override = default;
 
   void SetUp() override {
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
     const wchar_t kFontFamily[] = L"Arimo Bold";
-#else
-    const wchar_t kFontFamily[] = L"Arial Bold";
-#endif
     font_ = CFGAS_GEFont::LoadFont(kFontFamily, 0, FX_CodePage::kDefANSI);
     ASSERT_TRUE(font_);
 
diff --git a/xfa/fgas/layout/cfgas_rtfbreak_unittest.cpp b/xfa/fgas/layout/cfgas_rtfbreak_unittest.cpp
index 6c999f1..c4e7a9d 100644
--- a/xfa/fgas/layout/cfgas_rtfbreak_unittest.cpp
+++ b/xfa/fgas/layout/cfgas_rtfbreak_unittest.cpp
@@ -20,11 +20,7 @@
 class CFGAS_RTFBreakTest : public testing::Test {
  public:
   void SetUp() override {
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
     const wchar_t kFontFamily[] = L"Arimo Bold";
-#else
-    const wchar_t kFontFamily[] = L"Arial Bold";
-#endif
     font_ = CFGAS_GEFont::LoadFont(kFontFamily, 0, FX_CodePage::kDefANSI);
     ASSERT_TRUE(font_);
   }
diff --git a/xfa/fgas/layout/cfgas_txtbreak_unittest.cpp b/xfa/fgas/layout/cfgas_txtbreak_unittest.cpp
index c9f0d0f..533791c 100644
--- a/xfa/fgas/layout/cfgas_txtbreak_unittest.cpp
+++ b/xfa/fgas/layout/cfgas_txtbreak_unittest.cpp
@@ -17,11 +17,7 @@
 class CFGAS_TxtBreakTest : public testing::Test {
  public:
   void SetUp() override {
-#if defined(OS_LINUX) || defined(OS_CHROMEOS)
     const wchar_t kFontFamily[] = L"Arimo Bold";
-#else
-    const wchar_t kFontFamily[] = L"Arial Bold";
-#endif
     font_ = CFGAS_GEFont::LoadFont(kFontFamily, 0, FX_CodePage::kDefANSI);
     ASSERT_TRUE(font_);
   }