| 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 return pos; | 372 return pos; |
| 373 } | 373 } |
| 374 int CFX_Font::GetULthickness() { | 374 int CFX_Font::GetULthickness() { |
| 375 if (m_Face == NULL) { | 375 if (m_Face == NULL) { |
| 376 return 0; | 376 return 0; |
| 377 } | 377 } |
| 378 int thickness = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), | 378 int thickness = EM_ADJUST(FXFT_Get_Face_UnitsPerEM(m_Face), |
| 379 FXFT_Get_Face_UnderLineThickness(m_Face)); | 379 FXFT_Get_Face_UnderLineThickness(m_Face)); |
| 380 return thickness; | 380 return thickness; |
| 381 } | 381 } |
| 382 CFX_UnicodeEncoding::CFX_UnicodeEncoding(CFX_Font* pFont) { | 382 |
| 383 m_pFont = pFont; | 383 CFX_UnicodeEncoding::CFX_UnicodeEncoding(CFX_Font* pFont) : m_pFont(pFont) { |
| 384 } | 384 } |
| 385 |
| 386 CFX_UnicodeEncoding::~CFX_UnicodeEncoding() { |
| 387 } |
| 388 |
| 385 FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCode(FX_DWORD charcode) { | 389 FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCode(FX_DWORD charcode) { |
| 386 FXFT_Face face = m_pFont->GetFace(); | 390 FXFT_Face face = m_pFont->GetFace(); |
| 387 if (!face) { | 391 if (!face) |
| 388 return charcode; | 392 return charcode; |
| 389 } | 393 |
| 390 if (FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE) == 0) { | 394 if (FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE) == 0) |
| 391 return FXFT_Get_Char_Index(face, charcode); | 395 return FXFT_Get_Char_Index(face, charcode); |
| 392 } | 396 |
| 393 if (m_pFont->m_pSubstFont && m_pFont->m_pSubstFont->m_Charset == 2) { | 397 if (m_pFont->m_pSubstFont && m_pFont->m_pSubstFont->m_Charset == 2) { |
| 394 FX_DWORD index = 0; | 398 FX_DWORD index = 0; |
| 395 if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0) { | 399 if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0) |
| 396 index = FXFT_Get_Char_Index(face, charcode); | 400 index = FXFT_Get_Char_Index(face, charcode); |
| 397 } | 401 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) |
| 398 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) { | |
| 399 return FXFT_Get_Char_Index(face, charcode); | 402 return FXFT_Get_Char_Index(face, charcode); |
| 400 } | |
| 401 } | 403 } |
| 402 return charcode; | 404 return charcode; |
| 403 } | 405 } |
| 404 FX_DWORD CFX_UnicodeEncoding::GlyphFromCharCodeEx(FX_DWORD charcode, | |
| 405 int encoding) { | |
| 406 FXFT_Face face = m_pFont->GetFace(); | |
| 407 if (!face) { | |
| 408 return charcode; | |
| 409 } | |
| 410 if (encoding == ENCODING_UNICODE) { | |
| 411 return GlyphFromCharCode(charcode); | |
| 412 } | |
| 413 int nmaps = FXFT_Get_Face_CharmapCount(m_pFont->m_Face); | |
| 414 int i = 0; | |
| 415 while (i < nmaps) { | |
| 416 int encoding = FXFT_Get_Charmap_Encoding(FXFT_Get_Face_Charmaps(face)[i++]); | |
| 417 if (encoding != FXFT_ENCODING_UNICODE) { | |
| 418 FXFT_Select_Charmap(face, encoding); | |
| 419 break; | |
| 420 } | |
| 421 } | |
| 422 return FXFT_Get_Char_Index(face, charcode); | |
| 423 } | |
| 424 IFX_FontEncoding* FXGE_CreateUnicodeEncoding(CFX_Font* pFont) { | |
| 425 return new CFX_UnicodeEncoding(pFont); | |
| 426 } | |
| OLD | NEW |