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 #ifndef _SKIA_SUPPORT_ | 7 #ifndef _SKIA_SUPPORT_ |
8 #include "core/fxge/agg/fx_agg_driver.h" | 8 #include "core/fxge/agg/fx_agg_driver.h" |
9 #endif | 9 #endif |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "core/fxge/cfx_gemodule.h" | 13 #include "core/fxge/cfx_gemodule.h" |
14 #include "core/fxge/ge/cfx_folderfontinfo.h" | 14 #include "core/fxge/ge/cfx_folderfontinfo.h" |
15 #include "core/fxge/ge/fx_text_int.h" | 15 #include "core/fxge/ge/fx_text_int.h" |
16 #include "core/fxge/ifx_systemfontinfo.h" | 16 #include "core/fxge/ifx_systemfontinfo.h" |
17 | 17 |
18 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ | 18 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ |
19 namespace { | 19 namespace { |
20 | 20 |
21 class CFX_LinuxFontInfo : public CFX_FolderFontInfo { | 21 class CFX_LinuxFontInfo : public CFX_FolderFontInfo { |
22 public: | 22 public: |
23 void* MapFont(int weight, | 23 void* MapFont(int weight, |
24 FX_BOOL bItalic, | 24 bool bItalic, |
25 int charset, | 25 int charset, |
26 int pitch_family, | 26 int pitch_family, |
27 const FX_CHAR* family, | 27 const FX_CHAR* family, |
28 int& iExact) override; | 28 int& iExact) override; |
29 FX_BOOL ParseFontCfg(const char** pUserPaths); | 29 bool ParseFontCfg(const char** pUserPaths); |
30 }; | 30 }; |
31 | 31 |
32 const size_t kLinuxGpNameSize = 6; | 32 const size_t kLinuxGpNameSize = 6; |
33 | 33 |
34 const FX_CHAR* const g_LinuxGpFontList[][kLinuxGpNameSize] = { | 34 const FX_CHAR* const g_LinuxGpFontList[][kLinuxGpNameSize] = { |
35 {"TakaoPGothic", "VL PGothic", "IPAPGothic", "VL Gothic", "Kochi Gothic", | 35 {"TakaoPGothic", "VL PGothic", "IPAPGothic", "VL Gothic", "Kochi Gothic", |
36 "VL Gothic regular"}, | 36 "VL Gothic regular"}, |
37 {"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", nullptr, | 37 {"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", nullptr, |
38 "VL Gothic regular"}, | 38 "VL Gothic regular"}, |
39 {"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", nullptr, | 39 {"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", nullptr, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 75 } |
76 if (!(pitch_family & FXFONT_FF_ROMAN) && weight > 400) { | 76 if (!(pitch_family & FXFONT_FF_ROMAN) && weight > 400) { |
77 return 0; | 77 return 0; |
78 } | 78 } |
79 return 2; | 79 return 2; |
80 } | 80 } |
81 | 81 |
82 } // namespace | 82 } // namespace |
83 | 83 |
84 void* CFX_LinuxFontInfo::MapFont(int weight, | 84 void* CFX_LinuxFontInfo::MapFont(int weight, |
85 FX_BOOL bItalic, | 85 bool bItalic, |
86 int charset, | 86 int charset, |
87 int pitch_family, | 87 int pitch_family, |
88 const FX_CHAR* cstr_face, | 88 const FX_CHAR* cstr_face, |
89 int& iExact) { | 89 int& iExact) { |
90 void* font = GetSubstFont(cstr_face); | 90 void* font = GetSubstFont(cstr_face); |
91 if (font) { | 91 if (font) { |
92 iExact = 1; | 92 iExact = 1; |
93 return font; | 93 return font; |
94 } | 94 } |
95 FX_BOOL bCJK = TRUE; | 95 bool bCJK = true; |
96 switch (charset) { | 96 switch (charset) { |
97 case FXFONT_SHIFTJIS_CHARSET: { | 97 case FXFONT_SHIFTJIS_CHARSET: { |
98 size_t index = GetJapanesePreference(cstr_face, weight, pitch_family); | 98 size_t index = GetJapanesePreference(cstr_face, weight, pitch_family); |
99 ASSERT(index < FX_ArraySize(g_LinuxGpFontList)); | 99 ASSERT(index < FX_ArraySize(g_LinuxGpFontList)); |
100 for (size_t i = 0; i < kLinuxGpNameSize; i++) { | 100 for (size_t i = 0; i < kLinuxGpNameSize; i++) { |
101 auto it = m_FontList.find(g_LinuxGpFontList[index][i]); | 101 auto it = m_FontList.find(g_LinuxGpFontList[index][i]); |
102 if (it != m_FontList.end()) { | 102 if (it != m_FontList.end()) { |
103 return it->second; | 103 return it->second; |
104 } | 104 } |
105 } | 105 } |
(...skipping 20 matching lines...) Expand all Loading... |
126 case FXFONT_HANGUL_CHARSET: { | 126 case FXFONT_HANGUL_CHARSET: { |
127 for (size_t i = 0; i < FX_ArraySize(g_LinuxHGFontList); ++i) { | 127 for (size_t i = 0; i < FX_ArraySize(g_LinuxHGFontList); ++i) { |
128 auto it = m_FontList.find(g_LinuxHGFontList[i]); | 128 auto it = m_FontList.find(g_LinuxHGFontList[i]); |
129 if (it != m_FontList.end()) { | 129 if (it != m_FontList.end()) { |
130 return it->second; | 130 return it->second; |
131 } | 131 } |
132 } | 132 } |
133 break; | 133 break; |
134 } | 134 } |
135 default: | 135 default: |
136 bCJK = FALSE; | 136 bCJK = false; |
137 break; | 137 break; |
138 } | 138 } |
139 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK); | 139 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK); |
140 } | 140 } |
141 | 141 |
142 std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault( | 142 std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault( |
143 const char** pUserPaths) { | 143 const char** pUserPaths) { |
144 CFX_LinuxFontInfo* pInfo = new CFX_LinuxFontInfo; | 144 CFX_LinuxFontInfo* pInfo = new CFX_LinuxFontInfo; |
145 if (!pInfo->ParseFontCfg(pUserPaths)) { | 145 if (!pInfo->ParseFontCfg(pUserPaths)) { |
146 pInfo->AddPath("/usr/share/fonts"); | 146 pInfo->AddPath("/usr/share/fonts"); |
147 pInfo->AddPath("/usr/share/X11/fonts/Type1"); | 147 pInfo->AddPath("/usr/share/X11/fonts/Type1"); |
148 pInfo->AddPath("/usr/share/X11/fonts/TTF"); | 148 pInfo->AddPath("/usr/share/X11/fonts/TTF"); |
149 pInfo->AddPath("/usr/local/share/fonts"); | 149 pInfo->AddPath("/usr/local/share/fonts"); |
150 } | 150 } |
151 return std::unique_ptr<IFX_SystemFontInfo>(pInfo); | 151 return std::unique_ptr<IFX_SystemFontInfo>(pInfo); |
152 } | 152 } |
153 | 153 |
154 FX_BOOL CFX_LinuxFontInfo::ParseFontCfg(const char** pUserPaths) { | 154 bool CFX_LinuxFontInfo::ParseFontCfg(const char** pUserPaths) { |
155 if (!pUserPaths) | 155 if (!pUserPaths) |
156 return FALSE; | 156 return false; |
157 | 157 |
158 for (const char** pPath = pUserPaths; *pPath; ++pPath) | 158 for (const char** pPath = pUserPaths; *pPath; ++pPath) |
159 AddPath(*pPath); | 159 AddPath(*pPath); |
160 return TRUE; | 160 return true; |
161 } | 161 } |
162 | 162 |
163 void CFX_GEModule::InitPlatform() { | 163 void CFX_GEModule::InitPlatform() { |
164 m_pFontMgr->SetSystemFontInfo( | 164 m_pFontMgr->SetSystemFontInfo( |
165 IFX_SystemFontInfo::CreateDefault(m_pUserFontPaths)); | 165 IFX_SystemFontInfo::CreateDefault(m_pUserFontPaths)); |
166 } | 166 } |
167 | 167 |
168 void CFX_GEModule::DestroyPlatform() {} | 168 void CFX_GEModule::DestroyPlatform() {} |
169 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ | 169 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ |
OLD | NEW |