Implement handling --font-dir on Mac

Currently the value passed in via the flag is ignored on Mac. This
implements the needed logic to use the given path instead of the
standard system font directories.

BUG=pdfium:1094

Change-Id: I2a0599ce8c784add75d36089dee5e4b5476c3d3d
Reviewed-on: https://pdfium-review.googlesource.com/33090
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp
index 076cb22..f4a62a6 100644
--- a/core/fxge/apple/fx_mac_imp.cpp
+++ b/core/fxge/apple/fx_mac_imp.cpp
@@ -46,6 +46,8 @@
                 int charset,
                 int pitch_family,
                 const char* family) override;
+
+  bool ParseFontCfg(const char** pUserPaths);
 };
 
 const char JAPAN_GOTHIC[] = "Hiragino Kaku Gothic Pro W6";
@@ -118,20 +120,31 @@
   return it != m_FontList.end() ? it->second.get() : nullptr;
 }
 
+bool CFX_MacFontInfo::ParseFontCfg(const char** pUserPaths) {
+  if (!pUserPaths)
+    return false;
+
+  for (const char** pPath = pUserPaths; *pPath; ++pPath)
+    AddPath(*pPath);
+  return true;
+}
 }  // namespace
 
 std::unique_ptr<SystemFontInfoIface> SystemFontInfoIface::CreateDefault(
-    const char** pUnused) {
+    const char** pUserPaths) {
   auto pInfo = pdfium::MakeUnique<CFX_MacFontInfo>();
-  pInfo->AddPath("~/Library/Fonts");
-  pInfo->AddPath("/Library/Fonts");
-  pInfo->AddPath("/System/Library/Fonts");
+  if (!pInfo->ParseFontCfg(pUserPaths)) {
+    pInfo->AddPath("~/Library/Fonts");
+    pInfo->AddPath("/Library/Fonts");
+    pInfo->AddPath("/System/Library/Fonts");
+  }
   return std::move(pInfo);
 }
 
 void CFX_GEModule::InitPlatform() {
   m_pPlatformData = new CApplePlatform;
-  m_pFontMgr->SetSystemFontInfo(SystemFontInfoIface::CreateDefault(nullptr));
+  m_pFontMgr->SetSystemFontInfo(
+      SystemFontInfoIface::CreateDefault(m_pUserFontPaths));
 }
 
 void CFX_GEModule::DestroyPlatform() {