Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: core/src/fxge/apple/fx_mac_imp.cpp

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 const FX_CHAR*» m_pName; 11 const FX_CHAR* m_pName;
12 const FX_CHAR*» m_pSubstName; 12 const FX_CHAR* m_pSubstName;
13 } 13 } Base14Substs[] = {
14 Base14Substs[] = {
15 {"Courier", "Courier New"}, 14 {"Courier", "Courier New"},
16 {"Courier-Bold", "Courier New Bold"}, 15 {"Courier-Bold", "Courier New Bold"},
17 {"Courier-BoldOblique", "Courier New Bold Italic"}, 16 {"Courier-BoldOblique", "Courier New Bold Italic"},
18 {"Courier-Oblique", "Courier New Italic"}, 17 {"Courier-Oblique", "Courier New Italic"},
19 {"Helvetica", "Arial"}, 18 {"Helvetica", "Arial"},
20 {"Helvetica-Bold", "Arial Bold"}, 19 {"Helvetica-Bold", "Arial Bold"},
21 {"Helvetica-BoldOblique", "Arial Bold Italic"}, 20 {"Helvetica-BoldOblique", "Arial Bold Italic"},
22 {"Helvetica-Oblique", "Arial Italic"}, 21 {"Helvetica-Oblique", "Arial Italic"},
23 {"Times-Roman", "Times New Roman"}, 22 {"Times-Roman", "Times New Roman"},
24 {"Times-Bold", "Times New Roman Bold"}, 23 {"Times-Bold", "Times New Roman Bold"},
25 {"Times-BoldItalic", "Times New Roman Bold Italic"}, 24 {"Times-BoldItalic", "Times New Roman Bold Italic"},
26 {"Times-Italic", "Times New Roman Italic"}, 25 {"Times-Italic", "Times New Roman Italic"},
27 }; 26 };
28 class CFX_MacFontInfo : public CFX_FolderFontInfo 27 class CFX_MacFontInfo : public CFX_FolderFontInfo {
29 { 28 public:
30 public: 29 virtual void* MapFont(int weight,
31 virtual void*» » MapFont(int weight, FX_BOOL bItalic, int charset , int pitch_family, const FX_CHAR* family, int& iExact); 30 FX_BOOL bItalic,
31 int charset,
32 int pitch_family,
33 const FX_CHAR* family,
34 int& iExact);
32 }; 35 };
33 #define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6" 36 #define JAPAN_GOTHIC "Hiragino Kaku Gothic Pro W6"
34 #define JAPAN_MINCHO "Hiragino Mincho Pro W6" 37 #define JAPAN_MINCHO "Hiragino Mincho Pro W6"
35 static void GetJapanesePreference(CFX_ByteString& face, int weight, int picth_fa mily) 38 static void GetJapanesePreference(CFX_ByteString& face,
36 { 39 int weight,
37 if (face.Find("Gothic") >= 0) { 40 int picth_family) {
38 face = JAPAN_GOTHIC; 41 if (face.Find("Gothic") >= 0) {
39 return; 42 face = JAPAN_GOTHIC;
43 return;
44 }
45 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) {
46 face = JAPAN_GOTHIC;
47 } else {
48 face = JAPAN_MINCHO;
49 }
50 }
51 void* CFX_MacFontInfo::MapFont(int weight,
52 FX_BOOL bItalic,
53 int charset,
54 int pitch_family,
55 const FX_CHAR* cstr_face,
56 int& iExact) {
57 CFX_ByteString face = cstr_face;
58 int iBaseFont;
59 for (iBaseFont = 0; iBaseFont < 12; iBaseFont++)
60 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) {
61 face = Base14Substs[iBaseFont].m_pSubstName;
62 iExact = TRUE;
63 break;
40 } 64 }
41 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) { 65 if (iBaseFont < 12) {
42 face = JAPAN_GOTHIC; 66 return GetFont(face);
43 } else { 67 }
44 face = JAPAN_MINCHO; 68 void* p;
45 } 69 if (m_FontList.Lookup(face, p)) {
70 return p;
71 }
72 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {
73 return GetFont("Courier New");
74 }
75 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) {
76 return NULL;
77 }
78 switch (charset) {
79 case FXFONT_SHIFTJIS_CHARSET:
80 GetJapanesePreference(face, weight, pitch_family);
81 break;
82 case FXFONT_GB2312_CHARSET:
83 face = "STSong";
84 break;
85 case FXFONT_HANGEUL_CHARSET:
86 face = "AppleMyungjo";
87 break;
88 case FXFONT_CHINESEBIG5_CHARSET:
89 face = "LiSong Pro Light";
90 }
91 if (m_FontList.Lookup(face, p)) {
92 return p;
93 }
94 return NULL;
46 } 95 }
47 void* CFX_MacFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pit ch_family, const FX_CHAR* cstr_face, int& iExact) 96 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() {
48 { 97 CFX_MacFontInfo* pInfo = new CFX_MacFontInfo;
49 CFX_ByteString face = cstr_face; 98 pInfo->AddPath("~/Library/Fonts");
50 int iBaseFont; 99 pInfo->AddPath("/Library/Fonts");
51 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++) 100 pInfo->AddPath("/System/Library/Fonts");
52 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) { 101 return pInfo;
53 face = Base14Substs[iBaseFont].m_pSubstName;
54 iExact = TRUE;
55 break;
56 }
57 if (iBaseFont < 12) {
58 return GetFont(face);
59 }
60 void* p;
61 if (m_FontList.Lookup(face, p)) {
62 return p;
63 }
64 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {
65 return GetFont("Courier New");
66 }
67 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) {
68 return NULL;
69 }
70 switch (charset) {
71 case FXFONT_SHIFTJIS_CHARSET:
72 GetJapanesePreference(face, weight, pitch_family);
73 break;
74 case FXFONT_GB2312_CHARSET:
75 face = "STSong";
76 break;
77 case FXFONT_HANGEUL_CHARSET:
78 face = "AppleMyungjo";
79 break;
80 case FXFONT_CHINESEBIG5_CHARSET:
81 face = "LiSong Pro Light";
82 }
83 if (m_FontList.Lookup(face, p)) {
84 return p;
85 }
86 return NULL;
87 } 102 }
88 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() 103 void CFX_GEModule::InitPlatform() {
89 { 104 m_pPlatformData = new CApplePlatform;
90 CFX_MacFontInfo* pInfo = new CFX_MacFontInfo; 105 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault());
91 pInfo->AddPath("~/Library/Fonts");
92 pInfo->AddPath("/Library/Fonts");
93 pInfo->AddPath("/System/Library/Fonts");
94 return pInfo;
95 } 106 }
96 void CFX_GEModule::InitPlatform() 107 void CFX_GEModule::DestroyPlatform() {
97 { 108 delete (CApplePlatform*)m_pPlatformData;
98 m_pPlatformData = new CApplePlatform; 109 m_pPlatformData = NULL;
99 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault());
100 }
101 void CFX_GEModule::DestroyPlatform()
102 {
103 delete (CApplePlatform *)m_pPlatformData;
104 m_pPlatformData = NULL;
105 } 110 }
106 #endif 111 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698