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 "core/fxcrt/include/fx_system.h" | 7 #include "core/fxcrt/include/fx_system.h" |
8 | 8 |
9 #if _FX_OS_ == _FX_ANDROID_ | 9 #if _FX_OS_ == _FX_ANDROID_ |
10 | 10 |
| 11 #include "core/fxge/android/fpf_skiafont.h" |
| 12 #include "core/fxge/android/fpf_skiafontmgr.h" |
11 #include "core/fxge/android/fx_android_font.h" | 13 #include "core/fxge/android/fx_android_font.h" |
12 #include "core/fxge/include/fpf.h" | |
13 | 14 |
14 CFX_AndroidFontInfo::CFX_AndroidFontInfo() : m_pFontMgr(NULL) {} | 15 CFX_AndroidFontInfo::CFX_AndroidFontInfo() : m_pFontMgr(NULL) {} |
15 FX_BOOL CFX_AndroidFontInfo::Init(IFPF_FontMgr* pFontMgr) { | 16 FX_BOOL CFX_AndroidFontInfo::Init(CFPF_SkiaFontMgr* pFontMgr) { |
16 if (!pFontMgr) { | 17 if (!pFontMgr) |
17 return FALSE; | 18 return FALSE; |
18 } | 19 |
19 pFontMgr->LoadSystemFonts(); | 20 pFontMgr->LoadSystemFonts(); |
20 m_pFontMgr = pFontMgr; | 21 m_pFontMgr = pFontMgr; |
21 return TRUE; | 22 return TRUE; |
22 } | 23 } |
| 24 |
23 FX_BOOL CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper) { | 25 FX_BOOL CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper) { |
24 return FALSE; | 26 return FALSE; |
25 } | 27 } |
| 28 |
26 void* CFX_AndroidFontInfo::MapFont(int weight, | 29 void* CFX_AndroidFontInfo::MapFont(int weight, |
27 FX_BOOL bItalic, | 30 FX_BOOL bItalic, |
28 int charset, | 31 int charset, |
29 int pitch_family, | 32 int pitch_family, |
30 const FX_CHAR* face, | 33 const FX_CHAR* face, |
31 int& iExact) { | 34 int& iExact) { |
32 if (!m_pFontMgr) { | 35 if (!m_pFontMgr) |
33 return NULL; | 36 return nullptr; |
34 } | 37 |
35 uint32_t dwStyle = 0; | 38 uint32_t dwStyle = 0; |
36 if (weight >= 700) { | 39 if (weight >= 700) |
37 dwStyle |= FXFONT_BOLD; | 40 dwStyle |= FXFONT_BOLD; |
38 } | 41 if (bItalic) |
39 if (bItalic) { | |
40 dwStyle |= FXFONT_ITALIC; | 42 dwStyle |= FXFONT_ITALIC; |
41 } | 43 if (pitch_family & FXFONT_FF_FIXEDPITCH) |
42 if (pitch_family & FXFONT_FF_FIXEDPITCH) { | |
43 dwStyle |= FXFONT_FIXED_PITCH; | 44 dwStyle |= FXFONT_FIXED_PITCH; |
44 } | 45 if (pitch_family & FXFONT_FF_SCRIPT) |
45 if (pitch_family & FXFONT_FF_SCRIPT) { | |
46 dwStyle |= FXFONT_SCRIPT; | 46 dwStyle |= FXFONT_SCRIPT; |
47 } | 47 if (pitch_family & FXFONT_FF_ROMAN) |
48 if (pitch_family & FXFONT_FF_ROMAN) { | |
49 dwStyle |= FXFONT_SERIF; | 48 dwStyle |= FXFONT_SERIF; |
50 } | |
51 return m_pFontMgr->CreateFont(face, charset, dwStyle, | 49 return m_pFontMgr->CreateFont(face, charset, dwStyle, |
52 FPF_MATCHFONT_REPLACEANSI); | 50 FPF_MATCHFONT_REPLACEANSI); |
53 } | 51 } |
| 52 |
54 void* CFX_AndroidFontInfo::GetFont(const FX_CHAR* face) { | 53 void* CFX_AndroidFontInfo::GetFont(const FX_CHAR* face) { |
55 return NULL; | 54 return nullptr; |
56 } | 55 } |
| 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 } | 63 return static_cast<CFPF_SkiaFont*>(hFont)->GetFontData(table, buffer, size); |
64 return ((IFPF_Font*)hFont)->GetFontData(table, buffer, size); | |
65 } | 64 } |
| 65 |
66 FX_BOOL CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { | 66 FX_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 = ((IFPF_Font*)hFont)->GetFamilyName(); | 70 name = static_cast<CFPF_SkiaFont*>(hFont)->GetFamilyName(); |
71 return TRUE; | 71 return TRUE; |
72 } | 72 } |
| 73 |
73 FX_BOOL CFX_AndroidFontInfo::GetFontCharset(void* hFont, int& charset) { | 74 FX_BOOL CFX_AndroidFontInfo::GetFontCharset(void* hFont, int& charset) { |
74 if (!hFont) { | 75 if (!hFont) |
75 return FALSE; | 76 return FALSE; |
76 } | 77 |
77 charset = ((IFPF_Font*)hFont)->GetCharset(); | 78 charset = static_cast<CFPF_SkiaFont*>(hFont)->GetCharset(); |
78 return FALSE; | 79 return FALSE; |
79 } | 80 } |
| 81 |
80 void CFX_AndroidFontInfo::DeleteFont(void* hFont) { | 82 void CFX_AndroidFontInfo::DeleteFont(void* hFont) { |
81 if (!hFont) { | 83 if (!hFont) |
82 return; | 84 return; |
83 } | 85 |
84 ((IFPF_Font*)hFont)->Release(); | 86 static_cast<CFPF_SkiaFont*>(hFont)->Release(); |
85 } | 87 } |
| 88 |
86 void* CFX_AndroidFontInfo::RetainFont(void* hFont) { | 89 void* CFX_AndroidFontInfo::RetainFont(void* hFont) { |
87 return NULL; | 90 return nullptr; |
88 } | 91 } |
89 #endif | 92 |
| 93 #endif // _FX_OS_ == _FX_ANDROID_ |
OLD | NEW |