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.
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
7 #include "../../../include/fxge/fx_ge.h"
9 #if _FX_OS_ == _FX_MACOSX_
11 const FX_CHAR* m_pName;
12 const FX_CHAR* m_pSubstName;
14 {"Courier", "Courier New"},
15 {"Courier-Bold", "Courier New Bold"},
16 {"Courier-BoldOblique", "Courier New Bold Italic"},
17 {"Courier-Oblique", "Courier New Italic"},
18 {"Helvetica", "Arial"},
19 {"Helvetica-Bold", "Arial Bold"},
20 {"Helvetica-BoldOblique", "Arial Bold Italic"},
21 {"Helvetica-Oblique", "Arial Italic"},
22 {"Times-Roman", "Times New Roman"},
23 {"Times-Bold", "Times New Roman Bold"},
24 {"Times-BoldItalic", "Times New Roman Bold Italic"},
25 {"Times-Italic", "Times New Roman Italic"},
27 class CFX_MacFontInfo : public CFX_FolderFontInfo {
29 virtual void* MapFont(int weight,
33 const FX_CHAR* family,
36 #define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6"
37 #define JAPAN_MINCHO "Hiragino Mincho Pro W6"
38 static void GetJapanesePreference(CFX_ByteString& face,
41 if (face.Find("Gothic") >= 0) {
45 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) {
51 void* CFX_MacFontInfo::MapFont(int weight,
55 const FX_CHAR* cstr_face,
57 CFX_ByteString face = cstr_face;
59 for (iBaseFont = 0; iBaseFont < 12; iBaseFont++)
60 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) {
61 face = Base14Substs[iBaseFont].m_pSubstName;
68 auto it = m_FontList.find(face);
69 if (it != m_FontList.end)
72 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {
73 return GetFont("Courier New");
75 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) {
79 case FXFONT_SHIFTJIS_CHARSET:
80 GetJapanesePreference(face, weight, pitch_family);
82 case FXFONT_GB2312_CHARSET:
85 case FXFONT_HANGEUL_CHARSET:
86 face = "AppleMyungjo";
88 case FXFONT_CHINESEBIG5_CHARSET:
89 face = "LiSong Pro Light";
91 it = m_FontList.Lookup(face);
92 if (it != m_FontList.end)
97 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault(const char** pUnused) {
98 CFX_MacFontInfo* pInfo = new CFX_MacFontInfo;
99 pInfo->AddPath("~/Library/Fonts");
100 pInfo->AddPath("/Library/Fonts");
101 pInfo->AddPath("/System/Library/Fonts");
104 void CFX_GEModule::InitPlatform() {
105 m_pPlatformData = new CApplePlatform;
106 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault(nullptr));
108 void CFX_GEModule::DestroyPlatform() {
109 delete (CApplePlatform*)m_pPlatformData;
110 m_pPlatformData = NULL;