OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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 "core/fxge/include/cfx_unicodeencoding.h" | 7 #include "core/fxge/cfx_unicodeencoding.h" |
8 | 8 |
9 #include "core/fxge/include/fx_font.h" | 9 #include "core/fxge/fx_font.h" |
10 #include "core/fxge/include/fx_freetype.h" | 10 #include "core/fxge/fx_freetype.h" |
11 | 11 |
12 CFX_UnicodeEncoding::CFX_UnicodeEncoding(CFX_Font* pFont) : m_pFont(pFont) {} | 12 CFX_UnicodeEncoding::CFX_UnicodeEncoding(CFX_Font* pFont) : m_pFont(pFont) {} |
13 | 13 |
14 CFX_UnicodeEncoding::~CFX_UnicodeEncoding() {} | 14 CFX_UnicodeEncoding::~CFX_UnicodeEncoding() {} |
15 | 15 |
16 uint32_t CFX_UnicodeEncoding::GlyphFromCharCode(uint32_t charcode) { | 16 uint32_t CFX_UnicodeEncoding::GlyphFromCharCode(uint32_t charcode) { |
17 FXFT_Face face = m_pFont->GetFace(); | 17 FXFT_Face face = m_pFont->GetFace(); |
18 if (!face) | 18 if (!face) |
19 return charcode; | 19 return charcode; |
20 | 20 |
21 if (FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE) == 0) | 21 if (FXFT_Select_Charmap(face, FXFT_ENCODING_UNICODE) == 0) |
22 return FXFT_Get_Char_Index(face, charcode); | 22 return FXFT_Get_Char_Index(face, charcode); |
23 | 23 |
24 if (m_pFont->GetSubstFont() && | 24 if (m_pFont->GetSubstFont() && |
25 m_pFont->GetSubstFont()->m_Charset == FXFONT_SYMBOL_CHARSET) { | 25 m_pFont->GetSubstFont()->m_Charset == FXFONT_SYMBOL_CHARSET) { |
26 uint32_t index = 0; | 26 uint32_t index = 0; |
27 if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0) | 27 if (FXFT_Select_Charmap(face, FXFT_ENCODING_MS_SYMBOL) == 0) |
28 index = FXFT_Get_Char_Index(face, charcode); | 28 index = FXFT_Get_Char_Index(face, charcode); |
29 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) | 29 if (!index && !FXFT_Select_Charmap(face, FXFT_ENCODING_APPLE_ROMAN)) |
30 return FXFT_Get_Char_Index(face, charcode); | 30 return FXFT_Get_Char_Index(face, charcode); |
31 } | 31 } |
32 return charcode; | 32 return charcode; |
33 } | 33 } |
OLD | NEW |