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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 int iBaseFont; | 98 int iBaseFont; |
99 for (iBaseFont = 0; iBaseFont < 12; iBaseFont++) | 99 for (iBaseFont = 0; iBaseFont < 12; iBaseFont++) |
100 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) { | 100 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) { |
101 face = Base14Substs[iBaseFont].m_pSubstName; | 101 face = Base14Substs[iBaseFont].m_pSubstName; |
102 iExact = 1; | 102 iExact = 1; |
103 break; | 103 break; |
104 } | 104 } |
105 if (iBaseFont < 12) { | 105 if (iBaseFont < 12) { |
106 return GetFont(face); | 106 return GetFont(face); |
107 } | 107 } |
108 void* p = NULL; | |
109 FX_BOOL bCJK = TRUE; | 108 FX_BOOL bCJK = TRUE; |
110 switch (charset) { | 109 switch (charset) { |
111 case FXFONT_SHIFTJIS_CHARSET: { | 110 case FXFONT_SHIFTJIS_CHARSET: { |
112 int32_t index = GetJapanesePreference(cstr_face, weight, pitch_family); | 111 int32_t index = GetJapanesePreference(cstr_face, weight, pitch_family); |
113 if (index < 0) { | 112 if (index < 0) { |
114 break; | 113 break; |
115 } | 114 } |
116 for (int32_t i = 0; i < LINUX_GPNAMESIZE; i++) | 115 for (int32_t i = 0; i < LINUX_GPNAMESIZE; i++) { |
117 if (m_FontList.Lookup(LinuxGpFontList[index].NameArr[i], p)) { | 116 auto it = m_FontList.find(LinuxGpFontList[index].NameArr[i]); |
118 return p; | 117 if (it != m_FontList.end()) { |
| 118 return it->second; |
119 } | 119 } |
| 120 } |
120 } break; | 121 } break; |
121 case FXFONT_GB2312_CHARSET: { | 122 case FXFONT_GB2312_CHARSET: { |
122 static int32_t s_gbCount = | 123 for (int32_t i = 0; i < FX_ArraySize(g_LinuxGbFontList); ++i) { |
123 sizeof(g_LinuxGbFontList) / sizeof(const FX_CHAR*); | 124 auto it = m_FontList.find(g_LinuxGbFontList[i]); |
124 for (int32_t i = 0; i < s_gbCount; i++) | 125 if (it != m_FontList.end()) { |
125 if (m_FontList.Lookup(g_LinuxGbFontList[i], p)) { | 126 return it->second; |
126 return p; | |
127 } | 127 } |
| 128 } |
128 } break; | 129 } break; |
129 case FXFONT_CHINESEBIG5_CHARSET: { | 130 case FXFONT_CHINESEBIG5_CHARSET: { |
130 static int32_t s_b5Count = | 131 for (int32_t i = 0; i < FX_ArraySize(g_LinuxB5FontList); ++i) { |
131 sizeof(g_LinuxB5FontList) / sizeof(const FX_CHAR*); | 132 auto it = m_FontList.find(g_LinuxB5FontList[i]); |
132 for (int32_t i = 0; i < s_b5Count; i++) | 133 if (it != m_FontList.end()) { |
133 if (m_FontList.Lookup(g_LinuxB5FontList[i], p)) { | 134 return it->second; |
134 return p; | |
135 } | 135 } |
| 136 } |
136 } break; | 137 } break; |
137 case FXFONT_HANGEUL_CHARSET: { | 138 case FXFONT_HANGEUL_CHARSET: { |
138 static int32_t s_hgCount = | 139 for (int32_t i = 0; i < FX_ArraySize(g_LinuxHGFontList); ++i) { |
139 sizeof(g_LinuxHGFontList) / sizeof(const FX_CHAR*); | 140 auto it = m_FontList.find(g_LinuxHGFontList[i]); |
140 for (int32_t i = 0; i < s_hgCount; i++) | 141 if (it != m_FontList.end()) { |
141 if (m_FontList.Lookup(g_LinuxHGFontList[i], p)) { | 142 return it->second; |
142 return p; | |
143 } | 143 } |
| 144 } |
144 } break; | 145 } break; |
145 default: | 146 default: |
146 bCJK = FALSE; | 147 bCJK = FALSE; |
147 break; | 148 break; |
148 } | 149 } |
149 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) { | 150 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) { |
150 return GetFont("Courier New"); | 151 return GetFont("Courier New"); |
151 } | 152 } |
152 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK); | 153 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK); |
153 } | 154 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 } | 195 } |
195 void* CFX_LinuxFontInfo::FindFont(int weight, | 196 void* CFX_LinuxFontInfo::FindFont(int weight, |
196 FX_BOOL bItalic, | 197 FX_BOOL bItalic, |
197 int charset, | 198 int charset, |
198 int pitch_family, | 199 int pitch_family, |
199 const FX_CHAR* family, | 200 const FX_CHAR* family, |
200 FX_BOOL bMatchName) { | 201 FX_BOOL bMatchName) { |
201 CFX_FontFaceInfo* pFind = NULL; | 202 CFX_FontFaceInfo* pFind = NULL; |
202 FX_DWORD charset_flag = _LinuxGetCharset(charset); | 203 FX_DWORD charset_flag = _LinuxGetCharset(charset); |
203 int32_t iBestSimilar = 0; | 204 int32_t iBestSimilar = 0; |
204 FX_POSITION pos = m_FontList.GetStartPosition(); | 205 for (const auto& it : m_FontList) { |
205 while (pos) { | 206 const CFX_ByteString& bsName = it.first; |
206 CFX_ByteString bsName; | 207 CFX_FontFaceInfo* pFont = it.second; |
207 CFX_FontFaceInfo* pFont = NULL; | |
208 m_FontList.GetNextAssoc(pos, bsName, (void*&)pFont); | |
209 if (!(pFont->m_Charsets & charset_flag) && | 208 if (!(pFont->m_Charsets & charset_flag) && |
210 charset != FXFONT_DEFAULT_CHARSET) { | 209 charset != FXFONT_DEFAULT_CHARSET) { |
211 continue; | 210 continue; |
212 } | 211 } |
213 int32_t iSimilarValue = 0; | 212 int32_t iSimilarValue = 0; |
214 int32_t index = bsName.Find(family); | 213 int32_t index = bsName.Find(family); |
215 if (bMatchName && index < 0) { | 214 if (bMatchName && index < 0) { |
216 continue; | 215 continue; |
217 } | 216 } |
218 if (!bMatchName && index > 0) { | 217 if (!bMatchName && index > 0) { |
(...skipping 26 matching lines...) Expand all Loading... |
245 AddPath(*pPath); | 244 AddPath(*pPath); |
246 } | 245 } |
247 return TRUE; | 246 return TRUE; |
248 } | 247 } |
249 void CFX_GEModule::InitPlatform() { | 248 void CFX_GEModule::InitPlatform() { |
250 m_pFontMgr->SetSystemFontInfo( | 249 m_pFontMgr->SetSystemFontInfo( |
251 IFX_SystemFontInfo::CreateDefault(m_pUserFontPaths)); | 250 IFX_SystemFontInfo::CreateDefault(m_pUserFontPaths)); |
252 } | 251 } |
253 void CFX_GEModule::DestroyPlatform() {} | 252 void CFX_GEModule::DestroyPlatform() {} |
254 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ | 253 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ |
OLD | NEW |