summaryrefslogtreecommitdiff
path: root/core/fxge/android/fx_android_font.cpp
blob: 6554c66a1374c43e01cb065e1c8de557bd023d26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#include "core/fxcrt/include/fx_system.h"

#if _FX_OS_ == _FX_ANDROID_

#include "core/fxge/android/fx_android_font.h"
#include "core/fxge/include/fpf.h"

CFX_AndroidFontInfo::CFX_AndroidFontInfo() : m_pFontMgr(NULL) {}
FX_BOOL CFX_AndroidFontInfo::Init(IFPF_FontMgr* pFontMgr) {
  if (!pFontMgr) {
    return FALSE;
  }
  pFontMgr->LoadSystemFonts();
  m_pFontMgr = pFontMgr;
  return TRUE;
}
FX_BOOL CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
  return FALSE;
}
void* CFX_AndroidFontInfo::MapFont(int weight,
                                   FX_BOOL bItalic,
                                   int charset,
                                   int pitch_family,
                                   const FX_CHAR* face,
                                   int& iExact) {
  if (!m_pFontMgr) {
    return NULL;
  }
  uint32_t dwStyle = 0;
  if (weight >= 700) {
    dwStyle |= FXFONT_BOLD;
  }
  if (bItalic) {
    dwStyle |= FXFONT_ITALIC;
  }
  if (pitch_family & FXFONT_FF_FIXEDPITCH) {
    dwStyle |= FXFONT_FIXED_PITCH;
  }
  if (pitch_family & FXFONT_FF_SCRIPT) {
    dwStyle |= FXFONT_SCRIPT;
  }
  if (pitch_family & FXFONT_FF_ROMAN) {
    dwStyle |= FXFONT_SERIF;
  }
  return m_pFontMgr->CreateFont(face, charset, dwStyle,
                                FPF_MATCHFONT_REPLACEANSI);
}
void* CFX_AndroidFontInfo::GetFont(const FX_CHAR* face) {
  return NULL;
}
uint32_t CFX_AndroidFontInfo::GetFontData(void* hFont,
                                          uint32_t table,
                                          uint8_t* buffer,
                                          uint32_t size) {
  if (!hFont) {
    return 0;
  }
  return ((IFPF_Font*)hFont)->GetFontData(table, buffer, size);
}
FX_BOOL CFX_AndroidFontInfo::GetFaceName(void* hFont, CFX_ByteString& name) {
  if (!hFont) {
    return FALSE;
  }
  name = ((IFPF_Font*)hFont)->GetFamilyName();
  return TRUE;
}
FX_BOOL CFX_AndroidFontInfo::GetFontCharset(void* hFont, int& charset) {
  if (!hFont) {
    return FALSE;
  }
  charset = ((IFPF_Font*)hFont)->GetCharset();
  return FALSE;
}
void CFX_AndroidFontInfo::DeleteFont(void* hFont) {
  if (!hFont) {
    return;
  }
  ((IFPF_Font*)hFont)->Release();
}
void* CFX_AndroidFontInfo::RetainFont(void* hFont) {
  return NULL;
}
#endif