OLD | NEW |
---|---|
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 "core/fxge/include/cfx_substfont.h" | 9 #include "core/fxge/include/cfx_substfont.h" |
10 #include "core/fxge/include/cfx_unicodeencoding.h" | 10 #include "core/fxge/include/cfx_unicodeencoding.h" |
(...skipping 16 matching lines...) Expand all Loading... | |
27 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); | 27 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
28 if (!pFont->LoadFontInternal(pszFontFamily, dwFontStyles, wCodePage)) { | 28 if (!pFont->LoadFontInternal(pszFontFamily, dwFontStyles, wCodePage)) { |
29 pFont->Release(); | 29 pFont->Release(); |
30 return nullptr; | 30 return nullptr; |
31 } | 31 } |
32 return pFont; | 32 return pFont; |
33 #endif | 33 #endif |
34 } | 34 } |
35 | 35 |
36 // static | 36 // static |
37 CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExtFont, | 37 CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pSrcFont, |
38 bool bExternalFont, | |
38 IFGAS_FontMgr* pFontMgr) { | 39 IFGAS_FontMgr* pFontMgr) { |
39 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); | 40 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
40 if (!pFont->LoadFontInternal(pExtFont)) { | 41 if (!pFont->LoadFontInternal(pSrcFont, bExternalFont)) { |
41 pFont->Release(); | 42 pFont->Release(); |
42 return nullptr; | 43 return nullptr; |
43 } | 44 } |
44 return pFont; | 45 return pFont; |
45 } | 46 } |
46 | 47 |
47 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 48 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
48 // static | 49 // static |
49 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer, | 50 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer, |
50 int32_t iLength, | 51 int32_t iLength, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 | 203 |
203 m_pFileRead.reset(FX_CreateFileRead(pFontStream, FALSE)); | 204 m_pFileRead.reset(FX_CreateFileRead(pFontStream, FALSE)); |
204 m_pFont = new CFX_Font; | 205 m_pFont = new CFX_Font; |
205 if (m_pFont->LoadFile(m_pFileRead.get())) | 206 if (m_pFont->LoadFile(m_pFileRead.get())) |
206 return InitFont(); | 207 return InitFont(); |
207 m_pFileRead.reset(); | 208 m_pFileRead.reset(); |
208 return FALSE; | 209 return FALSE; |
209 } | 210 } |
210 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 211 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
211 | 212 |
212 FX_BOOL CFGAS_GEFont::LoadFontInternal(CFX_Font* pExtFont) { | 213 FX_BOOL CFGAS_GEFont::LoadFontInternal(CFX_Font* pFont, bool bExternalFont) { |
213 if (m_pFont || !pExtFont) { | 214 if (m_pFont || !pFont) |
214 return FALSE; | 215 return FALSE; |
215 } | 216 |
216 m_pFont = pExtFont; | 217 m_pFont = pFont; |
217 m_bExtFont = TRUE; | 218 m_bExtFont = bExternalFont; |
Lei Zhang
2016/09/01 22:55:42
Can we name |m_bExtFont| to |m_bExternalFont| late
Wei Li
2016/09/01 23:43:30
Done.
| |
218 return InitFont(); | 219 return InitFont(); |
219 } | 220 } |
220 | 221 |
221 FX_BOOL CFGAS_GEFont::InitFont() { | 222 FX_BOOL CFGAS_GEFont::InitFont() { |
222 if (!m_pFont) | 223 if (!m_pFont) |
223 return FALSE; | 224 return FALSE; |
224 if (!m_pFontEncoding) { | 225 if (!m_pFontEncoding) { |
225 m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont)); | 226 m_pFontEncoding.reset(FX_CreateFontEncodingEx(m_pFont)); |
226 if (!m_pFontEncoding) | 227 if (!m_pFontEncoding) |
227 return FALSE; | 228 return FALSE; |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
451 } | 452 } |
452 if (m_pRectArray) { | 453 if (m_pRectArray) { |
453 m_pRectArray->RemoveAll(FALSE); | 454 m_pRectArray->RemoveAll(FALSE); |
454 } | 455 } |
455 } | 456 } |
456 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { | 457 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { |
457 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; | 458 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; |
458 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) | 459 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) |
459 : m_SubstFonts[iGlyphIndex - 1]; | 460 : m_SubstFonts[iGlyphIndex - 1]; |
460 } | 461 } |
OLD | NEW |