OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fxge/apple/apple_int.h" | 7 #include "core/fxge/apple/apple_int.h" |
8 #include "core/fxge/include/fx_ge.h" | 8 #include "core/fxge/include/fx_ge.h" |
9 | 9 |
10 #if _FX_OS_ == _FX_MACOSX_ | 10 #if _FX_OS_ == _FX_MACOSX_ |
(...skipping 10 matching lines...) Expand all Loading... |
21 {"Helvetica-BoldOblique", "Arial Bold Italic"}, | 21 {"Helvetica-BoldOblique", "Arial Bold Italic"}, |
22 {"Helvetica-Oblique", "Arial Italic"}, | 22 {"Helvetica-Oblique", "Arial Italic"}, |
23 {"Times-Roman", "Times New Roman"}, | 23 {"Times-Roman", "Times New Roman"}, |
24 {"Times-Bold", "Times New Roman Bold"}, | 24 {"Times-Bold", "Times New Roman Bold"}, |
25 {"Times-BoldItalic", "Times New Roman Bold Italic"}, | 25 {"Times-BoldItalic", "Times New Roman Bold Italic"}, |
26 {"Times-Italic", "Times New Roman Italic"}, | 26 {"Times-Italic", "Times New Roman Italic"}, |
27 }; | 27 }; |
28 | 28 |
29 class CFX_MacFontInfo : public CFX_FolderFontInfo { | 29 class CFX_MacFontInfo : public CFX_FolderFontInfo { |
30 public: | 30 public: |
| 31 CFX_MacFontInfo() {} |
| 32 ~CFX_MacFontInfo() override {} |
| 33 |
31 // CFX_FolderFontInfo | 34 // CFX_FolderFontInfo |
32 void* MapFont(int weight, | 35 void* MapFont(int weight, |
33 FX_BOOL bItalic, | 36 FX_BOOL bItalic, |
34 int charset, | 37 int charset, |
35 int pitch_family, | 38 int pitch_family, |
36 const FX_CHAR* family, | 39 const FX_CHAR* family, |
37 int& iExact) override; | 40 int& iExact) override; |
38 }; | 41 }; |
39 | 42 |
40 #define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6" | 43 #define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6" |
41 #define JAPAN_MINCHO "Hiragino Mincho Pro W6" | 44 #define JAPAN_MINCHO "Hiragino Mincho Pro W6" |
42 static void GetJapanesePreference(CFX_ByteString& face, | 45 static void GetJapanesePreference(CFX_ByteString& face, |
43 int weight, | 46 int weight, |
44 int picth_family) { | 47 int pitch_family) { |
45 if (face.Find("Gothic") >= 0) { | 48 if (face.Find("Gothic") >= 0) { |
46 face = JAPAN_GOTHIC; | 49 face = JAPAN_GOTHIC; |
47 return; | 50 return; |
48 } | 51 } |
49 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) { | 52 if (!(pitch_family & FXFONT_FF_ROMAN) && weight > 400) { |
50 face = JAPAN_GOTHIC; | 53 face = JAPAN_GOTHIC; |
51 } else { | 54 } else { |
52 face = JAPAN_MINCHO; | 55 face = JAPAN_MINCHO; |
53 } | 56 } |
54 } | 57 } |
55 void* CFX_MacFontInfo::MapFont(int weight, | 58 void* CFX_MacFontInfo::MapFont(int weight, |
56 FX_BOOL bItalic, | 59 FX_BOOL bItalic, |
57 int charset, | 60 int charset, |
58 int pitch_family, | 61 int pitch_family, |
59 const FX_CHAR* cstr_face, | 62 const FX_CHAR* cstr_face, |
(...skipping 26 matching lines...) Expand all Loading... |
86 case FXFONT_GB2312_CHARSET: | 89 case FXFONT_GB2312_CHARSET: |
87 face = "STSong"; | 90 face = "STSong"; |
88 break; | 91 break; |
89 case FXFONT_HANGEUL_CHARSET: | 92 case FXFONT_HANGEUL_CHARSET: |
90 face = "AppleMyungjo"; | 93 face = "AppleMyungjo"; |
91 break; | 94 break; |
92 case FXFONT_CHINESEBIG5_CHARSET: | 95 case FXFONT_CHINESEBIG5_CHARSET: |
93 face = "LiSong Pro Light"; | 96 face = "LiSong Pro Light"; |
94 } | 97 } |
95 it = m_FontList.find(face); | 98 it = m_FontList.find(face); |
96 if (it != m_FontList.end()) | 99 return it != m_FontList.end() ? it->second : nullptr; |
97 return it->second; | |
98 | |
99 return nullptr; | |
100 } | 100 } |
101 | 101 |
102 std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault( | 102 std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault( |
103 const char** pUnused) { | 103 const char** pUnused) { |
104 CFX_MacFontInfo* pInfo(new CFX_MacFontInfo); | 104 CFX_MacFontInfo* pInfo(new CFX_MacFontInfo); |
105 pInfo->AddPath("~/Library/Fonts"); | 105 pInfo->AddPath("~/Library/Fonts"); |
106 pInfo->AddPath("/Library/Fonts"); | 106 pInfo->AddPath("/Library/Fonts"); |
107 pInfo->AddPath("/System/Library/Fonts"); | 107 pInfo->AddPath("/System/Library/Fonts"); |
108 return std::unique_ptr<CFX_MacFontInfo>(pInfo); | 108 return std::unique_ptr<CFX_MacFontInfo>(pInfo); |
109 } | 109 } |
110 | 110 |
111 void CFX_GEModule::InitPlatform() { | 111 void CFX_GEModule::InitPlatform() { |
112 m_pPlatformData = new CApplePlatform; | 112 m_pPlatformData = new CApplePlatform; |
113 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault(nullptr)); | 113 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault(nullptr)); |
114 } | 114 } |
115 void CFX_GEModule::DestroyPlatform() { | 115 void CFX_GEModule::DestroyPlatform() { |
116 delete (CApplePlatform*)m_pPlatformData; | 116 delete (CApplePlatform*)m_pPlatformData; |
117 m_pPlatformData = nullptr; | 117 m_pPlatformData = nullptr; |
118 } | 118 } |
119 #endif | 119 #endif |
OLD | NEW |