| 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/cfx_gemodule.h" | 8 #include "core/fxge/cfx_gemodule.h" |
| 9 #include "core/fxge/ge/cfx_folderfontinfo.h" | 9 #include "core/fxge/ge/cfx_folderfontinfo.h" |
| 10 #include "core/fxge/ifx_systemfontinfo.h" | 10 #include "core/fxge/ifx_systemfontinfo.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 {"Times-Italic", "Times New Roman Italic"}, | 31 {"Times-Italic", "Times New Roman Italic"}, |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 class CFX_MacFontInfo : public CFX_FolderFontInfo { | 34 class CFX_MacFontInfo : public CFX_FolderFontInfo { |
| 35 public: | 35 public: |
| 36 CFX_MacFontInfo() {} | 36 CFX_MacFontInfo() {} |
| 37 ~CFX_MacFontInfo() override {} | 37 ~CFX_MacFontInfo() override {} |
| 38 | 38 |
| 39 // CFX_FolderFontInfo | 39 // CFX_FolderFontInfo |
| 40 void* MapFont(int weight, | 40 void* MapFont(int weight, |
| 41 FX_BOOL bItalic, | 41 bool bItalic, |
| 42 int charset, | 42 int charset, |
| 43 int pitch_family, | 43 int pitch_family, |
| 44 const FX_CHAR* family, | 44 const FX_CHAR* family, |
| 45 int& iExact) override; | 45 int& iExact) override; |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 const char JAPAN_GOTHIC[] = "Hiragino Kaku Gothic Pro W6"; | 48 const char JAPAN_GOTHIC[] = "Hiragino Kaku Gothic Pro W6"; |
| 49 const char JAPAN_MINCHO[] = "Hiragino Mincho Pro W6"; | 49 const char JAPAN_MINCHO[] = "Hiragino Mincho Pro W6"; |
| 50 | 50 |
| 51 void GetJapanesePreference(CFX_ByteString* face, int weight, int pitch_family) { | 51 void GetJapanesePreference(CFX_ByteString* face, int weight, int pitch_family) { |
| 52 if (face->Find("Gothic") >= 0) { | 52 if (face->Find("Gothic") >= 0) { |
| 53 *face = JAPAN_GOTHIC; | 53 *face = JAPAN_GOTHIC; |
| 54 return; | 54 return; |
| 55 } | 55 } |
| 56 *face = ((pitch_family & FXFONT_FF_ROMAN) || weight <= 400) ? JAPAN_MINCHO | 56 *face = ((pitch_family & FXFONT_FF_ROMAN) || weight <= 400) ? JAPAN_MINCHO |
| 57 : JAPAN_GOTHIC; | 57 : JAPAN_GOTHIC; |
| 58 } | 58 } |
| 59 | 59 |
| 60 void* CFX_MacFontInfo::MapFont(int weight, | 60 void* CFX_MacFontInfo::MapFont(int weight, |
| 61 FX_BOOL bItalic, | 61 bool bItalic, |
| 62 int charset, | 62 int charset, |
| 63 int pitch_family, | 63 int pitch_family, |
| 64 const FX_CHAR* cstr_face, | 64 const FX_CHAR* cstr_face, |
| 65 int& iExact) { | 65 int& iExact) { |
| 66 CFX_ByteString face = cstr_face; | 66 CFX_ByteString face = cstr_face; |
| 67 for (size_t i = 0; i < FX_ArraySize(g_Base14Substs); ++i) { | 67 for (size_t i = 0; i < FX_ArraySize(g_Base14Substs); ++i) { |
| 68 if (face == CFX_ByteStringC(g_Base14Substs[i].m_pName)) { | 68 if (face == CFX_ByteStringC(g_Base14Substs[i].m_pName)) { |
| 69 face = g_Base14Substs[i].m_pSubstName; | 69 face = g_Base14Substs[i].m_pSubstName; |
| 70 iExact = TRUE; | 70 iExact = true; |
| 71 return GetFont(face.c_str()); | 71 return GetFont(face.c_str()); |
| 72 } | 72 } |
| 73 } | 73 } |
| 74 | 74 |
| 75 // The request may not ask for the bold and/or italic version of a font by | 75 // The request may not ask for the bold and/or italic version of a font by |
| 76 // name. So try to construct the appropriate name. This is not 100% foolproof | 76 // name. So try to construct the appropriate name. This is not 100% foolproof |
| 77 // as there are fonts that have "Oblique" or "BoldOblique" or "Heavy" in their | 77 // as there are fonts that have "Oblique" or "BoldOblique" or "Heavy" in their |
| 78 // names instead. But this at least works for common fonts like Arial and | 78 // names instead. But this at least works for common fonts like Arial and |
| 79 // Times New Roman. A more sophisticated approach would be to find all the | 79 // Times New Roman. A more sophisticated approach would be to find all the |
| 80 // fonts in |m_FontList| with |face| in the name, and examine the fonts to | 80 // fonts in |m_FontList| with |face| in the name, and examine the fonts to |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 m_pPlatformData = new CApplePlatform; | 132 m_pPlatformData = new CApplePlatform; |
| 133 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault(nullptr)); | 133 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault(nullptr)); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void CFX_GEModule::DestroyPlatform() { | 136 void CFX_GEModule::DestroyPlatform() { |
| 137 delete reinterpret_cast<CApplePlatform*>(m_pPlatformData); | 137 delete reinterpret_cast<CApplePlatform*>(m_pPlatformData); |
| 138 m_pPlatformData = nullptr; | 138 m_pPlatformData = nullptr; |
| 139 } | 139 } |
| 140 | 140 |
| 141 #endif // _FX_OS_ == _FX_MACOSX_ | 141 #endif // _FX_OS_ == _FX_MACOSX_ |
| OLD | NEW |