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;
15 {"Courier", "Courier New"},
16 {"Courier-Bold", "Courier New Bold"},
17 {"Courier-BoldOblique", "Courier New Bold Italic"},
18 {"Courier-Oblique", "Courier New Italic"},
19 {"Helvetica", "Arial"},
20 {"Helvetica-Bold", "Arial Bold"},
21 {"Helvetica-BoldOblique", "Arial Bold Italic"},
22 {"Helvetica-Oblique", "Arial Italic"},
23 {"Times-Roman", "Times New Roman"},
24 {"Times-Bold", "Times New Roman Bold"},
25 {"Times-BoldItalic", "Times New Roman Bold Italic"},
26 {"Times-Italic", "Times New Roman Italic"},
28 class CFX_MacFontInfo : public CFX_FolderFontInfo
31 virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* family, FX_BOOL& bExact);
33 #define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6"
34 #define JAPAN_MINCHO "Hiragino Mincho Pro W6"
35 static void GetJapanesePreference(CFX_ByteString& face, int weight, int picth_family)
37 if (face.Find("Gothic") >= 0) {
41 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) {
47 void* CFX_MacFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* cstr_face, FX_BOOL& bExact)
49 CFX_ByteString face = cstr_face;
51 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++)
52 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) {
53 face = Base14Substs[iBaseFont].m_pSubstName;
61 if (m_FontList.Lookup(face, p)) {
64 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {
65 return GetFont("Courier New");
67 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) {
71 case FXFONT_SHIFTJIS_CHARSET:
72 GetJapanesePreference(face, weight, pitch_family);
74 case FXFONT_GB2312_CHARSET:
77 case FXFONT_HANGEUL_CHARSET:
78 face = "AppleMyungjo";
80 case FXFONT_CHINESEBIG5_CHARSET:
81 face = "LiSong Pro Light";
83 if (m_FontList.Lookup(face, p)) {
88 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault()
90 CFX_MacFontInfo* pInfo = new CFX_MacFontInfo;
91 pInfo->AddPath("~/Library/Fonts");
92 pInfo->AddPath("/Library/Fonts");
93 pInfo->AddPath("/System/Library/Fonts");
96 void CFX_GEModule::InitPlatform()
98 m_pPlatformData = new CApplePlatform;
99 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault());
101 void CFX_GEModule::DestroyPlatform()
103 delete (CApplePlatform *)m_pPlatformData;
104 m_pPlatformData = NULL;