Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfx_androidfontinfo.cpp
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
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 "core/fxge/android/cfx_androidfontinfo.h"
8
9#include "core/fxcrt/fx_system.h"
10#include "core/fxge/android/cfpf_skiafont.h"
11#include "core/fxge/android/cfpf_skiafontmgr.h"
12#include "core/fxge/cfx_fontmapper.h"
13#include "core/fxge/fx_font.h"
14
15CFX_AndroidFontInfo::CFX_AndroidFontInfo() = default;
16
17CFX_AndroidFontInfo::~CFX_AndroidFontInfo() = default;
18
19bool CFX_AndroidFontInfo::Init(CFPF_SkiaFontMgr* pFontMgr) {
20 if (!pFontMgr)
21 return false;
22
23 pFontMgr->LoadSystemFonts();
24 m_pFontMgr = pFontMgr;
25 return true;
26}
27
28bool CFX_AndroidFontInfo::EnumFontList(CFX_FontMapper* pMapper) {
29 return false;
30}
31
32void* CFX_AndroidFontInfo::MapFont(int weight,
33 bool bItalic,
34 FX_Charset charset,
35 int pitch_family,
36 const ByteString& face) {
37 if (!m_pFontMgr)
38 return nullptr;
39
40 uint32_t dwStyle = 0;
41 if (weight >= 700)
42 dwStyle |= FXFONT_FORCE_BOLD;
43 if (bItalic)
44 dwStyle |= FXFONT_ITALIC;
45 if (FontFamilyIsFixedPitch(pitch_family))
46 dwStyle |= FXFONT_FIXED_PITCH;
47 if (FontFamilyIsScript(pitch_family))
48 dwStyle |= FXFONT_SCRIPT;
49 if (FontFamilyIsRoman(pitch_family))
50 dwStyle |= FXFONT_SERIF;
51 return m_pFontMgr->CreateFont(face.AsStringView(), charset, dwStyle);
52}
53
54void* CFX_AndroidFontInfo::GetFont(const ByteString& face) {
55 return nullptr;
56}
57
58size_t CFX_AndroidFontInfo::GetFontData(void* hFont,
59 uint32_t table,
60 pdfium::span<uint8_t> buffer) {
61 if (!hFont)
62 return 0;
63 return static_cast<CFPF_SkiaFont*>(hFont)->GetFontData(table, buffer);
64}
65
66bool CFX_AndroidFontInfo::GetFaceName(void* hFont, ByteString* name) {
67 if (!hFont)
68 return false;
69
70 *name = static_cast<CFPF_SkiaFont*>(hFont)->GetFamilyName();
71 return true;
72}
73
74bool CFX_AndroidFontInfo::GetFontCharset(void* hFont, FX_Charset* charset) {
75 if (!hFont)
76 return false;
77
78 *charset = static_cast<CFPF_SkiaFont*>(hFont)->GetCharset();
79 return false;
80}
81
82void CFX_AndroidFontInfo::DeleteFont(void* hFont) {}
FX_Charset GetCharset() const
ByteString GetFamilyName()
uint32_t GetFontData(uint32_t dwTable, pdfium::span< uint8_t > pBuffer)
void * MapFont(int weight, bool bItalic, FX_Charset charset, int pitch_family, const ByteString &face) override
bool GetFontCharset(void *hFont, FX_Charset *charset) override
~CFX_AndroidFontInfo() override
void DeleteFont(void *hFont) override
bool GetFaceName(void *hFont, ByteString *name) override
bool Init(CFPF_SkiaFontMgr *pFontMgr)
size_t GetFontData(void *hFont, uint32_t table, pdfium::span< uint8_t > buffer) override
void * GetFont(const ByteString &face) override
bool EnumFontList(CFX_FontMapper *pMapper) override
ByteString & operator=(ByteString &&that) noexcept
FX_Charset
Definition fx_codepage.h:70
bool FontFamilyIsFixedPitch(uint32_t family)
Definition fx_font.h:84
#define FXFONT_SERIF
Definition fx_font.h:29
bool FontFamilyIsScript(int32_t family)
Definition fx_font.h:90
#define FXFONT_ITALIC
Definition fx_font.h:33
bool FontFamilyIsRoman(uint32_t family)
Definition fx_font.h:87
#define FXFONT_SCRIPT
Definition fx_font.h:31
#define FXFONT_FORCE_BOLD
Definition fx_font.h:36
#define FXFONT_FIXED_PITCH
Definition fx_font.h:28