7#include "core/fxge/apple/fx_apple_platform.h"
12#include "core/fxcrt/fx_codepage.h"
13#include "core/fxge/cfx_folderfontinfo.h"
14#include "core/fxge/cfx_fontmgr.h"
15#include "core/fxge/fx_font.h"
16#include "core/fxge/systemfontinfo_iface.h"
22 const char* m_pSubstName;
25constexpr Substs kBase14Substs[] = {
26 {
"Courier",
"Courier New"},
27 {
"Courier-Bold",
"Courier New Bold"},
28 {
"Courier-BoldOblique",
"Courier New Bold Italic"},
29 {
"Courier-Oblique",
"Courier New Italic"},
30 {
"Helvetica",
"Arial"},
31 {
"Helvetica-Bold",
"Arial Bold"},
32 {
"Helvetica-BoldOblique",
"Arial Bold Italic"},
33 {
"Helvetica-Oblique",
"Arial Italic"},
34 {
"Times-Roman",
"Times New Roman"},
35 {
"Times-Bold",
"Times New Roman Bold"},
36 {
"Times-BoldItalic",
"Times New Roman Bold Italic"},
37 {
"Times-Italic",
"Times New Roman Italic"},
42 CFX_MacFontInfo() =
default;
43 ~CFX_MacFontInfo()
override =
default;
46 void* MapFont(
int weight,
50 const ByteString& face)
override;
52 bool ParseFontCfg(
const char** pUserPaths);
55constexpr char kJapanGothic[] =
"Hiragino Kaku Gothic Pro W6";
56constexpr char kJapanMincho[] =
"Hiragino Mincho Pro W6";
58ByteString GetJapanesePreference(
const ByteString& face,
61 if (face.Contains(
"Gothic"))
68void* CFX_MacFontInfo::MapFont(
int weight,
72 const ByteString& face) {
73 for (
const auto& sub : kBase14Substs) {
74 if (face == ByteStringView(sub.m_pName))
75 return GetFont(sub.m_pSubstName);
85 if (!face.Contains(
"Bold") && !face.Contains(
"Italic")) {
86 ByteString new_face = face;
90 new_face
+= " Italic";
91 auto it = m_FontList.find(new_face);
92 if (it != m_FontList.end())
93 return it->second.get();
96 auto it = m_FontList.find(face);
97 if (it != m_FontList.end())
98 return it->second.get();
106 ByteString other_face;
109 other_face
= GetJapanesePreference(face, weight, pitch_family);
112 other_face
= "STSong";
115 other_face
= "AppleMyungjo";
118 other_face
= "LiSong Pro Light";
124 it = m_FontList.find(other_face);
125 return it != m_FontList.end() ? it->second.get() :
nullptr;
128bool CFX_MacFontInfo::ParseFontCfg(
const char** pUserPaths) {
132 for (
const char** pPath = pUserPaths; *pPath; ++pPath)
146 auto pInfo =
std::make_unique<CFX_MacFontInfo>();
148 pInfo->AddPath(
"~/Library/Fonts");
149 pInfo->AddPath(
"/Library/Fonts");
150 pInfo->AddPath(
"/System/Library/Fonts");
152 return std::move(pInfo);
156 pdfium::span<
const uint8_t> font_span) {
161std::unique_ptr<CFX_GEModule::PlatformIface>
163 return std::make_unique<CApplePlatform>();
void AddPath(const ByteString &path)
void * GetFont(const ByteString &face) override
static CFX_GEModule * Get()
const char ** GetUserFontPaths() const
void * CreateFont(pdfium::span< const uint8_t > pFontData)
ByteString & operator+=(const char *str)
ByteString & operator=(const char *str)
ByteString & operator=(const ByteString &that)
ByteString & operator=(ByteString &&that) noexcept
bool FontFamilyIsFixedPitch(uint32_t family)
bool FontFamilyIsRoman(uint32_t family)