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

Side by Side Diff: core/src/fxge/ge/fx_ge_linux.cpp

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 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
« no previous file with comments | « core/src/fxge/ge/fx_ge_fontmap.cpp ('k') | core/src/fxge/ge/fx_ge_path.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "../agg/include/fx_agg_driver.h" 8 #include "../agg/include/fx_agg_driver.h"
9 #include "text_int.h" 9 #include "text_int.h"
10 10
(...skipping 12 matching lines...) Expand all
23 {"Helvetica-BoldOblique", "Arial Bold Italic"}, 23 {"Helvetica-BoldOblique", "Arial Bold Italic"},
24 {"Helvetica-Oblique", "Arial Italic"}, 24 {"Helvetica-Oblique", "Arial Italic"},
25 {"Times-Roman", "Times New Roman"}, 25 {"Times-Roman", "Times New Roman"},
26 {"Times-Bold", "Times New Roman Bold"}, 26 {"Times-Bold", "Times New Roman Bold"},
27 {"Times-BoldItalic", "Times New Roman Bold Italic"}, 27 {"Times-BoldItalic", "Times New Roman Bold Italic"},
28 {"Times-Italic", "Times New Roman Italic"}, 28 {"Times-Italic", "Times New Roman Italic"},
29 }; 29 };
30 class CFX_LinuxFontInfo : public CFX_FolderFontInfo 30 class CFX_LinuxFontInfo : public CFX_FolderFontInfo
31 { 31 {
32 public: 32 public:
33 virtual void*» » MapFont(int weight, FX_BOOL bItalic, int charset , int pitch_family, const FX_CHAR* family, FX_BOOL& bExact); 33 void* MapFont(int weight, bool bItalic, int charset, int pitch_family,
34 FX_BOOL» » » » ParseFontCfg(); 34 const FX_CHAR* family, int& iExact) override;
35 void*» » » » FindFont(int weight, FX_BOOL bItalic, in t charset, int pitch_family, const FX_CHAR* family, FX_BOOL bMatchName); 35
36 bool ParseFontCfg();
37 void* FindFont(int weight, bool bItalic, int charset, int pitch_family,
38 const FX_CHAR* family, bool bMatchName);
36 }; 39 };
37 #define LINUX_GPNAMESIZE 6 40 #define LINUX_GPNAMESIZE 6
38 static const struct { 41 static const struct {
39 const FX_CHAR* NameArr[LINUX_GPNAMESIZE]; 42 const FX_CHAR* NameArr[LINUX_GPNAMESIZE];
40 } 43 }
41 LinuxGpFontList[] = { 44 LinuxGpFontList[] = {
42 {{"TakaoPGothic", "VL PGothic", "IPAPGothic", "VL Gothic", "Kochi Gothic", " VL Gothic regular"}}, 45 {{"TakaoPGothic", "VL PGothic", "IPAPGothic", "VL Gothic", "Kochi Gothic", " VL Gothic regular"}},
43 {{"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", NULL, "VL Gothic regular"}}, 46 {{"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", NULL, "VL Gothic regular"}},
44 {{"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothi c regular"}}, 47 {{"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothi c regular"}},
45 {{"TakaoMincho", "IPAMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothic regular"}}, 48 {{"TakaoMincho", "IPAMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothic regular"}},
(...skipping 25 matching lines...) Expand all
71 return 2; 74 return 2;
72 } else { 75 } else {
73 return 3; 76 return 3;
74 } 77 }
75 } 78 }
76 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) { 79 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) {
77 return 0; 80 return 0;
78 } 81 }
79 return 2; 82 return 2;
80 } 83 }
81 void* CFX_LinuxFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int p itch_family, const FX_CHAR* cstr_face, FX_BOOL& bExact) 84 void* CFX_LinuxFontInfo::MapFont(int weight, bool bItalic, int charset, int pitc h_family, const FX_CHAR* cstr_face, int& iExact)
82 { 85 {
83 CFX_ByteString face = cstr_face; 86 CFX_ByteString face = cstr_face;
84 int iBaseFont; 87 int iBaseFont;
85 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++) 88 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++)
86 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) { 89 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) {
87 face = Base14Substs[iBaseFont].m_pSubstName; 90 face = Base14Substs[iBaseFont].m_pSubstName;
88 bExact = TRUE; 91 iExact = true;
89 break; 92 break;
90 } 93 }
91 if (iBaseFont < 12) { 94 if (iBaseFont < 12) {
92 return GetFont(face); 95 return GetFont(face);
93 } 96 }
94 void* p = NULL; 97 void* p = NULL;
95 FX_BOOL bCJK = TRUE; 98 bool bCJK = true;
96 switch (charset) { 99 switch (charset) {
97 case FXFONT_SHIFTJIS_CHARSET: { 100 case FXFONT_SHIFTJIS_CHARSET: {
98 int32_t index = GetJapanesePreference(cstr_face, weight, pitch_f amily); 101 int32_t index = GetJapanesePreference(cstr_face, weight, pitch_f amily);
99 if (index < 0) { 102 if (index < 0) {
100 break; 103 break;
101 } 104 }
102 for (int32_t i = 0; i < LINUX_GPNAMESIZE; i++) 105 for (int32_t i = 0; i < LINUX_GPNAMESIZE; i++)
103 if (m_FontList.Lookup(LinuxGpFontList[index].NameArr[i], p)) { 106 if (m_FontList.Lookup(LinuxGpFontList[index].NameArr[i], p)) {
104 return p; 107 return p;
105 } 108 }
(...skipping 17 matching lines...) Expand all
123 break; 126 break;
124 case FXFONT_HANGEUL_CHARSET: { 127 case FXFONT_HANGEUL_CHARSET: {
125 static int32_t s_hgCount = sizeof(g_LinuxHGFontList) / sizeof(co nst FX_CHAR*); 128 static int32_t s_hgCount = sizeof(g_LinuxHGFontList) / sizeof(co nst FX_CHAR*);
126 for (int32_t i = 0; i < s_hgCount; i++) 129 for (int32_t i = 0; i < s_hgCount; i++)
127 if (m_FontList.Lookup(g_LinuxHGFontList[i], p)) { 130 if (m_FontList.Lookup(g_LinuxHGFontList[i], p)) {
128 return p; 131 return p;
129 } 132 }
130 } 133 }
131 break; 134 break;
132 default: 135 default:
133 bCJK = FALSE; 136 bCJK = false;
134 break; 137 break;
135 } 138 }
136 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) { 139 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {
137 return GetFont("Courier New"); 140 return GetFont("Courier New");
138 } 141 }
139 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK); 142 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK);
140 } 143 }
141 static FX_DWORD _LinuxGetCharset(int charset) 144 static FX_DWORD _LinuxGetCharset(int charset)
142 { 145 {
143 switch(charset) { 146 switch(charset) {
144 case FXFONT_SHIFTJIS_CHARSET: 147 case FXFONT_SHIFTJIS_CHARSET:
145 return CHARSET_FLAG_SHIFTJIS; 148 return CHARSET_FLAG_SHIFTJIS;
146 case FXFONT_GB2312_CHARSET: 149 case FXFONT_GB2312_CHARSET:
147 return CHARSET_FLAG_GB; 150 return CHARSET_FLAG_GB;
148 case FXFONT_CHINESEBIG5_CHARSET: 151 case FXFONT_CHINESEBIG5_CHARSET:
149 return CHARSET_FLAG_BIG5; 152 return CHARSET_FLAG_BIG5;
150 case FXFONT_HANGEUL_CHARSET: 153 case FXFONT_HANGEUL_CHARSET:
151 return CHARSET_FLAG_KOREAN; 154 return CHARSET_FLAG_KOREAN;
152 case FXFONT_SYMBOL_CHARSET: 155 case FXFONT_SYMBOL_CHARSET:
153 return CHARSET_FLAG_SYMBOL; 156 return CHARSET_FLAG_SYMBOL;
154 case FXFONT_ANSI_CHARSET: 157 case FXFONT_ANSI_CHARSET:
155 return CHARSET_FLAG_ANSI; 158 return CHARSET_FLAG_ANSI;
156 default: 159 default:
157 break; 160 break;
158 } 161 }
159 return 0; 162 return 0;
160 } 163 }
161 static int32_t _LinuxGetSimilarValue(int weight, FX_BOOL bItalic, int pitch_fami ly, FX_DWORD style) 164 static int32_t _LinuxGetSimilarValue(int weight, bool bItalic, int pitch_family, FX_DWORD style)
162 { 165 {
163 int32_t iSimilarValue = 0; 166 int32_t iSimilarValue = 0;
164 if ((style & FXFONT_BOLD) == (weight > 400)) { 167 if ((style & FXFONT_BOLD) == (weight > 400)) {
165 iSimilarValue += 16; 168 iSimilarValue += 16;
166 } 169 }
167 if ((style & FXFONT_ITALIC) == bItalic) { 170 if ((style & FXFONT_ITALIC) == bItalic) {
168 iSimilarValue += 16; 171 iSimilarValue += 16;
169 } 172 }
170 if ((style & FXFONT_SERIF) == (pitch_family & FXFONT_FF_ROMAN)) { 173 if ((style & FXFONT_SERIF) == (pitch_family & FXFONT_FF_ROMAN)) {
171 iSimilarValue += 16; 174 iSimilarValue += 16;
172 } 175 }
173 if ((style & FXFONT_SCRIPT) == (pitch_family & FXFONT_FF_SCRIPT)) { 176 if ((style & FXFONT_SCRIPT) == (pitch_family & FXFONT_FF_SCRIPT)) {
174 iSimilarValue += 8; 177 iSimilarValue += 8;
175 } 178 }
176 if ((style & FXFONT_FIXED_PITCH) == (pitch_family & FXFONT_FF_FIXEDPITCH)) { 179 if ((style & FXFONT_FIXED_PITCH) == (pitch_family & FXFONT_FF_FIXEDPITCH)) {
177 iSimilarValue += 8; 180 iSimilarValue += 8;
178 } 181 }
179 return iSimilarValue; 182 return iSimilarValue;
180 } 183 }
181 void* CFX_LinuxFontInfo::FindFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* family, FX_BOOL bMatchName) 184 void* CFX_LinuxFontInfo::FindFont(int weight, bool bItalic, int charset, int pit ch_family, const FX_CHAR* family, bool bMatchName)
182 { 185 {
183 CFontFaceInfo* pFind = NULL; 186 CFontFaceInfo* pFind = NULL;
184 FX_DWORD charset_flag = _LinuxGetCharset(charset); 187 FX_DWORD charset_flag = _LinuxGetCharset(charset);
185 int32_t iBestSimilar = 0; 188 int32_t iBestSimilar = 0;
186 FX_POSITION pos = m_FontList.GetStartPosition(); 189 FX_POSITION pos = m_FontList.GetStartPosition();
187 while (pos) { 190 while (pos) {
188 CFX_ByteString bsName; 191 CFX_ByteString bsName;
189 CFontFaceInfo* pFont = NULL; 192 CFontFaceInfo* pFont = NULL;
190 m_FontList.GetNextAssoc(pos, bsName, (void*&)pFont); 193 m_FontList.GetNextAssoc(pos, bsName, (void*&)pFont);
191 if (!(pFont->m_Charsets & charset_flag) && charset != FXFONT_DEFAULT_CHA RSET) { 194 if (!(pFont->m_Charsets & charset_flag) && charset != FXFONT_DEFAULT_CHA RSET) {
(...skipping 19 matching lines...) Expand all
211 { 214 {
212 CFX_LinuxFontInfo* pInfo = new CFX_LinuxFontInfo; 215 CFX_LinuxFontInfo* pInfo = new CFX_LinuxFontInfo;
213 if (!pInfo->ParseFontCfg()) { 216 if (!pInfo->ParseFontCfg()) {
214 pInfo->AddPath("/usr/share/fonts"); 217 pInfo->AddPath("/usr/share/fonts");
215 pInfo->AddPath("/usr/share/X11/fonts/Type1"); 218 pInfo->AddPath("/usr/share/X11/fonts/Type1");
216 pInfo->AddPath("/usr/share/X11/fonts/TTF"); 219 pInfo->AddPath("/usr/share/X11/fonts/TTF");
217 pInfo->AddPath("/usr/local/share/fonts"); 220 pInfo->AddPath("/usr/local/share/fonts");
218 } 221 }
219 return pInfo; 222 return pInfo;
220 } 223 }
221 FX_BOOL CFX_LinuxFontInfo::ParseFontCfg() 224 bool CFX_LinuxFontInfo::ParseFontCfg()
222 { 225 {
223 return FALSE; 226 return false;
224 } 227 }
225 void CFX_GEModule::InitPlatform() 228 void CFX_GEModule::InitPlatform()
226 { 229 {
227 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault()); 230 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault());
228 } 231 }
229 void CFX_GEModule::DestroyPlatform() 232 void CFX_GEModule::DestroyPlatform()
230 { 233 {
231 } 234 }
232 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ 235 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_fontmap.cpp ('k') | core/src/fxge/ge/fx_ge_path.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698