John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 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. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Lei Zhang | b4e7f30 | 2015-11-06 15:52:32 -0800 | [diff] [blame] | 7 | #include "public/fpdf_sysfontinfo.h" |
| 8 | |
Dan Sinclair | 85c8e7f | 2016-11-21 13:50:32 -0500 | [diff] [blame] | 9 | #include <memory> |
| 10 | |
Dan Sinclair | f51a02a | 2017-04-19 12:46:53 -0400 | [diff] [blame] | 11 | #include "core/fxcrt/fx_codepage.h" |
Artem Strygin | 656eb84 | 2018-05-31 14:08:11 +0000 | [diff] [blame] | 12 | #include "core/fxge/cfx_font.h" |
dsinclair | 74a34fc | 2016-09-29 16:41:42 -0700 | [diff] [blame] | 13 | #include "core/fxge/cfx_fontmapper.h" |
Lei Zhang | 96d6b4d | 2018-01-11 14:31:41 +0000 | [diff] [blame] | 14 | #include "core/fxge/cfx_fontmgr.h" |
dsinclair | 74a34fc | 2016-09-29 16:41:42 -0700 | [diff] [blame] | 15 | #include "core/fxge/cfx_gemodule.h" |
| 16 | #include "core/fxge/fx_font.h" |
Dan Sinclair | f8af565 | 2018-03-06 18:56:33 +0000 | [diff] [blame] | 17 | #include "core/fxge/systemfontinfo_iface.h" |
Dan Sinclair | 00d47a6 | 2018-03-28 18:39:04 +0000 | [diff] [blame] | 18 | #include "fpdfsdk/cpdfsdk_helpers.h" |
Dan Sinclair | c411eb9 | 2017-07-25 09:39:30 -0400 | [diff] [blame] | 19 | #include "fpdfsdk/pwl/cpwl_font_map.h" |
Tom Sepez | fe91c6c | 2017-05-16 15:33:20 -0700 | [diff] [blame] | 20 | #include "third_party/base/ptr_util.h" |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 21 | |
Dan Sinclair | f51a02a | 2017-04-19 12:46:53 -0400 | [diff] [blame] | 22 | static_assert(FXFONT_ANSI_CHARSET == FX_CHARSET_ANSI, "Charset must match"); |
| 23 | static_assert(FXFONT_DEFAULT_CHARSET == FX_CHARSET_Default, |
| 24 | "Charset must match"); |
| 25 | static_assert(FXFONT_SYMBOL_CHARSET == FX_CHARSET_Symbol, "Charset must match"); |
| 26 | static_assert(FXFONT_SHIFTJIS_CHARSET == FX_CHARSET_ShiftJIS, |
| 27 | "Charset must match"); |
| 28 | static_assert(FXFONT_HANGEUL_CHARSET == FX_CHARSET_Hangul, |
| 29 | "Charset must match"); |
| 30 | static_assert(FXFONT_GB2312_CHARSET == FX_CHARSET_ChineseSimplified, |
| 31 | "Charset must match"); |
| 32 | static_assert(FXFONT_CHINESEBIG5_CHARSET == FX_CHARSET_ChineseTraditional, |
| 33 | "Charset must match"); |
Artem Strygin | 656eb84 | 2018-05-31 14:08:11 +0000 | [diff] [blame] | 34 | static_assert(sizeof(CFX_Font::CharsetFontMap) == sizeof(FPDF_CharsetFontMap), |
| 35 | "CFX_Font::CharsetFontMap should be same as FPDF_CharsetFontMap"); |
Dan Sinclair | f51a02a | 2017-04-19 12:46:53 -0400 | [diff] [blame] | 36 | |
Dan Sinclair | f8af565 | 2018-03-06 18:56:33 +0000 | [diff] [blame] | 37 | class CFX_ExternalFontInfo final : public SystemFontInfoIface { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 38 | public: |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 39 | explicit CFX_ExternalFontInfo(FPDF_SYSFONTINFO* pInfo) : m_pInfo(pInfo) {} |
thestig | 24508df | 2016-05-27 15:14:20 -0700 | [diff] [blame] | 40 | ~CFX_ExternalFontInfo() override { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 41 | if (m_pInfo->Release) |
| 42 | m_pInfo->Release(m_pInfo); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 43 | } |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 44 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 45 | bool EnumFontList(CFX_FontMapper* pMapper) override { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 46 | if (m_pInfo->EnumFonts) { |
| 47 | m_pInfo->EnumFonts(m_pInfo, pMapper); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 48 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 49 | } |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 50 | return false; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 51 | } |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 52 | |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 53 | void* MapFont(int weight, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 54 | bool bItalic, |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 55 | int charset, |
| 56 | int pitch_family, |
Nicolas Pena | 979e916 | 2017-11-07 16:32:20 +0000 | [diff] [blame] | 57 | const char* family) override { |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 58 | if (!m_pInfo->MapFont) |
| 59 | return nullptr; |
Nicolas Pena | 979e916 | 2017-11-07 16:32:20 +0000 | [diff] [blame] | 60 | |
| 61 | int iExact; |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 62 | return m_pInfo->MapFont(m_pInfo, weight, bItalic, charset, pitch_family, |
| 63 | family, &iExact); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 64 | } |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 65 | |
Dan Sinclair | 812e96c | 2017-03-13 16:43:37 -0400 | [diff] [blame] | 66 | void* GetFont(const char* family) override { |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 67 | if (!m_pInfo->GetFont) |
| 68 | return nullptr; |
| 69 | return m_pInfo->GetFont(m_pInfo, family); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 70 | } |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 71 | |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 72 | uint32_t GetFontData(void* hFont, |
| 73 | uint32_t table, |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 74 | uint8_t* buffer, |
tsepez | c3255f5 | 2016-03-25 14:52:27 -0700 | [diff] [blame] | 75 | uint32_t size) override { |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 76 | if (!m_pInfo->GetFontData) |
| 77 | return 0; |
| 78 | return m_pInfo->GetFontData(m_pInfo, hFont, table, buffer, size); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 79 | } |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 80 | |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 81 | bool GetFaceName(void* hFont, ByteString* name) override { |
Lei Zhang | 412e908 | 2015-12-14 18:34:00 -0800 | [diff] [blame] | 82 | if (!m_pInfo->GetFaceName) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 83 | return false; |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 84 | uint32_t size = m_pInfo->GetFaceName(m_pInfo, hFont, nullptr, 0); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 85 | if (size == 0) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 86 | return false; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 87 | char* buffer = FX_Alloc(char, size); |
| 88 | size = m_pInfo->GetFaceName(m_pInfo, hFont, buffer, size); |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 89 | *name = ByteString(buffer, size); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 90 | FX_Free(buffer); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 91 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 92 | } |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 93 | |
Tom Sepez | ec8ff7d | 2017-04-07 16:58:00 -0700 | [diff] [blame] | 94 | bool GetFontCharset(void* hFont, int* charset) override { |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 95 | if (!m_pInfo->GetFontCharset) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 96 | return false; |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 97 | |
Tom Sepez | ec8ff7d | 2017-04-07 16:58:00 -0700 | [diff] [blame] | 98 | *charset = m_pInfo->GetFontCharset(m_pInfo, hFont); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 99 | return true; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 100 | } |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 101 | |
Lei Zhang | 2b1a2d5 | 2015-08-14 22:16:22 -0700 | [diff] [blame] | 102 | void DeleteFont(void* hFont) override { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 103 | if (m_pInfo->DeleteFont) |
| 104 | m_pInfo->DeleteFont(m_pInfo, hFont); |
| 105 | } |
Tom Sepez | e5b59ca | 2015-01-09 11:46:17 -0800 | [diff] [blame] | 106 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 107 | private: |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 108 | FPDF_SYSFONTINFO* const m_pInfo; |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 111 | FPDF_EXPORT void FPDF_CALLCONV FPDF_AddInstalledFont(void* mapper, |
| 112 | const char* name, |
| 113 | int charset) { |
Nicolas Pena | 46abb66 | 2017-05-17 17:23:22 -0400 | [diff] [blame] | 114 | CFX_FontMapper* pMapper = static_cast<CFX_FontMapper*>(mapper); |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 115 | pMapper->AddInstalledFont(name, charset); |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 116 | } |
| 117 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 118 | FPDF_EXPORT void FPDF_CALLCONV |
| 119 | FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfoExt) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 120 | if (pFontInfoExt->version != 1) |
| 121 | return; |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 122 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 123 | CFX_GEModule::Get()->GetFontMgr()->SetSystemFontInfo( |
Tom Sepez | fe91c6c | 2017-05-16 15:33:20 -0700 | [diff] [blame] | 124 | pdfium::MakeUnique<CFX_ExternalFontInfo>(pFontInfoExt)); |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 125 | } |
| 126 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 127 | FPDF_EXPORT const FPDF_CharsetFontMap* FPDF_CALLCONV FPDF_GetDefaultTTFMap() { |
Artem Strygin | 656eb84 | 2018-05-31 14:08:11 +0000 | [diff] [blame] | 128 | return reinterpret_cast<const FPDF_CharsetFontMap*>(CFX_Font::defaultTTFMap); |
Tom Sepez | 2a0bb3b | 2015-05-12 12:37:14 -0700 | [diff] [blame] | 129 | } |
| 130 | |
Tom Sepez | 5586545 | 2018-08-27 20:18:04 +0000 | [diff] [blame] | 131 | struct FPDF_SYSFONTINFO_DEFAULT final : public FPDF_SYSFONTINFO { |
Dan Sinclair | f8af565 | 2018-03-06 18:56:33 +0000 | [diff] [blame] | 132 | UnownedPtr<SystemFontInfoIface> m_pFontInfo; |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 133 | }; |
| 134 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 135 | static void DefaultRelease(struct _FPDF_SYSFONTINFO* pThis) { |
thestig | 24508df | 2016-05-27 15:14:20 -0700 | [diff] [blame] | 136 | auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); |
Tom Sepez | d0409af | 2017-05-25 15:53:57 -0700 | [diff] [blame] | 137 | delete pDefault->m_pFontInfo.Release(); |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 140 | static void DefaultEnumFonts(struct _FPDF_SYSFONTINFO* pThis, void* pMapper) { |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 141 | auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); |
Tom Sepez | ea3a252 | 2018-04-26 18:33:58 +0000 | [diff] [blame] | 142 | pDefault->m_pFontInfo->EnumFontList(static_cast<CFX_FontMapper*>(pMapper)); |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 143 | } |
| 144 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 145 | static void* DefaultMapFont(struct _FPDF_SYSFONTINFO* pThis, |
| 146 | int weight, |
| 147 | int bItalic, |
| 148 | int charset, |
| 149 | int pitch_family, |
| 150 | const char* family, |
| 151 | int* bExact) { |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 152 | auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); |
tsepez | 95e5834 | 2016-10-28 11:34:42 -0700 | [diff] [blame] | 153 | return pDefault->m_pFontInfo->MapFont(weight, !!bItalic, charset, |
Nicolas Pena | 979e916 | 2017-11-07 16:32:20 +0000 | [diff] [blame] | 154 | pitch_family, family); |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 157 | void* DefaultGetFont(struct _FPDF_SYSFONTINFO* pThis, const char* family) { |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 158 | auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); |
| 159 | return pDefault->m_pFontInfo->GetFont(family); |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 160 | } |
| 161 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 162 | static unsigned long DefaultGetFontData(struct _FPDF_SYSFONTINFO* pThis, |
| 163 | void* hFont, |
| 164 | unsigned int table, |
| 165 | unsigned char* buffer, |
| 166 | unsigned long buf_size) { |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 167 | auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); |
| 168 | return pDefault->m_pFontInfo->GetFontData(hFont, table, buffer, buf_size); |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 171 | static unsigned long DefaultGetFaceName(struct _FPDF_SYSFONTINFO* pThis, |
| 172 | void* hFont, |
| 173 | char* buffer, |
| 174 | unsigned long buf_size) { |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 175 | ByteString name; |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 176 | auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); |
Tom Sepez | ec8ff7d | 2017-04-07 16:58:00 -0700 | [diff] [blame] | 177 | if (!pDefault->m_pFontInfo->GetFaceName(hFont, &name)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 178 | return 0; |
Ryan Harrison | 875e98c | 2017-09-27 10:53:11 -0400 | [diff] [blame] | 179 | if (name.GetLength() >= static_cast<size_t>(buf_size)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 180 | return name.GetLength() + 1; |
Dan Sinclair | 7e7c649 | 2017-04-03 14:50:05 -0400 | [diff] [blame] | 181 | |
| 182 | strncpy(buffer, name.c_str(), |
Ryan Harrison | 275e260 | 2017-09-18 14:23:18 -0400 | [diff] [blame] | 183 | (name.GetLength() + 1) * sizeof(ByteString::CharType)); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 184 | return name.GetLength() + 1; |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 187 | static int DefaultGetFontCharset(struct _FPDF_SYSFONTINFO* pThis, void* hFont) { |
| 188 | int charset; |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 189 | auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); |
Tom Sepez | ec8ff7d | 2017-04-07 16:58:00 -0700 | [diff] [blame] | 190 | if (!pDefault->m_pFontInfo->GetFontCharset(hFont, &charset)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 191 | return 0; |
| 192 | return charset; |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 193 | } |
| 194 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 195 | static void DefaultDeleteFont(struct _FPDF_SYSFONTINFO* pThis, void* hFont) { |
thestig | 907a522 | 2016-06-21 14:38:27 -0700 | [diff] [blame] | 196 | auto* pDefault = static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pThis); |
| 197 | pDefault->m_pFontInfo->DeleteFont(hFont); |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 198 | } |
| 199 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 200 | FPDF_EXPORT FPDF_SYSFONTINFO* FPDF_CALLCONV FPDF_GetDefaultSystemFontInfo() { |
Dan Sinclair | f8af565 | 2018-03-06 18:56:33 +0000 | [diff] [blame] | 201 | std::unique_ptr<SystemFontInfoIface> pFontInfo = |
| 202 | SystemFontInfoIface::CreateDefault(nullptr); |
Lei Zhang | 412e908 | 2015-12-14 18:34:00 -0800 | [diff] [blame] | 203 | if (!pFontInfo) |
thestig | 24508df | 2016-05-27 15:14:20 -0700 | [diff] [blame] | 204 | return nullptr; |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 205 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 206 | FPDF_SYSFONTINFO_DEFAULT* pFontInfoExt = |
| 207 | FX_Alloc(FPDF_SYSFONTINFO_DEFAULT, 1); |
| 208 | pFontInfoExt->DeleteFont = DefaultDeleteFont; |
| 209 | pFontInfoExt->EnumFonts = DefaultEnumFonts; |
| 210 | pFontInfoExt->GetFaceName = DefaultGetFaceName; |
| 211 | pFontInfoExt->GetFont = DefaultGetFont; |
| 212 | pFontInfoExt->GetFontCharset = DefaultGetFontCharset; |
| 213 | pFontInfoExt->GetFontData = DefaultGetFontData; |
| 214 | pFontInfoExt->MapFont = DefaultMapFont; |
| 215 | pFontInfoExt->Release = DefaultRelease; |
| 216 | pFontInfoExt->version = 1; |
thestig | 24508df | 2016-05-27 15:14:20 -0700 | [diff] [blame] | 217 | pFontInfoExt->m_pFontInfo = pFontInfo.release(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 218 | return pFontInfoExt; |
John Abd-El-Malek | 5110c47 | 2014-05-17 22:33:34 -0700 | [diff] [blame] | 219 | } |
npm | 788217d | 2016-11-08 16:48:36 -0800 | [diff] [blame] | 220 | |
Dan Sinclair | 00d2ad1 | 2017-08-10 14:13:02 -0400 | [diff] [blame] | 221 | FPDF_EXPORT void FPDF_CALLCONV |
Dan Sinclair | 4bb4e84 | 2017-07-18 09:58:58 -0400 | [diff] [blame] | 222 | FPDF_FreeDefaultSystemFontInfo(FPDF_SYSFONTINFO* pDefaultFontInfo) { |
npm | be6b148 | 2016-11-10 10:12:30 -0800 | [diff] [blame] | 223 | FX_Free(static_cast<FPDF_SYSFONTINFO_DEFAULT*>(pDefaultFontInfo)); |
npm | 788217d | 2016-11-08 16:48:36 -0800 | [diff] [blame] | 224 | } |