1 // Copyright 2014 PDFium Authors. All rights reserved.
\r
2 // Use of this source code is governed by a BSD-style license that can be
\r
3 // found in the LICENSE file.
\r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
\r
7 #include "../../../include/fxge/fx_ge.h"
\r
8 #include "apple_int.h"
\r
9 #if _FX_OS_ == _FX_MACOSX_
\r
10 static const struct {
\r
12 FX_LPCSTR m_pSubstName;
\r
15 {"Courier", "Courier New"},
\r
16 {"Courier-Bold", "Courier New Bold"},
\r
17 {"Courier-BoldOblique", "Courier New Bold Italic"},
\r
18 {"Courier-Oblique", "Courier New Italic"},
\r
19 {"Helvetica", "Arial"},
\r
20 {"Helvetica-Bold", "Arial Bold"},
\r
21 {"Helvetica-BoldOblique", "Arial Bold Italic"},
\r
22 {"Helvetica-Oblique", "Arial Italic"},
\r
23 {"Times-Roman", "Times New Roman"},
\r
24 {"Times-Bold", "Times New Roman Bold"},
\r
25 {"Times-BoldItalic", "Times New Roman Bold Italic"},
\r
26 {"Times-Italic", "Times New Roman Italic"},
\r
28 #if !defined(_FPDFAPI_MINI_)
\r
29 class CFX_MacFontInfo : public CFX_FolderFontInfo
\r
32 virtual void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR family, FX_BOOL& bExact);
\r
34 #define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6"
\r
35 #define JAPAN_MINCHO "Hiragino Mincho Pro W6"
\r
36 static void GetJapanesePreference(CFX_ByteString& face, int weight, int picth_family)
\r
38 if (face.Find("Gothic") >= 0) {
\r
39 face = JAPAN_GOTHIC;
\r
42 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) {
\r
43 face = JAPAN_GOTHIC;
\r
45 face = JAPAN_MINCHO;
\r
48 void* CFX_MacFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR cstr_face, FX_BOOL& bExact)
\r
50 CFX_ByteString face = cstr_face;
\r
52 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++)
\r
53 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) {
\r
54 face = Base14Substs[iBaseFont].m_pSubstName;
\r
58 if (iBaseFont < 12) {
\r
59 return GetFont(face);
\r
62 if (m_FontList.Lookup(face, p)) {
\r
65 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {
\r
66 return GetFont("Courier New");
\r
68 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) {
\r
72 case FXFONT_SHIFTJIS_CHARSET:
\r
73 GetJapanesePreference(face, weight, pitch_family);
\r
75 case FXFONT_GB2312_CHARSET:
\r
78 case FXFONT_HANGEUL_CHARSET:
\r
79 face = "AppleMyungjo";
\r
81 case FXFONT_CHINESEBIG5_CHARSET:
\r
82 face = "LiSong Pro Light";
\r
84 if (m_FontList.Lookup(face, p)) {
\r
90 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault()
\r
92 #if !defined(_FPDFAPI_MINI_)
\r
93 CFX_MacFontInfo* pInfo = FX_NEW CFX_MacFontInfo;
\r
97 pInfo->AddPath("~/Library/Fonts");
\r
98 pInfo->AddPath("/Library/Fonts");
\r
99 pInfo->AddPath("/System/Library/Fonts");
\r
105 void CFX_GEModule::InitPlatform()
\r
107 m_pPlatformData = FX_NEW CApplePlatform;
\r
108 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault());
\r
110 void CFX_GEModule::DestroyPlatform()
\r
112 if (m_pPlatformData) {
\r
113 delete (CApplePlatform *) m_pPlatformData;
\r
115 m_pPlatformData = NULL;
\r