1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "fx_fpf.h"
8 #if _FX_OS_ == _FX_ANDROID_
CFX_AndroidFontInfo()9 CFX_AndroidFontInfo::CFX_AndroidFontInfo() : m_pFontMgr(NULL) {}
Init(IFPF_FontMgr * pFontMgr)10 FX_BOOL CFX_AndroidFontInfo::Init(IFPF_FontMgr* pFontMgr) {
11 if (!pFontMgr) {
12 return FALSE;
13 }
14 pFontMgr->LoadSystemFonts();
15 m_pFontMgr = pFontMgr;
16 return TRUE;
17 }
EnumFontList(CFX_FontMapper * pMapper)18 FX_BOOL CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
19 return FALSE;
20 }
MapFont(int weight,FX_BOOL bItalic,int charset,int pitch_family,const FX_CHAR * face,int & iExact)21 void* CFX_AndroidFontInfo::MapFont(int weight,
22 FX_BOOL bItalic,
23 int charset,
24 int pitch_family,
25 const FX_CHAR* face,
26 int& iExact) {
27 if (!m_pFontMgr) {
28 return NULL;
29 }
30 FX_DWORD dwStyle = 0;
31 if (weight >= 700) {
32 dwStyle |= FXFONT_BOLD;
33 }
34 if (bItalic) {
35 dwStyle |= FXFONT_ITALIC;
36 }
37 if (pitch_family & FXFONT_FF_FIXEDPITCH) {
38 dwStyle |= FXFONT_FIXED_PITCH;
39 }
40 if (pitch_family & FXFONT_FF_SCRIPT) {
41 dwStyle |= FXFONT_SCRIPT;
42 }
43 if (pitch_family & FXFONT_FF_ROMAN) {
44 dwStyle |= FXFONT_SERIF;
45 }
46 return m_pFontMgr->CreateFont(face, charset, dwStyle,
47 FPF_MATCHFONT_REPLACEANSI);
48 }
GetFont(const FX_CHAR * face)49 void* CFX_AndroidFontInfo::GetFont(const FX_CHAR* face) {
50 return NULL;
51 }
GetFontData(void * hFont,FX_DWORD table,uint8_t * buffer,FX_DWORD size)52 FX_DWORD CFX_AndroidFontInfo::GetFontData(void* hFont,
53 FX_DWORD table,
54 uint8_t* buffer,
55 FX_DWORD size) {
56 if (!hFont) {
57 return 0;
58 }
59 return ((IFPF_Font*)hFont)->GetFontData(table, buffer, size);
60 }
GetFaceName(void * hFont,CFX_ByteString & name)61 FX_BOOL CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) {
62 if (!hFont) {
63 return FALSE;
64 }
65 name = ((IFPF_Font*)hFont)->GetFamilyName();
66 return TRUE;
67 }
GetFontCharset(void * hFont,int & charset)68 FX_BOOL CFX_AndroidFontInfo::GetFontCharset(void* hFont, int& charset) {
69 if (!hFont) {
70 return FALSE;
71 }
72 charset = ((IFPF_Font*)hFont)->GetCharset();
73 return FALSE;
74 }
DeleteFont(void * hFont)75 void CFX_AndroidFontInfo::DeleteFont(void* hFont) {
76 if (!hFont) {
77 return;
78 }
79 ((IFPF_Font*)hFont)->Release();
80 }
RetainFont(void * hFont)81 void* CFX_AndroidFontInfo::RetainFont(void* hFont) {
82 return NULL;
83 }
84 #endif
85