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

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_FontMap.cpp

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 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
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Icon.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/pdfwindow/PDFWindow.h" 7 #include "../../include/pdfwindow/PDFWindow.h"
8 #include "../../include/pdfwindow/PWL_Wnd.h" 8 #include "../../include/pdfwindow/PWL_Wnd.h"
9 #include "../../include/pdfwindow/PWL_FontMap.h" 9 #include "../../include/pdfwindow/PWL_FontMap.h"
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 if (CPDF_ModuleMgr::Get()) 42 if (CPDF_ModuleMgr::Get())
43 { 43 {
44 m_pPDFDoc = FX_NEW CPDF_Document; 44 m_pPDFDoc = FX_NEW CPDF_Document;
45 m_pPDFDoc->CreateNewDoc(); 45 m_pPDFDoc->CreateNewDoc();
46 } 46 }
47 } 47 }
48 48
49 return m_pPDFDoc; 49 return m_pPDFDoc;
50 } 50 }
51 51
52 CPDF_Font* CPWL_FontMap::GetPDFFont(FX_INT32 nFontIndex) 52 CPDF_Font* CPWL_FontMap::GetPDFFont(int32_t nFontIndex)
53 { 53 {
54 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize()) 54 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
55 { 55 {
56 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) 56 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
57 { 57 {
58 return pData->pFont; 58 return pData->pFont;
59 } 59 }
60 } 60 }
61 61
62 return NULL; 62 return NULL;
63 } 63 }
64 64
65 CFX_ByteString CPWL_FontMap::GetPDFFontAlias(FX_INT32 nFontIndex) 65 CFX_ByteString CPWL_FontMap::GetPDFFontAlias(int32_t nFontIndex)
66 { 66 {
67 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize()) 67 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
68 { 68 {
69 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) 69 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
70 { 70 {
71 return pData->sFontName; 71 return pData->sFontName;
72 } 72 }
73 } 73 }
74 74
75 return ""; 75 return "";
76 } 76 }
77 77
78 FX_BOOL CPWL_FontMap::KnowWord(FX_INT32 nFontIndex, FX_WORD word) 78 FX_BOOL CPWL_FontMap::KnowWord(int32_t nFontIndex, FX_WORD word)
79 { 79 {
80 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize()) 80 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
81 { 81 {
82 if (m_aData.GetAt(nFontIndex)) 82 if (m_aData.GetAt(nFontIndex))
83 { 83 {
84 return CharCodeFromUnicode(nFontIndex, word) >= 0; 84 return CharCodeFromUnicode(nFontIndex, word) >= 0;
85 } 85 }
86 } 86 }
87 87
88 return FALSE; 88 return FALSE;
89 } 89 }
90 90
91 FX_INT32 CPWL_FontMap::GetWordFontIndex(FX_WORD word, FX_INT32 nCharset, FX_INT3 2 nFontIndex) 91 int32_t CPWL_FontMap::GetWordFontIndex(FX_WORD word, int32_t nCharset, int32_t n FontIndex)
92 { 92 {
93 if (nFontIndex > 0) 93 if (nFontIndex > 0)
94 { 94 {
95 if (KnowWord(nFontIndex, word)) 95 if (KnowWord(nFontIndex, word))
96 return nFontIndex; 96 return nFontIndex;
97 } 97 }
98 else 98 else
99 { 99 {
100 if (const CPWL_FontMap_Data* pData = GetFontMapData(0)) 100 if (const CPWL_FontMap_Data* pData = GetFontMapData(0))
101 { 101 {
102 if (nCharset == DEFAULT_CHARSET || 102 if (nCharset == DEFAULT_CHARSET ||
103 pData->nCharset == SYMBOL_CHARSET || 103 pData->nCharset == SYMBOL_CHARSET ||
104 nCharset == pData->nCharset) 104 nCharset == pData->nCharset)
105 { 105 {
106 if (KnowWord(0, word)) 106 if (KnowWord(0, word))
107 { 107 {
108 return 0; 108 return 0;
109 } 109 }
110 } 110 }
111 } 111 }
112 } 112 }
113 113
114 » FX_INT32 nNewFontIndex = -1; 114 » int32_t nNewFontIndex = -1;
115 115
116 nNewFontIndex = this->GetFontIndex(GetNativeFontName(nCharset), nCharset , TRUE); 116 nNewFontIndex = this->GetFontIndex(GetNativeFontName(nCharset), nCharset , TRUE);
117 if (nNewFontIndex >= 0) 117 if (nNewFontIndex >= 0)
118 { 118 {
119 if (KnowWord(nNewFontIndex, word)) 119 if (KnowWord(nNewFontIndex, word))
120 return nNewFontIndex; 120 return nNewFontIndex;
121 } 121 }
122 122
123 nNewFontIndex = this->GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE); 123 nNewFontIndex = this->GetFontIndex("Arial Unicode MS", DEFAULT_CHARSET, FALSE);
124 if (nNewFontIndex >= 0) 124 if (nNewFontIndex >= 0)
125 { 125 {
126 if (KnowWord(nNewFontIndex, word)) 126 if (KnowWord(nNewFontIndex, word))
127 return nNewFontIndex; 127 return nNewFontIndex;
128 } 128 }
129 129
130 return -1; 130 return -1;
131 } 131 }
132 132
133 FX_INT32 CPWL_FontMap::CharCodeFromUnicode(FX_INT32 nFontIndex, FX_WORD word) 133 int32_t CPWL_FontMap::CharCodeFromUnicode(int32_t nFontIndex, FX_WORD word)
134 { 134 {
135 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) 135 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
136 { 136 {
137 if (pData->pFont) 137 if (pData->pFont)
138 { 138 {
139 if (pData->pFont->IsUnicodeCompatible()) 139 if (pData->pFont->IsUnicodeCompatible())
140 { 140 {
141 int nCharCode = pData->pFont->CharCodeFromUnicod e(word); 141 int nCharCode = pData->pFont->CharCodeFromUnicod e(word);
142 pData->pFont->GlyphFromCharCode(nCharCode); 142 pData->pFont->GlyphFromCharCode(nCharCode);
143 return nCharCode; 143 return nCharCode;
144 } 144 }
145 else 145 else
146 { 146 {
147 if (word < 0xFF) 147 if (word < 0xFF)
148 return word; 148 return word;
149 } 149 }
150 } 150 }
151 } 151 }
152 152
153 return -1; 153 return -1;
154 } 154 }
155 155
156 CFX_ByteString CPWL_FontMap::GetNativeFontName(FX_INT32 nCharset) 156 CFX_ByteString CPWL_FontMap::GetNativeFontName(int32_t nCharset)
157 { 157 {
158 //searching native font is slow, so we must save time 158 //searching native font is slow, so we must save time
159 » for (FX_INT32 i=0,sz=m_aNativeFont.GetSize(); i<sz; i++) 159 » for (int32_t i=0,sz=m_aNativeFont.GetSize(); i<sz; i++)
160 { 160 {
161 if (CPWL_FontMap_Native* pData = m_aNativeFont.GetAt(i)) 161 if (CPWL_FontMap_Native* pData = m_aNativeFont.GetAt(i))
162 { 162 {
163 if (pData->nCharset == nCharset) 163 if (pData->nCharset == nCharset)
164 return pData->sFontName; 164 return pData->sFontName;
165 } 165 }
166 } 166 }
167 167
168 CFX_ByteString sNew = GetNativeFont(nCharset); 168 CFX_ByteString sNew = GetNativeFont(nCharset);
169 169
170 if (!sNew.IsEmpty()) 170 if (!sNew.IsEmpty())
171 { 171 {
172 CPWL_FontMap_Native* pNewData = new CPWL_FontMap_Native; 172 CPWL_FontMap_Native* pNewData = new CPWL_FontMap_Native;
173 pNewData->nCharset = nCharset; 173 pNewData->nCharset = nCharset;
174 pNewData->sFontName = sNew; 174 pNewData->sFontName = sNew;
175 175
176 m_aNativeFont.Add(pNewData); 176 m_aNativeFont.Add(pNewData);
177 } 177 }
178 178
179 return sNew; 179 return sNew;
180 } 180 }
181 181
182 void CPWL_FontMap::Empty() 182 void CPWL_FontMap::Empty()
183 { 183 {
184 { 184 {
185 » » for (FX_INT32 i=0, sz=m_aData.GetSize(); i<sz; i++) 185 » » for (int32_t i=0, sz=m_aData.GetSize(); i<sz; i++)
186 delete m_aData.GetAt(i); 186 delete m_aData.GetAt(i);
187 187
188 m_aData.RemoveAll(); 188 m_aData.RemoveAll();
189 } 189 }
190 { 190 {
191 » » for (FX_INT32 i=0, sz=m_aNativeFont.GetSize(); i<sz; i++) 191 » » for (int32_t i=0, sz=m_aNativeFont.GetSize(); i<sz; i++)
192 delete m_aNativeFont.GetAt(i); 192 delete m_aNativeFont.GetAt(i);
193 193
194 m_aNativeFont.RemoveAll(); 194 m_aNativeFont.RemoveAll();
195 } 195 }
196 } 196 }
197 197
198 void CPWL_FontMap::Initial(FX_LPCSTR fontname) 198 void CPWL_FontMap::Initial(FX_LPCSTR fontname)
199 { 199 {
200 CFX_ByteString sFontName = fontname; 200 CFX_ByteString sFontName = fontname;
201 201
(...skipping 14 matching lines...) Expand all
216 Symbol, ZapfDingbats 216 Symbol, ZapfDingbats
217 */ 217 */
218 218
219 const char* g_sDEStandardFontName[] = {"Courier", "Courier-Bold", "Courier-BoldO blique", "Courier-Oblique", 219 const char* g_sDEStandardFontName[] = {"Courier", "Courier-Bold", "Courier-BoldO blique", "Courier-Oblique",
220 "Helvetica", "Helvetica-Bold", "Helvetica-BoldOblique", "Helvetica-Obliq ue", 220 "Helvetica", "Helvetica-Bold", "Helvetica-BoldOblique", "Helvetica-Obliq ue",
221 "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic", 221 "Times-Roman", "Times-Bold", "Times-Italic", "Times-BoldItalic",
222 "Symbol", "ZapfDingbats"}; 222 "Symbol", "ZapfDingbats"};
223 223
224 FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName) 224 FX_BOOL CPWL_FontMap::IsStandardFont(const CFX_ByteString& sFontName)
225 { 225 {
226 » for (FX_INT32 i=0; i<14; i++) 226 » for (int32_t i=0; i<14; i++)
227 { 227 {
228 if (sFontName == g_sDEStandardFontName[i]) 228 if (sFontName == g_sDEStandardFontName[i])
229 return TRUE; 229 return TRUE;
230 } 230 }
231 231
232 return FALSE; 232 return FALSE;
233 } 233 }
234 234
235 FX_INT32 CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, FX_INT32 nChars et) 235 int32_t CPWL_FontMap::FindFont(const CFX_ByteString& sFontName, int32_t nCharset )
236 { 236 {
237 » for (FX_INT32 i=0,sz=m_aData.GetSize(); i<sz; i++) 237 » for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++)
238 { 238 {
239 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) 239 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i))
240 { 240 {
241 if (nCharset == DEFAULT_CHARSET || nCharset == pData->nC harset) 241 if (nCharset == DEFAULT_CHARSET || nCharset == pData->nC harset)
242 { 242 {
243 if (sFontName.IsEmpty() || pData->sFontName == s FontName) 243 if (sFontName.IsEmpty() || pData->sFontName == s FontName)
244 return i; 244 return i;
245 } 245 }
246 } 246 }
247 } 247 }
248 248
249 return -1; 249 return -1;
250 } 250 }
251 251
252 FX_INT32 CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, FX_INT32 nC harset, FX_BOOL bFind) 252 int32_t CPWL_FontMap::GetFontIndex(const CFX_ByteString& sFontName, int32_t nCha rset, FX_BOOL bFind)
253 { 253 {
254 » FX_INT32 nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCh arset); 254 » int32_t nFontIndex = FindFont(EncodeFontAlias(sFontName, nCharset), nCha rset);
255 if (nFontIndex >= 0) return nFontIndex; 255 if (nFontIndex >= 0) return nFontIndex;
256 256
257 // nFontIndex = FindFont("", nCharset); 257 // nFontIndex = FindFont("", nCharset);
258 // if (nFontIndex >= 0) return nFontIndex; 258 // if (nFontIndex >= 0) return nFontIndex;
259 259
260 CFX_ByteString sAlias; 260 CFX_ByteString sAlias;
261 CPDF_Font* pFont = NULL; 261 CPDF_Font* pFont = NULL;
262 262
263 if (bFind) 263 if (bFind)
264 pFont = FindFontSameCharset(sAlias, nCharset); 264 pFont = FindFontSameCharset(sAlias, nCharset);
(...skipping 13 matching lines...) Expand all
278 { 278 {
279 sAlias = EncodeFontAlias(sTemp, nCharset); 279 sAlias = EncodeFontAlias(sTemp, nCharset);
280 } 280 }
281 } 281 }
282 282
283 AddedFont(pFont, sAlias); 283 AddedFont(pFont, sAlias);
284 284
285 return AddFontData(pFont, sAlias, nCharset); 285 return AddFontData(pFont, sAlias, nCharset);
286 } 286 }
287 287
288 FX_INT32 CPWL_FontMap::GetPWLFontIndex(FX_WORD word, FX_INT32 nCharset) 288 int32_t CPWL_FontMap::GetPWLFontIndex(FX_WORD word, int32_t nCharset)
289 { 289 {
290 » FX_INT32 nFind = -1; 290 » int32_t nFind = -1;
291 291
292 » for (FX_INT32 i=0,sz=m_aData.GetSize(); i<sz; i++) 292 » for (int32_t i=0,sz=m_aData.GetSize(); i<sz; i++)
293 { 293 {
294 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i)) 294 if (CPWL_FontMap_Data* pData = m_aData.GetAt(i))
295 { 295 {
296 if (pData->nCharset == nCharset) 296 if (pData->nCharset == nCharset)
297 { 297 {
298 nFind = i; 298 nFind = i;
299 break; 299 break;
300 } 300 }
301 } 301 }
302 } 302 }
303 303
304 CPDF_Font* pNewFont = GetPDFFont(nFind); 304 CPDF_Font* pNewFont = GetPDFFont(nFind);
305 305
306 if (!pNewFont) return -1; 306 if (!pNewFont) return -1;
307 307
308 /* 308 /*
309 if (CPDF_Font* pFont = GetPDFFont(nFind)) 309 if (CPDF_Font* pFont = GetPDFFont(nFind))
310 { 310 {
311 PWLFont.AddWordToFontDict(pFontDict, word); 311 PWLFont.AddWordToFontDict(pFontDict, word);
312 } 312 }
313 */ 313 */
314 314
315 CFX_ByteString sAlias = EncodeFontAlias("Arial_Chrome", nCharset); 315 CFX_ByteString sAlias = EncodeFontAlias("Arial_Chrome", nCharset);
316 AddedFont(pNewFont, sAlias); 316 AddedFont(pNewFont, sAlias);
317 317
318 return AddFontData(pNewFont, sAlias, nCharset); 318 return AddFontData(pNewFont, sAlias, nCharset);
319 } 319 }
320 320
321 CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, FX_INT3 2 nCharset) 321 CPDF_Font* CPWL_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, int32_t nCharset)
322 { 322 {
323 return NULL; 323 return NULL;
324 } 324 }
325 325
326 FX_INT32 CPWL_FontMap::AddFontData(CPDF_Font* pFont, const CFX_ByteString& sFont Alias, FX_INT32 nCharset) 326 int32_t CPWL_FontMap::AddFontData(CPDF_Font* pFont, const CFX_ByteString& sFontA lias, int32_t nCharset)
327 { 327 {
328 CPWL_FontMap_Data* pNewData = new CPWL_FontMap_Data; 328 CPWL_FontMap_Data* pNewData = new CPWL_FontMap_Data;
329 pNewData->pFont = pFont; 329 pNewData->pFont = pFont;
330 pNewData->sFontName = sFontAlias; 330 pNewData->sFontName = sFontAlias;
331 pNewData->nCharset = nCharset; 331 pNewData->nCharset = nCharset;
332 332
333 m_aData.Add(pNewData); 333 m_aData.Add(pNewData);
334 334
335 return m_aData.GetSize() -1; 335 return m_aData.GetSize() -1;
336 } 336 }
337 337
338 void CPWL_FontMap::AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias) 338 void CPWL_FontMap::AddedFont(CPDF_Font* pFont, const CFX_ByteString& sFontAlias)
339 { 339 {
340 } 340 }
341 341
342 CFX_ByteString CPWL_FontMap::GetFontName(FX_INT32 nFontIndex) 342 CFX_ByteString CPWL_FontMap::GetFontName(int32_t nFontIndex)
343 { 343 {
344 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize()) 344 if (nFontIndex >=0 && nFontIndex < m_aData.GetSize())
345 { 345 {
346 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex)) 346 if (CPWL_FontMap_Data* pData = m_aData.GetAt(nFontIndex))
347 { 347 {
348 return pData->sFontName; 348 return pData->sFontName;
349 } 349 }
350 } 350 }
351 351
352 return ""; 352 return "";
353 } 353 }
354 354
355 CFX_ByteString CPWL_FontMap::GetNativeFont(FX_INT32 nCharset) 355 CFX_ByteString CPWL_FontMap::GetNativeFont(int32_t nCharset)
356 { 356 {
357 CFX_ByteString sFontName; 357 CFX_ByteString sFontName;
358 358
359 if (nCharset == DEFAULT_CHARSET) 359 if (nCharset == DEFAULT_CHARSET)
360 nCharset = GetNativeCharset(); 360 nCharset = GetNativeCharset();
361 361
362 sFontName = GetDefaultFontByCharset(nCharset); 362 sFontName = GetDefaultFontByCharset(nCharset);
363 363
364 if (m_pSystemHandler) 364 if (m_pSystemHandler)
365 { 365 {
366 if (m_pSystemHandler->FindNativeTrueTypeFont(nCharset, sFontName )) 366 if (m_pSystemHandler->FindNativeTrueTypeFont(nCharset, sFontName ))
367 return sFontName; 367 return sFontName;
368 368
369 sFontName = m_pSystemHandler->GetNativeTrueTypeFont(nCharset); 369 sFontName = m_pSystemHandler->GetNativeTrueTypeFont(nCharset);
370 } 370 }
371 371
372 return sFontName; 372 return sFontName;
373 } 373 }
374 374
375 CPDF_Font* CPWL_FontMap::AddFontToDocument(CPDF_Document* pDoc, CFX_ByteString& sFontName, FX_BYTE nCharset) 375 CPDF_Font* CPWL_FontMap::AddFontToDocument(CPDF_Document* pDoc, CFX_ByteString& sFontName, uint8_t nCharset)
376 { 376 {
377 if (IsStandardFont(sFontName)) 377 if (IsStandardFont(sFontName))
378 return AddStandardFont(pDoc, sFontName); 378 return AddStandardFont(pDoc, sFontName);
379 else 379 else
380 return AddSystemFont(pDoc, sFontName, nCharset); 380 return AddSystemFont(pDoc, sFontName, nCharset);
381 } 381 }
382 382
383 CPDF_Font* CPWL_FontMap::AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sF ontName) 383 CPDF_Font* CPWL_FontMap::AddStandardFont(CPDF_Document* pDoc, CFX_ByteString& sF ontName)
384 { 384 {
385 if (!pDoc) return NULL; 385 if (!pDoc) return NULL;
386 386
387 CPDF_Font* pFont = NULL; 387 CPDF_Font* pFont = NULL;
388 388
389 if (sFontName == "ZapfDingbats") 389 if (sFontName == "ZapfDingbats")
390 pFont = pDoc->AddStandardFont(sFontName, NULL); 390 pFont = pDoc->AddStandardFont(sFontName, NULL);
391 else 391 else
392 { 392 {
393 CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI); 393 CPDF_FontEncoding fe(PDFFONT_ENCODING_WINANSI);
394 pFont = pDoc->AddStandardFont(sFontName, &fe); 394 pFont = pDoc->AddStandardFont(sFontName, &fe);
395 } 395 }
396 396
397 return pFont; 397 return pFont;
398 } 398 }
399 399
400 CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc, CFX_ByteString& sFon tName, FX_BYTE nCharset) 400 CPDF_Font* CPWL_FontMap::AddSystemFont(CPDF_Document* pDoc, CFX_ByteString& sFon tName, uint8_t nCharset)
401 { 401 {
402 if (!pDoc) return NULL; 402 if (!pDoc) return NULL;
403 403
404 if (sFontName.IsEmpty()) sFontName = GetNativeFont(nCharset); 404 if (sFontName.IsEmpty()) sFontName = GetNativeFont(nCharset);
405 if (nCharset == DEFAULT_CHARSET) nCharset = GetNativeCharset(); 405 if (nCharset == DEFAULT_CHARSET) nCharset = GetNativeCharset();
406 406
407 if (m_pSystemHandler) 407 if (m_pSystemHandler)
408 return m_pSystemHandler->AddNativeTrueTypeFontToPDF(pDoc, sFontN ame, nCharset); 408 return m_pSystemHandler->AddNativeTrueTypeFontToPDF(pDoc, sFontN ame, nCharset);
409 409
410 return NULL; 410 return NULL;
411 } 411 }
412 412
413 CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName, FX _INT32 nCharset) 413 CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName, in t32_t nCharset)
414 { 414 {
415 CFX_ByteString sPostfix; 415 CFX_ByteString sPostfix;
416 sPostfix.Format("_%02X", nCharset); 416 sPostfix.Format("_%02X", nCharset);
417 return EncodeFontAlias(sFontName) + sPostfix; 417 return EncodeFontAlias(sFontName) + sPostfix;
418 } 418 }
419 419
420 CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName) 420 CFX_ByteString CPWL_FontMap::EncodeFontAlias(const CFX_ByteString& sFontName)
421 { 421 {
422 CFX_ByteString sRet = sFontName; 422 CFX_ByteString sRet = sFontName;
423 sRet.Remove(' '); 423 sRet.Remove(' ');
424 return sRet; 424 return sRet;
425 } 425 }
426 426
427 FX_INT32 CPWL_FontMap::GetFontMapCount() const 427 int32_t CPWL_FontMap::GetFontMapCount() const
428 { 428 {
429 return m_aData.GetSize(); 429 return m_aData.GetSize();
430 } 430 }
431 431
432 const CPWL_FontMap_Data* CPWL_FontMap::GetFontMapData(FX_INT32 nIndex) const 432 const CPWL_FontMap_Data* CPWL_FontMap::GetFontMapData(int32_t nIndex) const
433 { 433 {
434 if (nIndex >=0 && nIndex < m_aData.GetSize()) 434 if (nIndex >=0 && nIndex < m_aData.GetSize())
435 { 435 {
436 return m_aData.GetAt(nIndex); 436 return m_aData.GetAt(nIndex);
437 } 437 }
438 438
439 return NULL; 439 return NULL;
440 } 440 }
441 441
442 FX_INT32 CPWL_FontMap::GetNativeCharset() 442 int32_t CPWL_FontMap::GetNativeCharset()
443 { 443 {
444 » FX_BYTE nCharset = ANSI_CHARSET; 444 » uint8_t nCharset = ANSI_CHARSET;
445 » FX_INT32 iCodePage = FXSYS_GetACP(); 445 » int32_t iCodePage = FXSYS_GetACP();
446 switch (iCodePage) 446 switch (iCodePage)
447 { 447 {
448 case 932://Japan 448 case 932://Japan
449 nCharset = SHIFTJIS_CHARSET; 449 nCharset = SHIFTJIS_CHARSET;
450 break; 450 break;
451 case 936://Chinese (PRC, Singapore) 451 case 936://Chinese (PRC, Singapore)
452 nCharset = GB2312_CHARSET; 452 nCharset = GB2312_CHARSET;
453 break; 453 break;
454 case 950://Chinese (Taiwan; Hong Kong SAR, PRC) 454 case 950://Chinese (Taiwan; Hong Kong SAR, PRC)
455 nCharset = GB2312_CHARSET; 455 nCharset = GB2312_CHARSET;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 { RUSSIAN_CHARSET, "Arial" }, 506 { RUSSIAN_CHARSET, "Arial" },
507 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || _FXM_PLATFORM_ == _FXM_PLATFORM_AP PLE_ 507 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ || _FXM_PLATFORM_ == _FXM_PLATFORM_AP PLE_
508 { EASTEUROPE_CHARSET, "Arial" }, 508 { EASTEUROPE_CHARSET, "Arial" },
509 #else 509 #else
510 { EASTEUROPE_CHARSET, "Tahoma" }, 510 { EASTEUROPE_CHARSET, "Tahoma" },
511 #endif 511 #endif
512 { ARABIC_CHARSET, "Arial" }, 512 { ARABIC_CHARSET, "Arial" },
513 { -1, NULL } 513 { -1, NULL }
514 }; 514 };
515 515
516 CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(FX_INT32 nCharset) 516 CFX_ByteString CPWL_FontMap::GetDefaultFontByCharset(int32_t nCharset)
517 { 517 {
518 int i = 0; 518 int i = 0;
519 while (defaultTTFMap[i].charset != -1) { 519 while (defaultTTFMap[i].charset != -1) {
520 if (nCharset == defaultTTFMap[i].charset) 520 if (nCharset == defaultTTFMap[i].charset)
521 return defaultTTFMap[i].fontname; 521 return defaultTTFMap[i].fontname;
522 ++i; 522 ++i;
523 } 523 }
524 return ""; 524 return "";
525 } 525 }
526 526
527 FX_INT32 CPWL_FontMap::CharSetFromUnicode(FX_WORD word, FX_INT32 nOldCharset) 527 int32_t CPWL_FontMap::CharSetFromUnicode(FX_WORD word, int32_t nOldCharset)
528 { 528 {
529 if(m_pSystemHandler && (-1 != m_pSystemHandler->GetCharSet())) 529 if(m_pSystemHandler && (-1 != m_pSystemHandler->GetCharSet()))
530 return m_pSystemHandler->GetCharSet(); 530 return m_pSystemHandler->GetCharSet();
531 //to avoid CJK Font to show ASCII 531 //to avoid CJK Font to show ASCII
532 if (word < 0x7F) return ANSI_CHARSET; 532 if (word < 0x7F) return ANSI_CHARSET;
533 //follow the old charset 533 //follow the old charset
534 if (nOldCharset != DEFAULT_CHARSET) return nOldCharset; 534 if (nOldCharset != DEFAULT_CHARSET) return nOldCharset;
535 535
536 //find new charset 536 //find new charset
537 if ((word >= 0x4E00 && word <= 0x9FA5) || 537 if ((word >= 0x4E00 && word <= 0x9FA5) ||
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 } 592 }
593 593
594 CPWL_DocFontMap::~CPWL_DocFontMap() 594 CPWL_DocFontMap::~CPWL_DocFontMap()
595 { 595 {
596 } 596 }
597 597
598 CPDF_Document* CPWL_DocFontMap::GetDocument() 598 CPDF_Document* CPWL_DocFontMap::GetDocument()
599 { 599 {
600 return m_pAttachedDoc; 600 return m_pAttachedDoc;
601 } 601 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/pdfwindow/PWL_EditCtrl.cpp ('k') | fpdfsdk/src/pdfwindow/PWL_Icon.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698