OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
8 #include "../agg/include/fx_agg_driver.h" | 8 #include "../agg/include/fx_agg_driver.h" |
9 #include "text_int.h" | 9 #include "text_int.h" |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 {"Times-Italic", "Times New Roman Italic"}, | 27 {"Times-Italic", "Times New Roman Italic"}, |
28 }; | 28 }; |
29 class CFX_LinuxFontInfo : public CFX_FolderFontInfo { | 29 class CFX_LinuxFontInfo : public CFX_FolderFontInfo { |
30 public: | 30 public: |
31 void* MapFont(int weight, | 31 void* MapFont(int weight, |
32 FX_BOOL bItalic, | 32 FX_BOOL bItalic, |
33 int charset, | 33 int charset, |
34 int pitch_family, | 34 int pitch_family, |
35 const FX_CHAR* family, | 35 const FX_CHAR* family, |
36 int& iExact) override; | 36 int& iExact) override; |
37 FX_BOOL ParseFontCfg(); | 37 FX_BOOL ParseFontCfg(const char** pUserPaths); |
38 void* FindFont(int weight, | 38 void* FindFont(int weight, |
39 FX_BOOL bItalic, | 39 FX_BOOL bItalic, |
40 int charset, | 40 int charset, |
41 int pitch_family, | 41 int pitch_family, |
42 const FX_CHAR* family, | 42 const FX_CHAR* family, |
43 FX_BOOL bMatchName); | 43 FX_BOOL bMatchName); |
44 }; | 44 }; |
45 #define LINUX_GPNAMESIZE 6 | 45 #define LINUX_GPNAMESIZE 6 |
46 static const struct { | 46 static const struct { |
47 const FX_CHAR* NameArr[LINUX_GPNAMESIZE]; | 47 const FX_CHAR* NameArr[LINUX_GPNAMESIZE]; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 } | 219 } |
220 iSimilarValue = | 220 iSimilarValue = |
221 _LinuxGetSimilarValue(weight, bItalic, pitch_family, pFont->m_Styles); | 221 _LinuxGetSimilarValue(weight, bItalic, pitch_family, pFont->m_Styles); |
222 if (iSimilarValue > iBestSimilar) { | 222 if (iSimilarValue > iBestSimilar) { |
223 iBestSimilar = iSimilarValue; | 223 iBestSimilar = iSimilarValue; |
224 pFind = pFont; | 224 pFind = pFont; |
225 } | 225 } |
226 } | 226 } |
227 return pFind; | 227 return pFind; |
228 } | 228 } |
229 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() { | 229 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUserPaths) { |
230 CFX_LinuxFontInfo* pInfo = new CFX_LinuxFontInfo; | 230 CFX_LinuxFontInfo* pInfo = new CFX_LinuxFontInfo; |
231 if (!pInfo) { | 231 if (!pInfo->ParseFontCfg(pUserPaths)) { |
232 return NULL; | |
233 } | |
234 if (!pInfo->ParseFontCfg()) { | |
235 pInfo->AddPath("/usr/share/fonts"); | 232 pInfo->AddPath("/usr/share/fonts"); |
236 pInfo->AddPath("/usr/share/X11/fonts/Type1"); | 233 pInfo->AddPath("/usr/share/X11/fonts/Type1"); |
237 pInfo->AddPath("/usr/share/X11/fonts/TTF"); | 234 pInfo->AddPath("/usr/share/X11/fonts/TTF"); |
238 pInfo->AddPath("/usr/local/share/fonts"); | 235 pInfo->AddPath("/usr/local/share/fonts"); |
239 } | 236 } |
240 return pInfo; | 237 return pInfo; |
241 } | 238 } |
242 FX_BOOL CFX_LinuxFontInfo::ParseFontCfg() { | 239 FX_BOOL CFX_LinuxFontInfo::ParseFontCfg(const char** pUserPaths) { |
243 return FALSE; | 240 if (!pUserPaths) { |
| 241 return FALSE; |
| 242 } |
| 243 for (const char** pPath = pUserPaths; *pPath; ++pPath) { |
| 244 AddPath(*pPath); |
| 245 } |
| 246 return TRUE; |
244 } | 247 } |
245 void CFX_GEModule::InitPlatform() { | 248 void CFX_GEModule::InitPlatform() { |
246 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault()); | 249 m_pFontMgr->SetSystemFontInfo( |
| 250 IFX_SystemFontInfo::CreateDefault(m_pUserFontPaths)); |
247 } | 251 } |
248 void CFX_GEModule::DestroyPlatform() {} | 252 void CFX_GEModule::DestroyPlatform() {} |
249 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ | 253 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ |
OLD | NEW |