Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: core/src/fxge/ge/fx_ge_linux.cpp

Issue 1268323004: Allow external font-path configuration from pdfium_test. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Remove python driver changes Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 iSimilarValue = 221 iSimilarValue =
222 _LinuxGetSimilarValue(weight, bItalic, pitch_family, pFont->m_Styles); 222 _LinuxGetSimilarValue(weight, bItalic, pitch_family, pFont->m_Styles);
223 if (iSimilarValue > iBestSimilar) { 223 if (iSimilarValue > iBestSimilar) {
224 iBestSimilar = iSimilarValue; 224 iBestSimilar = iSimilarValue;
225 pFind = pFont; 225 pFind = pFont;
226 } 226 }
227 } 227 }
228 return pFind; 228 return pFind;
229 } 229 }
230 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() { 230 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUserPaths) {
231 CFX_LinuxFontInfo* pInfo = new CFX_LinuxFontInfo; 231 CFX_LinuxFontInfo* pInfo = new CFX_LinuxFontInfo;
232 if (!pInfo->ParseFontCfg()) { 232 if (!pInfo->ParseFontCfg(pUserPaths)) {
233 pInfo->AddPath("/usr/share/fonts"); 233 pInfo->AddPath("/usr/share/fonts");
234 pInfo->AddPath("/usr/share/X11/fonts/Type1"); 234 pInfo->AddPath("/usr/share/X11/fonts/Type1");
235 pInfo->AddPath("/usr/share/X11/fonts/TTF"); 235 pInfo->AddPath("/usr/share/X11/fonts/TTF");
236 pInfo->AddPath("/usr/local/share/fonts"); 236 pInfo->AddPath("/usr/local/share/fonts");
237 } 237 }
238 return pInfo; 238 return pInfo;
239 } 239 }
240 FX_BOOL CFX_LinuxFontInfo::ParseFontCfg() { 240 FX_BOOL CFX_LinuxFontInfo::ParseFontCfg(const char** pUserPaths) {
241 return FALSE; 241 if (!pUserPaths) {
242 return FALSE;
243 }
244 for (const char** pPath = pUserPaths; *pPath; ++pPath) {
245 AddPath(*pPath);
246 }
247 return TRUE;
242 } 248 }
243 void CFX_GEModule::InitPlatform() { 249 void CFX_GEModule::InitPlatform() {
244 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault()); 250 m_pFontMgr->SetSystemFontInfo(
251 IFX_SystemFontInfo::CreateDefault(m_pUserFontPaths));
245 } 252 }
246 void CFX_GEModule::DestroyPlatform() {} 253 void CFX_GEModule::DestroyPlatform() {}
247 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ 254 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698