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

Side by Side Diff: core/src/fxge/win32/fx_win32_device.cpp

Issue 1258283004: Merge to XFA: Name IFX_SysFontInfo subclasses consistently. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
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 | « no previous file | fpdfsdk/src/fpdf_sysfontinfo.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 8
9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ 9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_
10 #include <crtdbg.h> 10 #include <crtdbg.h>
11 11
12 #include "../../../include/fxcodec/fx_codec.h" 12 #include "../../../include/fxcodec/fx_codec.h"
13 #include "../../../include/fxge/fx_freetype.h" 13 #include "../../../include/fxge/fx_freetype.h"
14 #include "../../../include/fxge/fx_ge_win32.h" 14 #include "../../../include/fxge/fx_ge_win32.h"
15 #include "../agg/include/fx_agg_driver.h" 15 #include "../agg/include/fx_agg_driver.h"
16 #include "../dib/dib_int.h" 16 #include "../dib/dib_int.h"
17 #include "../ge/text_int.h" 17 #include "../ge/text_int.h"
18 #include "dwrite_int.h" 18 #include "dwrite_int.h"
19 #include "win32_int.h" 19 #include "win32_int.h"
20 20
21 class CWin32FontInfo final : public IFX_SystemFontInfo 21 class CFX_Win32FontInfo final : public IFX_SystemFontInfo
22 { 22 {
23 public: 23 public:
24 CWin32FontInfo(); 24 CFX_Win32FontInfo();
25 ~CWin32FontInfo(); 25 ~CFX_Win32FontInfo();
26 virtual void Release(); 26 virtual void Release();
27 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper); 27 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper);
28 virtual void* MapFont(int weight, FX_BOOL bItalic, int charset , int pitch_family, const FX_CHAR* face, int& iExact); 28 virtual void* MapFont(int weight, FX_BOOL bItalic, int charset , int pitch_family, const FX_CHAR* face, int& iExact);
29 virtual void* GetFont(const FX_CHAR* face) 29 virtual void* GetFont(const FX_CHAR* face)
30 { 30 {
31 return NULL; 31 return NULL;
32 } 32 }
33 virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, uint8_t* buffer , FX_DWORD size); 33 virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, uint8_t* buffer , FX_DWORD size);
34 virtual void DeleteFont(void* hFont); 34 virtual void DeleteFont(void* hFont);
35 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name); 35 virtual FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name);
36 virtual FX_BOOL GetFontCharset(void* hFont, int& charset); 36 virtual FX_BOOL GetFontCharset(void* hFont, int& charset);
37 FX_BOOL IsOpenTypeFromDiv(const LOGFONTA *plf); 37 FX_BOOL IsOpenTypeFromDiv(const LOGFONTA *plf);
38 FX_BOOL IsSupportFontFormDiv(const LOGFONTA* plf ); 38 FX_BOOL IsSupportFontFormDiv(const LOGFONTA* plf );
39 void AddInstalledFont(const LOGFONTA *plf, FX _DWORD FontType); 39 void AddInstalledFont(const LOGFONTA *plf, FX _DWORD FontType);
40 void GetGBPreference(CFX_ByteString& face, in t weight, int picth_family); 40 void GetGBPreference(CFX_ByteString& face, in t weight, int picth_family);
41 void GetJapanesePreference(CFX_ByteString& fa ce, int weight, int picth_family); 41 void GetJapanesePreference(CFX_ByteString& fa ce, int weight, int picth_family);
42 CFX_ByteString FindFont(const CFX_ByteString& name); 42 CFX_ByteString FindFont(const CFX_ByteString& name);
43 HDC m_hDC; 43 HDC m_hDC;
44 CFX_FontMapper* m_pMapper; 44 CFX_FontMapper* m_pMapper;
45 CFX_ByteString m_LastFamily; 45 CFX_ByteString m_LastFamily;
46 CFX_ByteString m_KaiTi, m_FangSong; 46 CFX_ByteString m_KaiTi, m_FangSong;
47 }; 47 };
48 CWin32FontInfo::CWin32FontInfo() 48 CFX_Win32FontInfo::CFX_Win32FontInfo()
49 { 49 {
50 m_hDC = CreateCompatibleDC(NULL); 50 m_hDC = CreateCompatibleDC(NULL);
51 } 51 }
52 CWin32FontInfo::~CWin32FontInfo() 52 CFX_Win32FontInfo::~CFX_Win32FontInfo()
53 { 53 {
54 m_pMapper = NULL; 54 m_pMapper = NULL;
55 } 55 }
56 void CWin32FontInfo::Release() 56 void CFX_Win32FontInfo::Release()
57 { 57 {
58 DeleteDC(m_hDC); 58 DeleteDC(m_hDC);
59 delete this; 59 delete this;
60 } 60 }
61 #define TT_MAKE_TAG(x1, x2, x3, x4) (((FX_DWORD)x1<<24)|((FX_DWORD)x2<<16)|((FX_ DWORD)x3<<8)|(FX_DWORD)x4) 61 #define TT_MAKE_TAG(x1, x2, x3, x4) (((FX_DWORD)x1<<24)|((FX_DWORD)x2<<16)|((FX_ DWORD)x3<<8)|(FX_DWORD)x4)
62 FX_BOOL CWin32FontInfo::IsOpenTypeFromDiv(const LOGFONTA *plf) 62 FX_BOOL CFX_Win32FontInfo::IsOpenTypeFromDiv(const LOGFONTA *plf)
63 { 63 {
64 HFONT hFont = CreateFontIndirectA(plf); 64 HFONT hFont = CreateFontIndirectA(plf);
65 FX_BOOL ret = FALSE; 65 FX_BOOL ret = FALSE;
66 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0); 66 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0);
67 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) { 67 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) {
68 FX_DWORD lVersion = 0; 68 FX_DWORD lVersion = 0;
69 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(FX_DWORD)); 69 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(FX_DWORD));
70 lVersion = (((FX_DWORD)(uint8_t)(lVersion)) << 24) | ((FX_DWORD)((uint8_ t)(lVersion >> 8))) << 16 | 70 lVersion = (((FX_DWORD)(uint8_t)(lVersion)) << 24) | ((FX_DWORD)((uint8_ t)(lVersion >> 8))) << 16 |
71 ((FX_DWORD)((uint8_t)(lVersion >> 16))) << 8 | ((uint8_t)(lVe rsion >> 24)); 71 ((FX_DWORD)((uint8_t)(lVersion >> 16))) << 8 | ((uint8_t)(lVe rsion >> 24));
72 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') || 72 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') ||
73 lVersion == 0x00010000 || 73 lVersion == 0x00010000 ||
74 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') || 74 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') ||
75 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') || 75 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') ||
76 lVersion == 0x00020000) { 76 lVersion == 0x00020000) {
77 ret = TRUE; 77 ret = TRUE;
78 } 78 }
79 } 79 }
80 DeleteFont(hFont); 80 DeleteFont(hFont);
81 return ret; 81 return ret;
82 } 82 }
83 FX_BOOL CWin32FontInfo::IsSupportFontFormDiv(const LOGFONTA* plf) 83 FX_BOOL CFX_Win32FontInfo::IsSupportFontFormDiv(const LOGFONTA* plf)
84 { 84 {
85 HFONT hFont = CreateFontIndirectA(plf); 85 HFONT hFont = CreateFontIndirectA(plf);
86 FX_BOOL ret = FALSE; 86 FX_BOOL ret = FALSE;
87 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0); 87 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0);
88 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) { 88 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) {
89 FX_DWORD lVersion = 0; 89 FX_DWORD lVersion = 0;
90 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(FX_DWORD)); 90 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(FX_DWORD));
91 lVersion = (((FX_DWORD)(uint8_t)(lVersion)) << 24) | ((FX_DWORD)((uint8_ t)(lVersion >> 8))) << 16 | 91 lVersion = (((FX_DWORD)(uint8_t)(lVersion)) << 24) | ((FX_DWORD)((uint8_ t)(lVersion >> 8))) << 16 |
92 ((FX_DWORD)((uint8_t)(lVersion >> 16))) << 8 | ((uint8_t)(lVe rsion >> 24)); 92 ((FX_DWORD)((uint8_t)(lVersion >> 16))) << 8 | ((uint8_t)(lVe rsion >> 24));
93 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') || 93 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') ||
94 lVersion == 0x00010000 || 94 lVersion == 0x00010000 ||
95 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') || 95 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') ||
96 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') || 96 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') ||
97 lVersion == 0x00020000) { 97 lVersion == 0x00020000) {
98 ret = TRUE; 98 ret = TRUE;
99 } else if ((lVersion & 0xFFFF0000) == TT_MAKE_TAG(0x80, 0x01, 0x00, 0x00 ) || 99 } else if ((lVersion & 0xFFFF0000) == TT_MAKE_TAG(0x80, 0x01, 0x00, 0x00 ) ||
100 (lVersion & 0xFFFF0000) == TT_MAKE_TAG('%', '!', 0, 0)) { 100 (lVersion & 0xFFFF0000) == TT_MAKE_TAG('%', '!', 0, 0)) {
101 ret = TRUE; 101 ret = TRUE;
102 } 102 }
103 } 103 }
104 DeleteFont(hFont); 104 DeleteFont(hFont);
105 return ret; 105 return ret;
106 } 106 }
107 void CWin32FontInfo::AddInstalledFont(const LOGFONTA *plf, FX_DWORD FontType) 107 void CFX_Win32FontInfo::AddInstalledFont(const LOGFONTA *plf, FX_DWORD FontType)
108 { 108 {
109 CFX_ByteString name(plf->lfFaceName, -1); 109 CFX_ByteString name(plf->lfFaceName, -1);
110 if (name[0] == '@') { 110 if (name[0] == '@') {
111 return; 111 return;
112 } 112 }
113 if (name == m_LastFamily) { 113 if (name == m_LastFamily) {
114 m_pMapper->AddInstalledFont(name, plf->lfCharSet); 114 m_pMapper->AddInstalledFont(name, plf->lfCharSet);
115 return; 115 return;
116 } 116 }
117 if (!(FontType & TRUETYPE_FONTTYPE) && !(FontType & DEVICE_FONTTYPE)) { 117 if (!(FontType & TRUETYPE_FONTTYPE) && !(FontType & DEVICE_FONTTYPE)) {
118 return; 118 return;
119 } 119 }
120 if (!(FontType & TRUETYPE_FONTTYPE)) { 120 if (!(FontType & TRUETYPE_FONTTYPE)) {
121 if (!IsSupportFontFormDiv(plf)) { 121 if (!IsSupportFontFormDiv(plf)) {
122 return; 122 return;
123 } 123 }
124 } 124 }
125 m_pMapper->AddInstalledFont(name, plf->lfCharSet); 125 m_pMapper->AddInstalledFont(name, plf->lfCharSet);
126 m_LastFamily = name; 126 m_LastFamily = name;
127 } 127 }
128 static int CALLBACK FontEnumProc( 128 static int CALLBACK FontEnumProc(
129 const LOGFONTA *plf, 129 const LOGFONTA *plf,
130 const TEXTMETRICA *lpntme, 130 const TEXTMETRICA *lpntme,
131 FX_DWORD FontType, 131 FX_DWORD FontType,
132 LPARAM lParam 132 LPARAM lParam
133 ) 133 )
134 { 134 {
135 CWin32FontInfo* pFontInfo = (CWin32FontInfo*)lParam; 135 CFX_Win32FontInfo* pFontInfo = (CFX_Win32FontInfo*)lParam;
136 if (pFontInfo->m_pMapper->GetFontEnumerator()) { 136 if (pFontInfo->m_pMapper->GetFontEnumerator()) {
137 pFontInfo->m_pMapper->GetFontEnumerator()->HitFont(); 137 pFontInfo->m_pMapper->GetFontEnumerator()->HitFont();
138 } 138 }
139 pFontInfo->AddInstalledFont(plf, FontType); 139 pFontInfo->AddInstalledFont(plf, FontType);
140 return 1; 140 return 1;
141 } 141 }
142 FX_BOOL CWin32FontInfo::EnumFontList(CFX_FontMapper* pMapper) 142 FX_BOOL CFX_Win32FontInfo::EnumFontList(CFX_FontMapper* pMapper)
143 { 143 {
144 m_pMapper = pMapper; 144 m_pMapper = pMapper;
145 LOGFONTA lf; 145 LOGFONTA lf;
146 FXSYS_memset(&lf, 0, sizeof(LOGFONTA)); 146 FXSYS_memset(&lf, 0, sizeof(LOGFONTA));
147 lf.lfCharSet = DEFAULT_CHARSET; 147 lf.lfCharSet = DEFAULT_CHARSET;
148 lf.lfFaceName[0] = 0; 148 lf.lfFaceName[0] = 0;
149 lf.lfPitchAndFamily = 0; 149 lf.lfPitchAndFamily = 0;
150 EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t)this , 0); 150 EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t)this , 0);
151 if (pMapper->GetFontEnumerator()) { 151 if (pMapper->GetFontEnumerator()) {
152 pMapper->GetFontEnumerator()->Finish(); 152 pMapper->GetFontEnumerator()->Finish();
(...skipping 20 matching lines...) Expand all
173 {"Courier-Oblique", "Courier New", FALSE, TRUE}, 173 {"Courier-Oblique", "Courier New", FALSE, TRUE},
174 {"Helvetica", "Arial", FALSE, FALSE}, 174 {"Helvetica", "Arial", FALSE, FALSE},
175 {"Helvetica-Bold", "Arial", TRUE, FALSE}, 175 {"Helvetica-Bold", "Arial", TRUE, FALSE},
176 {"Helvetica-BoldOblique", "Arial", TRUE, TRUE}, 176 {"Helvetica-BoldOblique", "Arial", TRUE, TRUE},
177 {"Helvetica-Oblique", "Arial", FALSE, TRUE}, 177 {"Helvetica-Oblique", "Arial", FALSE, TRUE},
178 {"Times-Roman", "Times New Roman", FALSE, FALSE}, 178 {"Times-Roman", "Times New Roman", FALSE, FALSE},
179 {"Times-Bold", "Times New Roman", TRUE, FALSE}, 179 {"Times-Bold", "Times New Roman", TRUE, FALSE},
180 {"Times-BoldItalic", "Times New Roman", TRUE, TRUE}, 180 {"Times-BoldItalic", "Times New Roman", TRUE, TRUE},
181 {"Times-Italic", "Times New Roman", FALSE, TRUE}, 181 {"Times-Italic", "Times New Roman", FALSE, TRUE},
182 }; 182 };
183 CFX_ByteString CWin32FontInfo::FindFont(const CFX_ByteString& name) 183 CFX_ByteString CFX_Win32FontInfo::FindFont(const CFX_ByteString& name)
184 { 184 {
185 if (m_pMapper == NULL) { 185 if (m_pMapper == NULL) {
186 return name; 186 return name;
187 } 187 }
188 int nFonts = m_pMapper->m_InstalledTTFonts.GetSize(); 188 int nFonts = m_pMapper->m_InstalledTTFonts.GetSize();
189 for (int i = 0; i < nFonts; i ++) { 189 for (int i = 0; i < nFonts; i ++) {
190 CFX_ByteString thisname = m_pMapper->m_InstalledTTFonts[i]; 190 CFX_ByteString thisname = m_pMapper->m_InstalledTTFonts[i];
191 if (thisname[0] == ' ') { 191 if (thisname[0] == ' ') {
192 if (thisname.Mid(1, name.GetLength()) == name) { 192 if (thisname.Mid(1, name.GetLength()) == name) {
193 return m_pMapper->m_InstalledTTFonts[i + 1]; 193 return m_pMapper->m_InstalledTTFonts[i + 1];
(...skipping 23 matching lines...) Expand all
217 int size = sizeof g_JpFontNameMap; 217 int size = sizeof g_JpFontNameMap;
218 void* pFontnameMap = (void*)g_JpFontNameMap; 218 void* pFontnameMap = (void*)g_JpFontNameMap;
219 _FontNameMap* found = (_FontNameMap*)FXSYS_bsearch(name.c_str(), pFontnameMa p, 219 _FontNameMap* found = (_FontNameMap*)FXSYS_bsearch(name.c_str(), pFontnameMa p,
220 size / sizeof (_FontNameMap), sizeof (_FontNameMap), c ompareString); 220 size / sizeof (_FontNameMap), sizeof (_FontNameMap), c ompareString);
221 if (found == NULL) { 221 if (found == NULL) {
222 return FALSE; 222 return FALSE;
223 } 223 }
224 name = found->m_pSubFontName; 224 name = found->m_pSubFontName;
225 return TRUE; 225 return TRUE;
226 } 226 }
227 void CWin32FontInfo::GetGBPreference(CFX_ByteString& face, int weight, int picth _family) 227 void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face, int weight, int pi cth_family)
228 { 228 {
229 if (face.Find("KaiTi") >= 0 || face.Find("\xbf\xac") >= 0) { 229 if (face.Find("KaiTi") >= 0 || face.Find("\xbf\xac") >= 0) {
230 if (m_KaiTi.IsEmpty()) { 230 if (m_KaiTi.IsEmpty()) {
231 m_KaiTi = FindFont("KaiTi"); 231 m_KaiTi = FindFont("KaiTi");
232 if (m_KaiTi.IsEmpty()) { 232 if (m_KaiTi.IsEmpty()) {
233 m_KaiTi = "SimSun"; 233 m_KaiTi = "SimSun";
234 } 234 }
235 } 235 }
236 face = m_KaiTi; 236 face = m_KaiTi;
237 } else if (face.Find("FangSong") >= 0 || face.Find("\xb7\xc2\xcb\xce") >= 0) { 237 } else if (face.Find("FangSong") >= 0 || face.Find("\xb7\xc2\xcb\xce") >= 0) {
238 if (m_FangSong.IsEmpty()) { 238 if (m_FangSong.IsEmpty()) {
239 m_FangSong = FindFont("FangSong"); 239 m_FangSong = FindFont("FangSong");
240 if (m_FangSong.IsEmpty()) { 240 if (m_FangSong.IsEmpty()) {
241 m_FangSong = "SimSun"; 241 m_FangSong = "SimSun";
242 } 242 }
243 } 243 }
244 face = m_FangSong; 244 face = m_FangSong;
245 } else if (face.Find("SimSun") >= 0 || face.Find("\xcb\xce") >= 0) { 245 } else if (face.Find("SimSun") >= 0 || face.Find("\xcb\xce") >= 0) {
246 face = "SimSun"; 246 face = "SimSun";
247 } else if (face.Find("SimHei") >= 0 || face.Find("\xba\xda") >= 0) { 247 } else if (face.Find("SimHei") >= 0 || face.Find("\xba\xda") >= 0) {
248 face = "SimHei"; 248 face = "SimHei";
249 } else if (!(picth_family & FF_ROMAN) && weight > 550) { 249 } else if (!(picth_family & FF_ROMAN) && weight > 550) {
250 face = "SimHei"; 250 face = "SimHei";
251 } else { 251 } else {
252 face = "SimSun"; 252 face = "SimSun";
253 } 253 }
254 } 254 }
255 void CWin32FontInfo::GetJapanesePreference(CFX_ByteString& face, int weight, int picth_family) 255 void CFX_Win32FontInfo::GetJapanesePreference(CFX_ByteString& face, int weight, int picth_family)
256 { 256 {
257 if (face.Find("Gothic") >= 0 || face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e" ) >= 0) { 257 if (face.Find("Gothic") >= 0 || face.Find("\x83\x53\x83\x56\x83\x62\x83\x4e" ) >= 0) {
258 if (face.Find("PGothic") >= 0 || face.Find("\x82\x6f\x83\x53\x83\x56\x83 \x62\x83\x4e") >= 0) { 258 if (face.Find("PGothic") >= 0 || face.Find("\x82\x6f\x83\x53\x83\x56\x83 \x62\x83\x4e") >= 0) {
259 face = "MS PGothic"; 259 face = "MS PGothic";
260 } else if (face.Find("UI Gothic") >= 0) { 260 } else if (face.Find("UI Gothic") >= 0) {
261 face = "MS UI Gothic"; 261 face = "MS UI Gothic";
262 } else { 262 } else {
263 if (face.Find("HGSGothicM") >= 0 || face.Find("HGMaruGothicMPRO") >= 0) { 263 if (face.Find("HGSGothicM") >= 0 || face.Find("HGMaruGothicMPRO") >= 0) {
264 face = "MS PGothic"; 264 face = "MS PGothic";
265 } else { 265 } else {
(...skipping 12 matching lines...) Expand all
278 } 278 }
279 if (_GetSubFontName(face)) { 279 if (_GetSubFontName(face)) {
280 return; 280 return;
281 } 281 }
282 if (!(picth_family & FF_ROMAN) && weight > 400) { 282 if (!(picth_family & FF_ROMAN) && weight > 400) {
283 face = "MS PGothic"; 283 face = "MS PGothic";
284 } else { 284 } else {
285 face = "MS PMincho"; 285 face = "MS PMincho";
286 } 286 }
287 } 287 }
288 void* CWin32FontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pitc h_family, const FX_CHAR* cstr_face, int& iExact) 288 void* CFX_Win32FontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int p itch_family, const FX_CHAR* cstr_face, int& iExact)
289 { 289 {
290 CFX_ByteString face = cstr_face; 290 CFX_ByteString face = cstr_face;
291 int iBaseFont; 291 int iBaseFont;
292 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++) 292 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++)
293 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) { 293 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) {
294 face = Base14Substs[iBaseFont].m_pWinName; 294 face = Base14Substs[iBaseFont].m_pWinName;
295 weight = Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL; 295 weight = Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL;
296 bItalic = Base14Substs[iBaseFont].m_bItalic; 296 bItalic = Base14Substs[iBaseFont].m_bItalic;
297 iExact = TRUE; 297 iExact = TRUE;
298 break; 298 break;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 face = "MingLiU"; 351 face = "MingLiU";
352 } else { 352 } else {
353 face = "PMingLiU"; 353 face = "PMingLiU";
354 } 354 }
355 break; 355 break;
356 } 356 }
357 hFont = ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0, charset, OUT_TT_O NLY_PRECIS, 357 hFont = ::CreateFontA(-10, 0, 0, 0, weight, bItalic, 0, 0, charset, OUT_TT_O NLY_PRECIS,
358 0, 0, subst_pitch_family, face); 358 0, 0, subst_pitch_family, face);
359 return hFont; 359 return hFont;
360 } 360 }
361 void CWin32FontInfo::DeleteFont(void* hFont) 361 void CFX_Win32FontInfo::DeleteFont(void* hFont)
362 { 362 {
363 ::DeleteObject(hFont); 363 ::DeleteObject(hFont);
364 } 364 }
365 FX_DWORD CWin32FontInfo::GetFontData(void* hFont, FX_DWORD table, uint8_t* buffe r, FX_DWORD size) 365 FX_DWORD CFX_Win32FontInfo::GetFontData(void* hFont, FX_DWORD table, uint8_t* bu ffer, FX_DWORD size)
366 { 366 {
367 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); 367 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
368 table = FXDWORD_FROM_MSBFIRST(table); 368 table = FXDWORD_FROM_MSBFIRST(table);
369 size = ::GetFontData(m_hDC, table, 0, buffer, size); 369 size = ::GetFontData(m_hDC, table, 0, buffer, size);
370 ::SelectObject(m_hDC, hOldFont); 370 ::SelectObject(m_hDC, hOldFont);
371 if (size == GDI_ERROR) { 371 if (size == GDI_ERROR) {
372 return 0; 372 return 0;
373 } 373 }
374 return size; 374 return size;
375 } 375 }
376 FX_BOOL CWin32FontInfo::GetFaceName(void* hFont, CFX_ByteString& name) 376 FX_BOOL CFX_Win32FontInfo::GetFaceName(void* hFont, CFX_ByteString& name)
377 { 377 {
378 char facebuf[100]; 378 char facebuf[100];
379 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); 379 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
380 int ret = ::GetTextFaceA(m_hDC, 100, facebuf); 380 int ret = ::GetTextFaceA(m_hDC, 100, facebuf);
381 ::SelectObject(m_hDC, hOldFont); 381 ::SelectObject(m_hDC, hOldFont);
382 if (ret == 0) { 382 if (ret == 0) {
383 return FALSE; 383 return FALSE;
384 } 384 }
385 name = facebuf; 385 name = facebuf;
386 return TRUE; 386 return TRUE;
387 } 387 }
388 FX_BOOL CWin32FontInfo::GetFontCharset(void* hFont, int& charset) 388 FX_BOOL CFX_Win32FontInfo::GetFontCharset(void* hFont, int& charset)
389 { 389 {
390 TEXTMETRIC tm; 390 TEXTMETRIC tm;
391 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); 391 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
392 ::GetTextMetrics(m_hDC, &tm); 392 ::GetTextMetrics(m_hDC, &tm);
393 ::SelectObject(m_hDC, hOldFont); 393 ::SelectObject(m_hDC, hOldFont);
394 charset = tm.tmCharSet; 394 charset = tm.tmCharSet;
395 return TRUE; 395 return TRUE;
396 } 396 }
397 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() 397 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault()
398 { 398 {
399 return FX_NEW CWin32FontInfo; 399 return new CFX_Win32FontInfo;
400 } 400 }
401 void CFX_GEModule::InitPlatform() 401 void CFX_GEModule::InitPlatform()
402 { 402 {
403 CWin32Platform* pPlatformData = FX_NEW CWin32Platform; 403 CWin32Platform* pPlatformData = FX_NEW CWin32Platform;
404 if (!pPlatformData) { 404 if (!pPlatformData) {
405 return; 405 return;
406 } 406 }
407 OSVERSIONINFO ver; 407 OSVERSIONINFO ver;
408 ver.dwOSVersionInfoSize = sizeof(ver); 408 ver.dwOSVersionInfoSize = sizeof(ver);
409 GetVersionEx(&ver); 409 GetVersionEx(&ver);
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
1209 SelectObject(m_hDC, m_hOldBitmap); 1209 SelectObject(m_hDC, m_hOldBitmap);
1210 DeleteDC(m_hDC); 1210 DeleteDC(m_hDC);
1211 } 1211 }
1212 if (m_hBitmap) { 1212 if (m_hBitmap) {
1213 DeleteObject(m_hBitmap); 1213 DeleteObject(m_hBitmap);
1214 } 1214 }
1215 delete GetBitmap(); 1215 delete GetBitmap();
1216 } 1216 }
1217 1217
1218 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ 1218 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
OLDNEW
« no previous file with comments | « no previous file | fpdfsdk/src/fpdf_sysfontinfo.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698