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

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

Issue 1258093002: FX Bool considered harmful, part 3 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: 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
« 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 void* MapFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, co nst FX_CHAR* family, int& iExact) override; 33 void* MapFont(int weight, bool bItalic, int charset, int pitch_family, const FX_CHAR* family, int& iExact) override;
34 FX_BOOL» » » » ParseFontCfg(); 34 bool» » » » ParseFontCfg();
35 void*» » » » FindFont(int weight, FX_BOOL bItalic, in t charset, int pitch_family, const FX_CHAR* family, FX_BOOL bMatchName); 35 void*» » » » FindFont(int weight, bool bItalic, int c harset, int pitch_family, const FX_CHAR* family, bool bMatchName);
36 }; 36 };
37 #define LINUX_GPNAMESIZE 6 37 #define LINUX_GPNAMESIZE 6
38 static const struct { 38 static const struct {
39 const FX_CHAR* NameArr[LINUX_GPNAMESIZE]; 39 const FX_CHAR* NameArr[LINUX_GPNAMESIZE];
40 } 40 }
41 LinuxGpFontList[] = { 41 LinuxGpFontList[] = {
42 {{"TakaoPGothic", "VL PGothic", "IPAPGothic", "VL Gothic", "Kochi Gothic", " VL Gothic regular"}}, 42 {{"TakaoPGothic", "VL PGothic", "IPAPGothic", "VL Gothic", "Kochi Gothic", " VL Gothic regular"}},
43 {{"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", NULL, "VL Gothic regular"}}, 43 {{"TakaoGothic", "VL Gothic", "IPAGothic", "Kochi Gothic", NULL, "VL Gothic regular"}},
44 {{"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothi c regular"}}, 44 {{"TakaoPMincho", "IPAPMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothi c regular"}},
45 {{"TakaoMincho", "IPAMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothic regular"}}, 45 {{"TakaoMincho", "IPAMincho", "VL Gothic", "Kochi Mincho", NULL, "VL Gothic regular"}},
(...skipping 24 matching lines...) Expand all
70 if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") > = 0) { 70 if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") > = 0) {
71 return 2; 71 return 2;
72 } 72 }
73 return 3; 73 return 3;
74 } 74 }
75 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) { 75 if (!(picth_family & FXFONT_FF_ROMAN) && weight > 400) {
76 return 0; 76 return 0;
77 } 77 }
78 return 2; 78 return 2;
79 } 79 }
80 void* CFX_LinuxFontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int p itch_family, const FX_CHAR* cstr_face, int& iExact) 80 void* CFX_LinuxFontInfo::MapFont(int weight, bool bItalic, int charset, int pitc h_family, const FX_CHAR* cstr_face, int& iExact)
81 { 81 {
82 CFX_ByteString face = cstr_face; 82 CFX_ByteString face = cstr_face;
83 int iBaseFont; 83 int iBaseFont;
84 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++) 84 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++)
85 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) { 85 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) {
86 face = Base14Substs[iBaseFont].m_pSubstName; 86 face = Base14Substs[iBaseFont].m_pSubstName;
87 iExact = 1; 87 iExact = 1;
88 break; 88 break;
89 } 89 }
90 if (iBaseFont < 12) { 90 if (iBaseFont < 12) {
91 return GetFont(face); 91 return GetFont(face);
92 } 92 }
93 void* p = NULL; 93 void* p = NULL;
94 FX_BOOL bCJK = TRUE; 94 bool bCJK = true;
95 switch (charset) { 95 switch (charset) {
96 case FXFONT_SHIFTJIS_CHARSET: { 96 case FXFONT_SHIFTJIS_CHARSET: {
97 int32_t index = GetJapanesePreference(cstr_face, weight, pitch_f amily); 97 int32_t index = GetJapanesePreference(cstr_face, weight, pitch_f amily);
98 if (index < 0) { 98 if (index < 0) {
99 break; 99 break;
100 } 100 }
101 for (int32_t i = 0; i < LINUX_GPNAMESIZE; i++) 101 for (int32_t i = 0; i < LINUX_GPNAMESIZE; i++)
102 if (m_FontList.Lookup(LinuxGpFontList[index].NameArr[i], p)) { 102 if (m_FontList.Lookup(LinuxGpFontList[index].NameArr[i], p)) {
103 return p; 103 return p;
104 } 104 }
(...skipping 17 matching lines...) Expand all
122 break; 122 break;
123 case FXFONT_HANGEUL_CHARSET: { 123 case FXFONT_HANGEUL_CHARSET: {
124 static int32_t s_hgCount = sizeof(g_LinuxHGFontList) / sizeof(co nst FX_CHAR*); 124 static int32_t s_hgCount = sizeof(g_LinuxHGFontList) / sizeof(co nst FX_CHAR*);
125 for (int32_t i = 0; i < s_hgCount; i++) 125 for (int32_t i = 0; i < s_hgCount; i++)
126 if (m_FontList.Lookup(g_LinuxHGFontList[i], p)) { 126 if (m_FontList.Lookup(g_LinuxHGFontList[i], p)) {
127 return p; 127 return p;
128 } 128 }
129 } 129 }
130 break; 130 break;
131 default: 131 default:
132 bCJK = FALSE; 132 bCJK = false;
133 break; 133 break;
134 } 134 }
135 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) { 135 if (charset == FXFONT_ANSI_CHARSET && (pitch_family & FXFONT_FF_FIXEDPITCH)) {
136 return GetFont("Courier New"); 136 return GetFont("Courier New");
137 } 137 }
138 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK); 138 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK);
139 } 139 }
140 static FX_DWORD _LinuxGetCharset(int charset) 140 static FX_DWORD _LinuxGetCharset(int charset)
141 { 141 {
142 switch(charset) { 142 switch(charset) {
143 case FXFONT_SHIFTJIS_CHARSET: 143 case FXFONT_SHIFTJIS_CHARSET:
144 return CHARSET_FLAG_SHIFTJIS; 144 return CHARSET_FLAG_SHIFTJIS;
145 case FXFONT_GB2312_CHARSET: 145 case FXFONT_GB2312_CHARSET:
146 return CHARSET_FLAG_GB; 146 return CHARSET_FLAG_GB;
147 case FXFONT_CHINESEBIG5_CHARSET: 147 case FXFONT_CHINESEBIG5_CHARSET:
148 return CHARSET_FLAG_BIG5; 148 return CHARSET_FLAG_BIG5;
149 case FXFONT_HANGEUL_CHARSET: 149 case FXFONT_HANGEUL_CHARSET:
150 return CHARSET_FLAG_KOREAN; 150 return CHARSET_FLAG_KOREAN;
151 case FXFONT_SYMBOL_CHARSET: 151 case FXFONT_SYMBOL_CHARSET:
152 return CHARSET_FLAG_SYMBOL; 152 return CHARSET_FLAG_SYMBOL;
153 case FXFONT_ANSI_CHARSET: 153 case FXFONT_ANSI_CHARSET:
154 return CHARSET_FLAG_ANSI; 154 return CHARSET_FLAG_ANSI;
155 default: 155 default:
156 break; 156 break;
157 } 157 }
158 return 0; 158 return 0;
159 } 159 }
160 static int32_t _LinuxGetSimilarValue(int weight, FX_BOOL bItalic, int pitch_fami ly, FX_DWORD style) 160 static int32_t _LinuxGetSimilarValue(int weight, bool bItalic, int pitch_family, FX_DWORD style)
161 { 161 {
162 int32_t iSimilarValue = 0; 162 int32_t iSimilarValue = 0;
163 if ((style & FXFONT_BOLD) == (weight > 400)) { 163 if ((style & FXFONT_BOLD) == (weight > 400)) {
164 iSimilarValue += 16; 164 iSimilarValue += 16;
165 } 165 }
166 if ((style & FXFONT_ITALIC) == bItalic) { 166 if ((style & FXFONT_ITALIC) == bItalic) {
167 iSimilarValue += 16; 167 iSimilarValue += 16;
168 } 168 }
169 if ((style & FXFONT_SERIF) == (pitch_family & FXFONT_FF_ROMAN)) { 169 if ((style & FXFONT_SERIF) == (pitch_family & FXFONT_FF_ROMAN)) {
170 iSimilarValue += 16; 170 iSimilarValue += 16;
171 } 171 }
172 if ((style & FXFONT_SCRIPT) == (pitch_family & FXFONT_FF_SCRIPT)) { 172 if ((style & FXFONT_SCRIPT) == (pitch_family & FXFONT_FF_SCRIPT)) {
173 iSimilarValue += 8; 173 iSimilarValue += 8;
174 } 174 }
175 if ((style & FXFONT_FIXED_PITCH) == (pitch_family & FXFONT_FF_FIXEDPITCH)) { 175 if ((style & FXFONT_FIXED_PITCH) == (pitch_family & FXFONT_FF_FIXEDPITCH)) {
176 iSimilarValue += 8; 176 iSimilarValue += 8;
177 } 177 }
178 return iSimilarValue; 178 return iSimilarValue;
179 } 179 }
180 void* CFX_LinuxFontInfo::FindFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, const FX_CHAR* family, FX_BOOL bMatchName) 180 void* CFX_LinuxFontInfo::FindFont(int weight, bool bItalic, int charset, int pit ch_family, const FX_CHAR* family, bool bMatchName)
181 { 181 {
182 CFontFaceInfo* pFind = NULL; 182 CFontFaceInfo* pFind = NULL;
183 FX_DWORD charset_flag = _LinuxGetCharset(charset); 183 FX_DWORD charset_flag = _LinuxGetCharset(charset);
184 int32_t iBestSimilar = 0; 184 int32_t iBestSimilar = 0;
185 FX_POSITION pos = m_FontList.GetStartPosition(); 185 FX_POSITION pos = m_FontList.GetStartPosition();
186 while (pos) { 186 while (pos) {
187 CFX_ByteString bsName; 187 CFX_ByteString bsName;
188 CFontFaceInfo* pFont = NULL; 188 CFontFaceInfo* pFont = NULL;
189 m_FontList.GetNextAssoc(pos, bsName, (void*&)pFont); 189 m_FontList.GetNextAssoc(pos, bsName, (void*&)pFont);
190 if (!(pFont->m_Charsets & charset_flag) && charset != FXFONT_DEFAULT_CHA RSET) { 190 if (!(pFont->m_Charsets & charset_flag) && charset != FXFONT_DEFAULT_CHA RSET) {
(...skipping 19 matching lines...) Expand all
210 { 210 {
211 CFX_LinuxFontInfo* pInfo = new CFX_LinuxFontInfo; 211 CFX_LinuxFontInfo* pInfo = new CFX_LinuxFontInfo;
212 if (!pInfo->ParseFontCfg()) { 212 if (!pInfo->ParseFontCfg()) {
213 pInfo->AddPath("/usr/share/fonts"); 213 pInfo->AddPath("/usr/share/fonts");
214 pInfo->AddPath("/usr/share/X11/fonts/Type1"); 214 pInfo->AddPath("/usr/share/X11/fonts/Type1");
215 pInfo->AddPath("/usr/share/X11/fonts/TTF"); 215 pInfo->AddPath("/usr/share/X11/fonts/TTF");
216 pInfo->AddPath("/usr/local/share/fonts"); 216 pInfo->AddPath("/usr/local/share/fonts");
217 } 217 }
218 return pInfo; 218 return pInfo;
219 } 219 }
220 FX_BOOL CFX_LinuxFontInfo::ParseFontCfg() 220 bool CFX_LinuxFontInfo::ParseFontCfg()
221 { 221 {
222 return FALSE; 222 return false;
223 } 223 }
224 void CFX_GEModule::InitPlatform() 224 void CFX_GEModule::InitPlatform()
225 { 225 {
226 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault()); 226 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault());
227 } 227 }
228 void CFX_GEModule::DestroyPlatform() 228 void CFX_GEModule::DestroyPlatform()
229 { 229 {
230 } 230 }
231 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ 231 #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