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

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

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 6 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_ps.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 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_ 10 #if _FXM_PLATFORM_ == _FXM_PLATFORM_LINUX_
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 "AR PL UKai CN", 49 "AR PL UKai CN",
50 }; 50 };
51 static const FX_LPCSTR g_LinuxB5FontList[] = { 51 static const FX_LPCSTR g_LinuxB5FontList[] = {
52 "AR PL UMing TW Light", 52 "AR PL UMing TW Light",
53 "WenQuanYi Micro Hei", 53 "WenQuanYi Micro Hei",
54 "AR PL UKai TW", 54 "AR PL UKai TW",
55 }; 55 };
56 static const FX_LPCSTR g_LinuxHGFontList[] = { 56 static const FX_LPCSTR g_LinuxHGFontList[] = {
57 "UnDotum", 57 "UnDotum",
58 }; 58 };
59 static FX_INT32 GetJapanesePreference(FX_LPCSTR facearr, int weight, int picth_f amily) 59 static int32_t GetJapanesePreference(FX_LPCSTR facearr, int weight, int picth_fa mily)
60 { 60 {
61 CFX_ByteString face = facearr; 61 CFX_ByteString face = facearr;
62 if (face.Find("Gothic") >= 0 || face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e" ) >= 0) { 62 if (face.Find("Gothic") >= 0 || face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e" ) >= 0) {
63 if (face.Find("PGothic") >= 0 || face.Find("\x82\x6f\x83\x53\x83\x56\x83 \x62\x83\x4e") >= 0) { 63 if (face.Find("PGothic") >= 0 || face.Find("\x82\x6f\x83\x53\x83\x56\x83 \x62\x83\x4e") >= 0) {
64 return 0; 64 return 0;
65 } else { 65 } else {
66 return 1; 66 return 1;
67 } 67 }
68 } else if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) { 68 } else if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) {
69 if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") > = 0) { 69 if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") > = 0) {
(...skipping 17 matching lines...) Expand all
87 bExact = TRUE; 87 bExact = TRUE;
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 FX_LPVOID p = NULL; 93 FX_LPVOID p = NULL;
94 FX_BOOL bCJK = TRUE; 94 FX_BOOL bCJK = TRUE;
95 switch (charset) { 95 switch (charset) {
96 case FXFONT_SHIFTJIS_CHARSET: { 96 case FXFONT_SHIFTJIS_CHARSET: {
97 FX_INT32 index = GetJapanesePreference(cstr_face, weight, pitch_ family); 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 (FX_INT32 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 }
105 } 105 }
106 break; 106 break;
107 case FXFONT_GB2312_CHARSET: { 107 case FXFONT_GB2312_CHARSET: {
108 static FX_INT32 s_gbCount = sizeof(g_LinuxGbFontList) / sizeof(F X_LPCSTR); 108 static int32_t s_gbCount = sizeof(g_LinuxGbFontList) / sizeof(FX _LPCSTR);
109 for (FX_INT32 i = 0; i < s_gbCount; i++) 109 for (int32_t i = 0; i < s_gbCount; i++)
110 if (m_FontList.Lookup(g_LinuxGbFontList[i], p)) { 110 if (m_FontList.Lookup(g_LinuxGbFontList[i], p)) {
111 return p; 111 return p;
112 } 112 }
113 } 113 }
114 break; 114 break;
115 case FXFONT_CHINESEBIG5_CHARSET: { 115 case FXFONT_CHINESEBIG5_CHARSET: {
116 static FX_INT32 s_b5Count = sizeof(g_LinuxB5FontList) / sizeof(F X_LPCSTR); 116 static int32_t s_b5Count = sizeof(g_LinuxB5FontList) / sizeof(FX _LPCSTR);
117 for (FX_INT32 i = 0; i < s_b5Count; i++) 117 for (int32_t i = 0; i < s_b5Count; i++)
118 if (m_FontList.Lookup(g_LinuxB5FontList[i], p)) { 118 if (m_FontList.Lookup(g_LinuxB5FontList[i], p)) {
119 return p; 119 return p;
120 } 120 }
121 } 121 }
122 break; 122 break;
123 case FXFONT_HANGEUL_CHARSET: { 123 case FXFONT_HANGEUL_CHARSET: {
124 static FX_INT32 s_hgCount = sizeof(g_LinuxHGFontList) / sizeof(F X_LPCSTR); 124 static int32_t s_hgCount = sizeof(g_LinuxHGFontList) / sizeof(FX _LPCSTR);
125 for (FX_INT32 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)) {
(...skipping 14 matching lines...) Expand all
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 FX_INT32 _LinuxGetSimilarValue(int weight, FX_BOOL bItalic, int pitch_fam ily, FX_DWORD style) 160 static int32_t _LinuxGetSimilarValue(int weight, FX_BOOL bItalic, int pitch_fami ly, FX_DWORD style)
161 { 161 {
162 FX_INT32 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, FX_LPCSTR family, FX_BOOL bMatchName) 180 void* CFX_LinuxFontInfo::FindFont(int weight, FX_BOOL bItalic, int charset, int pitch_family, FX_LPCSTR family, FX_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 FX_INT32 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, (FX_LPVOID&)pFont); 189 m_FontList.GetNextAssoc(pos, bsName, (FX_LPVOID&)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) {
191 continue; 191 continue;
192 } 192 }
193 FX_INT32 iSimilarValue = 0; 193 int32_t iSimilarValue = 0;
194 FX_INT32 index = bsName.Find(family); 194 int32_t index = bsName.Find(family);
195 if (bMatchName && index < 0) { 195 if (bMatchName && index < 0) {
196 continue; 196 continue;
197 } 197 }
198 if (!bMatchName && index > 0) { 198 if (!bMatchName && index > 0) {
199 iSimilarValue += 64; 199 iSimilarValue += 64;
200 } 200 }
201 iSimilarValue = _LinuxGetSimilarValue(weight, bItalic, pitch_family, pFo nt->m_Styles); 201 iSimilarValue = _LinuxGetSimilarValue(weight, bItalic, pitch_family, pFo nt->m_Styles);
202 if (iSimilarValue > iBestSimilar) { 202 if (iSimilarValue > iBestSimilar) {
203 iBestSimilar = iSimilarValue; 203 iBestSimilar = iSimilarValue;
204 pFind = pFont; 204 pFind = pFont;
(...skipping 20 matching lines...) Expand all
225 return FALSE; 225 return FALSE;
226 } 226 }
227 void CFX_GEModule::InitPlatform() 227 void CFX_GEModule::InitPlatform()
228 { 228 {
229 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault()); 229 m_pFontMgr->SetSystemFontInfo(IFX_SystemFontInfo::CreateDefault());
230 } 230 }
231 void CFX_GEModule::DestroyPlatform() 231 void CFX_GEModule::DestroyPlatform()
232 { 232 {
233 } 233 }
234 #endif 234 #endif
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_fontmap.cpp ('k') | core/src/fxge/ge/fx_ge_ps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698