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/android/cfx_androidfontinfo.h" | 7 #include "core/fxge/android/cfx_androidfontinfo.h" |
8 | 8 |
9 #include "core/fxcrt/fx_system.h" | 9 #include "core/fxcrt/fx_system.h" |
10 #include "core/fxge/android/cfpf_skiafont.h" | 10 #include "core/fxge/android/cfpf_skiafont.h" |
11 #include "core/fxge/android/cfpf_skiafontmgr.h" | 11 #include "core/fxge/android/cfpf_skiafontmgr.h" |
12 #include "core/fxge/cfx_fontmapper.h" | 12 #include "core/fxge/cfx_fontmapper.h" |
13 | 13 |
14 CFX_AndroidFontInfo::CFX_AndroidFontInfo() : m_pFontMgr(nullptr) {} | 14 CFX_AndroidFontInfo::CFX_AndroidFontInfo() : m_pFontMgr(nullptr) {} |
15 CFX_AndroidFontInfo::~CFX_AndroidFontInfo() {} | 15 CFX_AndroidFontInfo::~CFX_AndroidFontInfo() {} |
16 FX_BOOL CFX_AndroidFontInfo::Init(CFPF_SkiaFontMgr* pFontMgr) { | 16 bool CFX_AndroidFontInfo::Init(CFPF_SkiaFontMgr* pFontMgr) { |
17 if (!pFontMgr) | 17 if (!pFontMgr) |
18 return FALSE; | 18 return false; |
19 | 19 |
20 pFontMgr->LoadSystemFonts(); | 20 pFontMgr->LoadSystemFonts(); |
21 m_pFontMgr = pFontMgr; | 21 m_pFontMgr = pFontMgr; |
22 return TRUE; | 22 return true; |
23 } | 23 } |
24 | 24 |
25 FX_BOOL CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper) { | 25 bool CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper) { |
26 return FALSE; | 26 return false; |
27 } | 27 } |
28 | 28 |
29 void* CFX_AndroidFontInfo::MapFont(int weight, | 29 void* CFX_AndroidFontInfo::MapFont(int weight, |
30 FX_BOOL bItalic, | 30 bool bItalic, |
31 int charset, | 31 int charset, |
32 int pitch_family, | 32 int pitch_family, |
33 const FX_CHAR* face, | 33 const FX_CHAR* face, |
34 int& iExact) { | 34 int& iExact) { |
35 if (!m_pFontMgr) | 35 if (!m_pFontMgr) |
36 return nullptr; | 36 return nullptr; |
37 | 37 |
38 uint32_t dwStyle = 0; | 38 uint32_t dwStyle = 0; |
39 if (weight >= 700) | 39 if (weight >= 700) |
40 dwStyle |= FXFONT_BOLD; | 40 dwStyle |= FXFONT_BOLD; |
(...skipping 15 matching lines...) Expand all Loading... |
56 | 56 |
57 uint32_t CFX_AndroidFontInfo::GetFontData(void* hFont, | 57 uint32_t CFX_AndroidFontInfo::GetFontData(void* hFont, |
58 uint32_t table, | 58 uint32_t table, |
59 uint8_t* buffer, | 59 uint8_t* buffer, |
60 uint32_t size) { | 60 uint32_t size) { |
61 if (!hFont) | 61 if (!hFont) |
62 return 0; | 62 return 0; |
63 return static_cast<CFPF_SkiaFont*>(hFont)->GetFontData(table, buffer, size); | 63 return static_cast<CFPF_SkiaFont*>(hFont)->GetFontData(table, buffer, size); |
64 } | 64 } |
65 | 65 |
66 FX_BOOL CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { | 66 bool CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { |
67 if (!hFont) | 67 if (!hFont) |
68 return FALSE; | 68 return false; |
69 | 69 |
70 name = static_cast<CFPF_SkiaFont*>(hFont)->GetFamilyName(); | 70 name = static_cast<CFPF_SkiaFont*>(hFont)->GetFamilyName(); |
71 return TRUE; | 71 return true; |
72 } | 72 } |
73 | 73 |
74 FX_BOOL CFX_AndroidFontInfo::GetFontCharset(void* hFont, int& charset) { | 74 bool CFX_AndroidFontInfo::GetFontCharset(void* hFont, int& charset) { |
75 if (!hFont) | 75 if (!hFont) |
76 return FALSE; | 76 return false; |
77 | 77 |
78 charset = static_cast<CFPF_SkiaFont*>(hFont)->GetCharset(); | 78 charset = static_cast<CFPF_SkiaFont*>(hFont)->GetCharset(); |
79 return FALSE; | 79 return false; |
80 } | 80 } |
81 | 81 |
82 void CFX_AndroidFontInfo::DeleteFont(void* hFont) { | 82 void CFX_AndroidFontInfo::DeleteFont(void* hFont) { |
83 if (!hFont) | 83 if (!hFont) |
84 return; | 84 return; |
85 | 85 |
86 static_cast<CFPF_SkiaFont*>(hFont)->Release(); | 86 static_cast<CFPF_SkiaFont*>(hFont)->Release(); |
87 } | 87 } |
OLD | NEW |