From 163b4a4117bcc0b2bd1866d32205fbfb9cc01e02 Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Wed, 30 May 2018 14:10:40 +0000 Subject: 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 Commit-Queue: Ryan Harrison --- core/fxge/apple/fx_mac_imp.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'core/fxge') 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::CreateDefault( - const char** pUnused) { + const char** pUserPaths) { auto pInfo = pdfium::MakeUnique(); - 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() { -- cgit v1.2.3