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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 int charset, | 60 int charset, |
61 int pitch_family, | 61 int pitch_family, |
62 const FX_CHAR* cstr_face, | 62 const FX_CHAR* cstr_face, |
63 int& iExact) { | 63 int& iExact) { |
64 CFX_ByteString face = cstr_face; | 64 CFX_ByteString face = cstr_face; |
65 for (size_t i = 0; i < FX_ArraySize(g_Base14Substs); ++i) { | 65 for (size_t i = 0; i < FX_ArraySize(g_Base14Substs); ++i) { |
66 if (face == CFX_ByteStringC(g_Base14Substs[i].m_pName)) { | 66 if (face == CFX_ByteStringC(g_Base14Substs[i].m_pName)) { |
67 face = g_Base14Substs[i].m_pSubstName; | 67 face = g_Base14Substs[i].m_pSubstName; |
68 iExact = TRUE; | 68 iExact = TRUE; |
69 return GetFont(face.c_str()); | 69 return GetFont(face.c_str()); |
70 break; | |
71 } | 70 } |
72 } | 71 } |
73 | 72 |
| 73 // The request may not ask for the bold and/or italic version of a font by |
| 74 // name. So try to construct the appropriate name. This is not 100% foolproof |
| 75 // as there are fonts that have "Oblique" or "BoldOblique" or "Heavy" in their |
| 76 // names instead. But this at least works for common fonts like Arial and |
| 77 // Times New Roman. A more sophisticated approach would be to find all the |
| 78 // fonts in |m_FontList| with |face| in the name, and examine the fonts to |
| 79 // see which best matches the requested characteristics. |
| 80 if (face.Find("Bold") == -1 && face.Find("Italic") == -1) { |
| 81 CFX_ByteString new_face = face; |
| 82 if (weight > 400) |
| 83 new_face += " Bold"; |
| 84 if (bItalic) |
| 85 new_face += " Italic"; |
| 86 auto it = m_FontList.find(new_face); |
| 87 if (it != m_FontList.end()) |
| 88 return it->second; |
| 89 } |
| 90 |
74 auto it = m_FontList.find(face); | 91 auto it = m_FontList.find(face); |
75 if (it != m_FontList.end()) | 92 if (it != m_FontList.end()) |
76 return it->second; | 93 return it->second; |
77 | 94 |
78 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) | 95 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) |
79 return GetFont("Courier New"); | 96 return GetFont("Courier New"); |
80 | 97 |
81 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) | 98 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) |
82 return nullptr; | 99 return nullptr; |
83 | 100 |
(...skipping 29 matching lines...) Expand all Loading... |
113 m_pPlatformData = new CApplePlatform; | 130 m_pPlatformData = new CApplePlatform; |
114 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault(nullptr)); | 131 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault(nullptr)); |
115 } | 132 } |
116 | 133 |
117 void CFX_GEModule::DestroyPlatform() { | 134 void CFX_GEModule::DestroyPlatform() { |
118 delete reinterpret_cast<CApplePlatform*>(m_pPlatformData); | 135 delete reinterpret_cast<CApplePlatform*>(m_pPlatformData); |
119 m_pPlatformData = nullptr; | 136 m_pPlatformData = nullptr; |
120 } | 137 } |
121 | 138 |
122 #endif // _FX_OS_ == _FX_MACOSX_ | 139 #endif // _FX_OS_ == _FX_MACOSX_ |
OLD | NEW |