diff options
author | Ryan Harrison <rharrison@chromium.org> | 2018-05-30 14:10:40 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-05-30 14:10:40 +0000 |
commit | 163b4a4117bcc0b2bd1866d32205fbfb9cc01e02 (patch) | |
tree | 393c04eca9cc2b456afd5b52d30c23f095b2a31e /core | |
parent | 491112b06c802de0d7dc577e77690d1a081f05c9 (diff) | |
download | pdfium-163b4a4117bcc0b2bd1866d32205fbfb9cc01e02.tar.xz |
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>
Diffstat (limited to 'core')
-rw-r--r-- | core/fxge/apple/fx_mac_imp.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/core/fxge/apple/fx_mac_imp.cpp b/core/fxge/apple/fx_mac_imp.cpp index 076cb2288c..f4a62a62d8 100644 --- a/core/fxge/apple/fx_mac_imp.cpp +++ b/core/fxge/apple/fx_mac_imp.cpp @@ -46,6 +46,8 @@ class CFX_MacFontInfo : public CFX_FolderFontInfo { 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 @@ void* CFX_MacFontInfo::MapFont(int weight, 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() { |