| 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 <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "core/fxge/cfx_substfont.h" | 12 #include "core/fxge/cfx_substfont.h" |
| 13 #include "core/fxge/cfx_unicodeencoding.h" | 13 #include "core/fxge/cfx_unicodeencoding.h" |
| 14 #include "core/fxge/cfx_unicodeencodingex.h" | 14 #include "core/fxge/cfx_unicodeencodingex.h" |
| 15 #include "xfa/fgas/crt/fgas_codepage.h" | 15 #include "xfa/fgas/crt/fgas_codepage.h" |
| 16 #include "xfa/fgas/font/fgas_fontutils.h" | 16 #include "xfa/fgas/font/fgas_fontutils.h" |
| 17 #include "xfa/fxfa/xfa_fontmgr.h" | 17 #include "xfa/fxfa/xfa_fontmgr.h" |
| 18 | 18 |
| 19 // static | 19 // static |
| 20 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, | 20 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const FX_WCHAR* pszFontFamily, |
| 21 uint32_t dwFontStyles, | 21 uint32_t dwFontStyles, |
| 22 uint16_t wCodePage, | 22 uint16_t wCodePage, |
| 23 IFGAS_FontMgr* pFontMgr) { | 23 CFGAS_FontMgr* pFontMgr) { |
| 24 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 24 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 25 if (pFontMgr) | 25 if (pFontMgr) |
| 26 return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); | 26 return pFontMgr->GetFontByCodePage(wCodePage, dwFontStyles, pszFontFamily); |
| 27 return nullptr; | 27 return nullptr; |
| 28 #else | 28 #else |
| 29 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); | 29 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
| 30 if (!pFont->LoadFontInternal(pszFontFamily, dwFontStyles, wCodePage)) { | 30 if (!pFont->LoadFontInternal(pszFontFamily, dwFontStyles, wCodePage)) { |
| 31 pFont->Release(); | 31 pFont->Release(); |
| 32 return nullptr; | 32 return nullptr; |
| 33 } | 33 } |
| 34 return pFont; | 34 return pFont; |
| 35 #endif | 35 #endif |
| 36 } | 36 } |
| 37 | 37 |
| 38 // static | 38 // static |
| 39 CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont, | 39 CFGAS_GEFont* CFGAS_GEFont::LoadFont(CFX_Font* pExternalFont, |
| 40 IFGAS_FontMgr* pFontMgr) { | 40 CFGAS_FontMgr* pFontMgr) { |
| 41 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); | 41 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
| 42 if (!pFont->LoadFontInternal(pExternalFont)) { | 42 if (!pFont->LoadFontInternal(pExternalFont)) { |
| 43 pFont->Release(); | 43 pFont->Release(); |
| 44 return nullptr; | 44 return nullptr; |
| 45 } | 45 } |
| 46 return pFont; | 46 return pFont; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // static | 49 // static |
| 50 CFGAS_GEFont* CFGAS_GEFont::LoadFont(std::unique_ptr<CFX_Font> pInternalFont, | 50 CFGAS_GEFont* CFGAS_GEFont::LoadFont(std::unique_ptr<CFX_Font> pInternalFont, |
| 51 IFGAS_FontMgr* pFontMgr) { | 51 CFGAS_FontMgr* pFontMgr) { |
| 52 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); | 52 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
| 53 if (!pFont->LoadFontInternal(std::move(pInternalFont))) { | 53 if (!pFont->LoadFontInternal(std::move(pInternalFont))) { |
| 54 pFont->Release(); | 54 pFont->Release(); |
| 55 return nullptr; | 55 return nullptr; |
| 56 } | 56 } |
| 57 return pFont; | 57 return pFont; |
| 58 } | 58 } |
| 59 | 59 |
| 60 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 60 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 61 // static | 61 // static |
| 62 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer, | 62 CFGAS_GEFont* CFGAS_GEFont::LoadFont(const uint8_t* pBuffer, |
| 63 int32_t iLength, | 63 int32_t iLength, |
| 64 IFGAS_FontMgr* pFontMgr) { | 64 CFGAS_FontMgr* pFontMgr) { |
| 65 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); | 65 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
| 66 if (!pFont->LoadFontInternal(pBuffer, iLength)) { | 66 if (!pFont->LoadFontInternal(pBuffer, iLength)) { |
| 67 pFont->Release(); | 67 pFont->Release(); |
| 68 return nullptr; | 68 return nullptr; |
| 69 } | 69 } |
| 70 return pFont; | 70 return pFont; |
| 71 } | 71 } |
| 72 | 72 |
| 73 // static | 73 // static |
| 74 CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream, | 74 CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream, |
| 75 IFGAS_FontMgr* pFontMgr, | 75 CFGAS_FontMgr* pFontMgr, |
| 76 bool bSaveStream) { | 76 bool bSaveStream) { |
| 77 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); | 77 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
| 78 if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) { | 78 if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) { |
| 79 pFont->Release(); | 79 pFont->Release(); |
| 80 return nullptr; | 80 return nullptr; |
| 81 } | 81 } |
| 82 return pFont; | 82 return pFont; |
| 83 } | 83 } |
| 84 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 84 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 85 | 85 |
| 86 CFGAS_GEFont::CFGAS_GEFont(IFGAS_FontMgr* pFontMgr) | 86 CFGAS_GEFont::CFGAS_GEFont(CFGAS_FontMgr* pFontMgr) |
| 87 : | 87 : |
| 88 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 88 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 89 m_bUseLogFontStyle(false), | 89 m_bUseLogFontStyle(false), |
| 90 m_dwLogFontStyle(0), | 90 m_dwLogFontStyle(0), |
| 91 #endif | 91 #endif |
| 92 m_pFont(nullptr), | 92 m_pFont(nullptr), |
| 93 m_pSrcFont(nullptr), | 93 m_pSrcFont(nullptr), |
| 94 m_pFontMgr(pFontMgr), | 94 m_pFontMgr(pFontMgr), |
| 95 m_iRefCount(1), | 95 m_iRefCount(1), |
| 96 m_bExternalFont(false), | 96 m_bExternalFont(false), |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 } | 483 } |
| 484 if (m_pRectArray) { | 484 if (m_pRectArray) { |
| 485 m_pRectArray->RemoveAll(false); | 485 m_pRectArray->RemoveAll(false); |
| 486 } | 486 } |
| 487 } | 487 } |
| 488 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { | 488 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { |
| 489 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; | 489 iGlyphIndex = ((uint32_t)iGlyphIndex) >> 24; |
| 490 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) | 490 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) |
| 491 : m_SubstFonts[iGlyphIndex - 1]; | 491 : m_SubstFonts[iGlyphIndex - 1]; |
| 492 } | 492 } |
| OLD | NEW |