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

Side by Side Diff: xfa/fgas/font/fgas_gefont.cpp

Issue 2033673002: Remove dead code in CFGAS_FontMgrImp. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@rm_ifx_font
Patch Set: rebase Created 4 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 | « xfa/fgas/font/fgas_gefont.h ('k') | xfa/fgas/font/fgas_stdfontmgr.h » ('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 "xfa/fgas/font/fgas_gefont.h" 7 #include "xfa/fgas/font/fgas_gefont.h"
8 8
9 #include "xfa/fgas/crt/fgas_codepage.h" 9 #include "xfa/fgas/crt/fgas_codepage.h"
10 #include "xfa/fgas/font/fgas_fontutils.h" 10 #include "xfa/fgas/font/fgas_fontutils.h"
11 #include "xfa/fxfa/include/xfa_fontmgr.h" 11 #include "xfa/fxfa/include/xfa_fontmgr.h"
12 12
13 // static 13 // static
14 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, 14 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily,
15 uint32_t dwFontStyles, 15 uint32_t dwFontStyles,
16 uint16_t wCodePage, 16 uint16_t wCodePage,
17 IFGAS_FontMgr* pFontMgr) { 17 IFGAS_FontMgr* pFontMgr) {
18 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 18 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
19 if (NULL != pFontMgr) { 19 if (NULL != pFontMgr) {
20 return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); 20 return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily);
21 } 21 }
22 return NULL; 22 return NULL;
23 #else 23 #else
24 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); 24 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
25 if (!pFont->LoadFont(pszFontFamily, dwFontStyles, wCodePage)) { 25 if (!pFont->LoadFontInternal(pszFontFamily, dwFontStyles, wCodePage)) {
26 pFont->Release(); 26 pFont->Release();
27 return NULL; 27 return NULL;
28 } 28 }
29 return pFont; 29 return pFont;
30 #endif 30 #endif
31 } 31 }
32 32
33 // static 33 // static
34 CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExtFont, 34 CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExtFont,
35 IFGAS_FontMgr* pFontMgr, 35 IFGAS_FontMgr* pFontMgr) {
36 FX_BOOL bTakeOver) {
37 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); 36 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
38 if (!pFont->LoadFont(pExtFont, bTakeOver)) { 37 if (!pFont->LoadFontInternal(pExtFont)) {
39 pFont->Release(); 38 pFont->Release();
40 return NULL; 39 return NULL;
41 } 40 }
42 return pFont; 41 return pFont;
43 } 42 }
44 43
45 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 44 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
46 // static 45 // static
47 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer, 46 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer,
48 int32_t iLength, 47 int32_t iLength,
49 IFGAS_FontMgr* pFontMgr) { 48 IFGAS_FontMgr* pFontMgr) {
50 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); 49 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
51 if (!pFont->LoadFont(pBuffer, iLength)) { 50 if (!pFont->LoadFontInternal(pBuffer, iLength)) {
52 pFont->Release(); 51 pFont->Release();
53 return nullptr; 52 return nullptr;
54 } 53 }
55 return pFont;
56 }
57
58 // static
59 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFileName) {
60 CFGAS_GEFont* pFont = new CFGAS_GEFont(nullptr);
61 if (!pFont->LoadFontInternal(pszFileName)) {
62 pFont->Release();
63 return nullptr;
64 }
65 return pFont; 54 return pFont;
66 } 55 }
67 56
68 // static 57 // static
69 CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream, 58 CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream,
70 IFGAS_FontMgr* pFontMgr, 59 IFGAS_FontMgr* pFontMgr,
71 FX_BOOL bSaveStream) { 60 FX_BOOL bSaveStream) {
72 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); 61 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr);
73 if (!pFont->LoadFont(pFontStream, bSaveStream)) { 62 if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) {
74 pFont->Release(); 63 pFont->Release();
75 return nullptr; 64 return nullptr;
76 } 65 }
77 return pFont; 66 return pFont;
78 } 67 }
79 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 68 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
80 69
81 CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr) 70 CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr)
82 : 71 :
83 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ 72 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 148 }
160 delete this; 149 delete this;
161 } 150 }
162 } 151 }
163 CFGAS_GEFont* CFGAS_GEFont::Retain() { 152 CFGAS_GEFont* CFGAS_GEFont::Retain() {
164 ++m_iRefCount; 153 ++m_iRefCount;
165 return this; 154 return this;
166 } 155 }
167 156
168 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 157 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
169 FX_BOOL CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, 158 FX_BOOL CFGAS_GEFont::LoadFontInternal(const FX_WCHAR* pszFontFamily,
170 uint32_t dwFontStyles, 159 uint32_t dwFontStyles,
171 uint16_t wCodePage) { 160 uint16_t wCodePage) {
172 if (m_pFont) { 161 if (m_pFont) {
173 return FALSE; 162 return FALSE;
174 } 163 }
175 CFX_ByteString csFontFamily; 164 CFX_ByteString csFontFamily;
176 if (pszFontFamily != NULL) { 165 if (pszFontFamily != NULL) {
177 csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily); 166 csFontFamily = CFX_ByteString::FromUnicode(pszFontFamily);
178 } 167 }
179 uint32_t dwFlags = 0; 168 uint32_t dwFlags = 0;
180 if (dwFontStyles & FX_FONTSTYLE_FixedPitch) { 169 if (dwFontStyles & FX_FONTSTYLE_FixedPitch) {
181 dwFlags |= FXFONT_FIXED_PITCH; 170 dwFlags |= FXFONT_FIXED_PITCH;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 csFontFamily += ",Italic"; 203 csFontFamily += ",Italic";
215 } 204 }
216 m_pFont->LoadSubst(csFontFamily, TRUE, dwFlags, iWeight, 0, wCodePage); 205 m_pFont->LoadSubst(csFontFamily, TRUE, dwFlags, iWeight, 0, wCodePage);
217 FX_BOOL bRet = m_pFont->GetFace() != nullptr; 206 FX_BOOL bRet = m_pFont->GetFace() != nullptr;
218 if (bRet) { 207 if (bRet) {
219 bRet = InitFont(); 208 bRet = InitFont();
220 } 209 }
221 return bRet; 210 return bRet;
222 } 211 }
223 212
224 FX_BOOL CFGAS_GEFont::LoadFont(const uint8_t* pBuffer, int32_t length) { 213 FX_BOOL CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) {
225 if (m_pFont) { 214 if (m_pFont) {
226 return FALSE; 215 return FALSE;
227 } 216 }
228 m_pFont = new CFX_Font; 217 m_pFont = new CFX_Font;
229 FX_BOOL bRet = m_pFont->LoadEmbedded(pBuffer, length); 218 FX_BOOL bRet = m_pFont->LoadEmbedded(pBuffer, length);
230 if (bRet) { 219 if (bRet) {
231 bRet = InitFont(); 220 bRet = InitFont();
232 } 221 }
233 m_wCharSet = 0xFFFF; 222 m_wCharSet = 0xFFFF;
234 return bRet; 223 return bRet;
235 } 224 }
236 225
237 FX_BOOL CFGAS_GEFont::LoadFontInternal(const FX_WCHAR* pszFileName) { 226 FX_BOOL CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream,
238 if (m_pFont || m_pStream || m_pFileRead) { 227 FX_BOOL bSaveStream) {
239 return FALSE;
240 }
241 m_pStream = IFX_Stream::CreateStream(
242 pszFileName, FX_STREAMACCESS_Binary | FX_STREAMACCESS_Read);
243 m_pFileRead = FX_CreateFileRead(m_pStream);
244 FX_BOOL bRet = FALSE;
245 if (m_pStream && m_pFileRead) {
246 m_pFont = new CFX_Font;
247 bRet = m_pFont->LoadFile(m_pFileRead);
248 if (bRet) {
249 bRet = InitFont();
250 } else {
251 m_pFileRead->Release();
252 m_pFileRead = nullptr;
253 }
254 }
255 m_wCharSet = 0xFFFF;
256 return bRet;
257 }
258
259 FX_BOOL CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream, FX_BOOL bSaveStream) {
260 if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) { 228 if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) {
261 return FALSE; 229 return FALSE;
262 } 230 }
263 if (bSaveStream) { 231 if (bSaveStream) {
264 m_pStream = pFontStream; 232 m_pStream = pFontStream;
265 } 233 }
266 m_pFileRead = FX_CreateFileRead(pFontStream); 234 m_pFileRead = FX_CreateFileRead(pFontStream);
267 m_pFont = new CFX_Font; 235 m_pFont = new CFX_Font;
268 FX_BOOL bRet = m_pFont->LoadFile(m_pFileRead); 236 FX_BOOL bRet = m_pFont->LoadFile(m_pFileRead);
269 if (bRet) { 237 if (bRet) {
270 bRet = InitFont(); 238 bRet = InitFont();
271 } else { 239 } else {
272 m_pFileRead->Release(); 240 m_pFileRead->Release();
273 m_pFileRead = nullptr; 241 m_pFileRead = nullptr;
274 } 242 }
275 m_wCharSet = 0xFFFF; 243 m_wCharSet = 0xFFFF;
276 return bRet; 244 return bRet;
277 } 245 }
278 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 246 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
279 247
280 FX_BOOL CFGAS_GEFont::LoadFont(CFX_Font* pExtFont, FX_BOOL bTakeOver) { 248 FX_BOOL CFGAS_GEFont::LoadFontInternal(CFX_Font* pExtFont) {
281 if (m_pFont || !pExtFont) { 249 if (m_pFont || !pExtFont) {
282 return FALSE; 250 return FALSE;
283 } 251 }
284 m_pFont = pExtFont; 252 m_pFont = pExtFont;
285 FX_BOOL bRet = !!m_pFont; 253 m_bExtFont = TRUE;
286 if (bRet) {
287 m_bExtFont = !bTakeOver;
288 bRet = InitFont();
289 } else {
290 m_bExtFont = TRUE;
291 }
292 m_wCharSet = 0xFFFF; 254 m_wCharSet = 0xFFFF;
293 return bRet; 255 return InitFont();
294 } 256 }
295 257
296 FX_BOOL CFGAS_GEFont::InitFont() { 258 FX_BOOL CFGAS_GEFont::InitFont() {
297 if (!m_pFont) 259 if (!m_pFont)
298 return FALSE; 260 return FALSE;
299 if (!m_pFontEncoding) { 261 if (!m_pFontEncoding) {
300 m_pFontEncoding = FX_CreateFontEncodingEx(m_pFont); 262 m_pFontEncoding = FX_CreateFontEncodingEx(m_pFont);
301 if (!m_pFontEncoding) 263 if (!m_pFontEncoding)
302 return FALSE; 264 return FALSE;
303 } 265 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 } 496 }
535 if (m_pRectArray != NULL) { 497 if (m_pRectArray != NULL) {
536 m_pRectArray->RemoveAll(); 498 m_pRectArray->RemoveAll();
537 } 499 }
538 } 500 }
539 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { 501 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const {
540 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; 502 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24;
541 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) 503 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this)
542 : m_SubstFonts[iGlyphIndex - 1]; 504 : m_SubstFonts[iGlyphIndex - 1];
543 } 505 }
OLDNEW
« no previous file with comments | « xfa/fgas/font/fgas_gefont.h ('k') | xfa/fgas/font/fgas_stdfontmgr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698