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 "../../../include/fxge/fx_ge.h" | 7 #include "../../../include/fxge/fx_ge.h" |
8 #include "apple_int.h" | 8 #include "apple_int.h" |
9 #if _FX_OS_ == _FX_MACOSX_ | 9 #if _FX_OS_ == _FX_MACOSX_ |
10 static const struct { | 10 static const struct { |
11 FX_LPCSTR» m_pName; | 11 const FX_CHAR*» m_pName; |
12 FX_LPCSTR» m_pSubstName; | 12 const FX_CHAR*» m_pSubstName; |
13 } | 13 } |
14 Base14Substs[] = { | 14 Base14Substs[] = { |
15 {"Courier", "Courier New"}, | 15 {"Courier", "Courier New"}, |
16 {"Courier-Bold", "Courier New Bold"}, | 16 {"Courier-Bold", "Courier New Bold"}, |
17 {"Courier-BoldOblique", "Courier New Bold Italic"}, | 17 {"Courier-BoldOblique", "Courier New Bold Italic"}, |
18 {"Courier-Oblique", "Courier New Italic"}, | 18 {"Courier-Oblique", "Courier New Italic"}, |
19 {"Helvetica", "Arial"}, | 19 {"Helvetica", "Arial"}, |
20 {"Helvetica-Bold", "Arial Bold"}, | 20 {"Helvetica-Bold", "Arial Bold"}, |
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 class CFX_MacFontInfo : public CFX_FolderFontInfo | 28 class CFX_MacFontInfo : public CFX_FolderFontInfo |
29 { | 29 { |
30 public: | 30 public: |
31 virtual void*» » MapFont(int weight, FX_BOOL bItalic, int charset
, int pitch_family, FX_LPCSTR family, FX_BOOL& bExact); | 31 virtual void*» » MapFont(int weight, FX_BOOL bItalic, int charset
, int pitch_family, const FX_CHAR* family, FX_BOOL& bExact); |
32 }; | 32 }; |
33 #define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6" | 33 #define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6" |
34 #define JAPAN_MINCHO "Hiragino Mincho Pro W6" | 34 #define JAPAN_MINCHO "Hiragino Mincho Pro W6" |
35 static void GetJapanesePreference(CFX_ByteString& face, int weight, int picth_fa
mily) | 35 static void GetJapanesePreference(CFX_ByteString& face, int weight, int picth_fa
mily) |
36 { | 36 { |
37 if (face.Find("Gothic") >= 0) { | 37 if (face.Find("Gothic") >= 0) { |
38 face = JAPAN_GOTHIC; | 38 face = JAPAN_GOTHIC; |
39 return; | 39 return; |
40 } | 40 } |
41 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) { | 41 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) { |
42 face = JAPAN_GOTHIC; | 42 face = JAPAN_GOTHIC; |
43 } else { | 43 } else { |
44 face = JAPAN_MINCHO; | 44 face = JAPAN_MINCHO; |
45 } | 45 } |
46 } | 46 } |
47 void* CFX_MacFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pit
ch_family, FX_LPCSTR cstr_face, FX_BOOL& bExact) | 47 void* CFX_MacFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pit
ch_family, const FX_CHAR* cstr_face, FX_BOOL& bExact) |
48 { | 48 { |
49 CFX_ByteString face = cstr_face; | 49 CFX_ByteString face = cstr_face; |
50 int iBaseFont; | 50 int iBaseFont; |
51 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++) | 51 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++) |
52 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) { | 52 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) { |
53 face = Base14Substs[iBaseFont].m_pSubstName; | 53 face = Base14Substs[iBaseFont].m_pSubstName; |
54 bExact = TRUE; | 54 bExact = TRUE; |
55 break; | 55 break; |
56 } | 56 } |
57 if (iBaseFont < 12) { | 57 if (iBaseFont < 12) { |
58 return GetFont(face); | 58 return GetFont(face); |
59 } | 59 } |
60 FX_LPVOID p; | 60 void* p; |
61 if (m_FontList.Lookup(face, p)) { | 61 if (m_FontList.Lookup(face, p)) { |
62 return p; | 62 return p; |
63 } | 63 } |
64 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH))
{ | 64 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH))
{ |
65 return GetFont("Courier New"); | 65 return GetFont("Courier New"); |
66 } | 66 } |
67 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) { | 67 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) { |
68 return NULL; | 68 return NULL; |
69 } | 69 } |
70 switch (charset) { | 70 switch (charset) { |
(...skipping 28 matching lines...) Expand all Loading... |
99 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault()); | 99 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault()); |
100 } | 100 } |
101 void CFX_GEModule::DestroyPlatform() | 101 void CFX_GEModule::DestroyPlatform() |
102 { | 102 { |
103 if (m_pPlatformData) { | 103 if (m_pPlatformData) { |
104 delete (CApplePlatform *) m_pPlatformData; | 104 delete (CApplePlatform *) m_pPlatformData; |
105 } | 105 } |
106 m_pPlatformData = NULL; | 106 m_pPlatformData = NULL; |
107 } | 107 } |
108 #endif | 108 #endif |
OLD | NEW |