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 "../../../include/fxge/fx_freetype.h" | 8 #include "../../../include/fxge/fx_freetype.h" |
9 #include "text_int.h" | 9 #include "text_int.h" |
10 #define EM_ADJUST(em, a) (em == 0?(a): (a)*1000/em) | 10 #define EM_ADJUST(em, a) (em == 0?(a): (a)*1000/em) |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 } | 302 } |
303 return psName; | 303 return psName; |
304 } | 304 } |
305 CFX_ByteString CFX_Font::GetFamilyName() const | 305 CFX_ByteString CFX_Font::GetFamilyName() const |
306 { | 306 { |
307 if (m_Face == NULL && m_pSubstFont == NULL) { | 307 if (m_Face == NULL && m_pSubstFont == NULL) { |
308 return CFX_ByteString(); | 308 return CFX_ByteString(); |
309 } | 309 } |
310 if (m_Face) { | 310 if (m_Face) { |
311 return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face)); | 311 return CFX_ByteString(FXFT_Get_Face_Family_Name(m_Face)); |
312 } else { | |
313 return m_pSubstFont->m_Family; | |
314 } | 312 } |
| 313 return m_pSubstFont->m_Family; |
315 } | 314 } |
316 CFX_ByteString CFX_Font::GetFaceName() const | 315 CFX_ByteString CFX_Font::GetFaceName() const |
317 { | 316 { |
318 if (m_Face == NULL && m_pSubstFont == NULL) { | 317 if (m_Face == NULL && m_pSubstFont == NULL) { |
319 return CFX_ByteString(); | 318 return CFX_ByteString(); |
320 } | 319 } |
321 if (m_Face) { | 320 if (m_Face) { |
322 CFX_ByteString facename; | 321 CFX_ByteString facename; |
323 CFX_ByteString style = CFX_ByteString(FXFT_Get_Face_Style_Name(m_Face)); | 322 CFX_ByteString style = CFX_ByteString(FXFT_Get_Face_Style_Name(m_Face)); |
324 facename = GetFamilyName(); | 323 facename = GetFamilyName(); |
325 if (facename.IsEmpty()) { | 324 if (facename.IsEmpty()) { |
326 facename = "Untitled"; | 325 facename = "Untitled"; |
327 } | 326 } |
328 if (!style.IsEmpty() && style != "Regular") { | 327 if (!style.IsEmpty() && style != "Regular") { |
329 facename += " " + style; | 328 facename += " " + style; |
330 } | 329 } |
331 return facename; | 330 return facename; |
332 } else { | |
333 return m_pSubstFont->m_Family; | |
334 } | 331 } |
| 332 return m_pSubstFont->m_Family; |
335 } | 333 } |
336 FX_BOOL CFX_Font::GetBBox(FX_RECT &bbox) | 334 FX_BOOL CFX_Font::GetBBox(FX_RECT &bbox) |
337 { | 335 { |
338 if (m_Face == NULL) { | 336 if (m_Face == NULL) { |
339 return FALSE; | 337 return FALSE; |
340 } | 338 } |
341 int em = FXFT_Get_Face_UnitsPerEM(m_Face); | 339 int em = FXFT_Get_Face_UnitsPerEM(m_Face); |
342 if (em == 0) { | 340 if (em == 0) { |
343 bbox.left = FXFT_Get_Face_xMin(m_Face); | 341 bbox.left = FXFT_Get_Face_xMin(m_Face); |
344 bbox.bottom = FXFT_Get_Face_yMax(m_Face); | 342 bbox.bottom = FXFT_Get_Face_yMax(m_Face); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 index = FXFT_Get_Char_Index(face, charcode); | 401 index = FXFT_Get_Char_Index(face, charcode); |
404 } | 402 } |
405 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) { | 403 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) { |
406 return FXFT_Get_Char_Index(face, charcode); | 404 return FXFT_Get_Char_Index(face, charcode); |
407 } | 405 } |
408 } | 406 } |
409 return charcode; | 407 return charcode; |
410 } | 408 } |
411 FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCodeEx(FX_DWORD charcode, int encodin
g) | 409 FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCodeEx(FX_DWORD charcode, int encodin
g) |
412 { | 410 { |
413 FXFT_Face face = m_pFont->GetFace(); | 411 FXFT_Face face = m_pFont->GetFace(); |
414 if (!face) { | 412 if (!face) { |
415 return charcode; | 413 return charcode; |
416 } | 414 } |
417 if (encoding == ENCODING_UNICODE) { | 415 if (encoding == ENCODING_UNICODE) { |
418 return» GlyphFromCharCode(charcode); | 416 return GlyphFromCharCode(charcode); |
419 } else { | 417 } |
420 int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face); | 418 int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face); |
421 int i = 0; | 419 int i = 0; |
422 while (i < nmaps) { | 420 while (i < nmaps) { |
423 int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face
)[i++]); | 421 int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i+
+]); |
424 if (encoding != FXFT_ENCODING_UNICODE) { | 422 if (encoding != FXFT_ENCODING_UNICODE) { |
425 FXFT_Select_Charmap(face, encoding); | 423 FXFT_Select_Charmap(face, encoding); |
426 break; | 424 break; |
427 } | |
428 } | 425 } |
429 } | 426 } |
430 return FXFT_Get_Char_Index(face, charcode); | 427 return FXFT_Get_Char_Index(face, charcode); |
431 } | 428 } |
432 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont) | 429 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont) |
433 { | 430 { |
434 return new CFX_UnicodeEncoding(pFont); | 431 return new CFX_UnicodeEncoding(pFont); |
435 } | 432 } |
OLD | NEW |