| 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/cfgas_gefont.h" | 7 #include "xfa/fgas/font/cfgas_gefont.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 CFGAS_FontMgr* pFontMgr) { | 65 CFGAS_FontMgr* pFontMgr) { |
| 66 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); | 66 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
| 67 if (!pFont->LoadFontInternal(pBuffer, iLength)) { | 67 if (!pFont->LoadFontInternal(pBuffer, iLength)) { |
| 68 pFont->Release(); | 68 pFont->Release(); |
| 69 return nullptr; | 69 return nullptr; |
| 70 } | 70 } |
| 71 return pFont; | 71 return pFont; |
| 72 } | 72 } |
| 73 | 73 |
| 74 // static | 74 // static |
| 75 CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFX_Stream* pFontStream, | 75 CFGAS_GEFont* CFGAS_GEFont::LoadFont(IFGAS_Stream* pFontStream, |
| 76 CFGAS_FontMgr* pFontMgr, | 76 CFGAS_FontMgr* pFontMgr, |
| 77 bool bSaveStream) { | 77 bool bSaveStream) { |
| 78 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); | 78 CFGAS_GEFont* pFont = new CFGAS_GEFont(pFontMgr); |
| 79 if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) { | 79 if (!pFont->LoadFontInternal(pFontStream, bSaveStream)) { |
| 80 pFont->Release(); | 80 pFont->Release(); |
| 81 return nullptr; | 81 return nullptr; |
| 82 } | 82 } |
| 83 return pFont; | 83 return pFont; |
| 84 } | 84 } |
| 85 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 85 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 bool CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) { | 196 bool CFGAS_GEFont::LoadFontInternal(const uint8_t* pBuffer, int32_t length) { |
| 197 if (m_pFont) | 197 if (m_pFont) |
| 198 return false; | 198 return false; |
| 199 | 199 |
| 200 m_pFont = new CFX_Font; | 200 m_pFont = new CFX_Font; |
| 201 if (!m_pFont->LoadEmbedded(pBuffer, length)) | 201 if (!m_pFont->LoadEmbedded(pBuffer, length)) |
| 202 return false; | 202 return false; |
| 203 return InitFont(); | 203 return InitFont(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 bool CFGAS_GEFont::LoadFontInternal(IFX_Stream* pFontStream, bool bSaveStream) { | 206 bool CFGAS_GEFont::LoadFontInternal(IFGAS_Stream* pFontStream, |
| 207 bool bSaveStream) { |
| 207 if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) | 208 if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) |
| 208 return false; | 209 return false; |
| 209 if (bSaveStream) | 210 if (bSaveStream) |
| 210 m_pStream.reset(pFontStream); | 211 m_pStream.reset(pFontStream); |
| 211 | 212 |
| 212 m_pFileRead.reset(pFontStream->MakeSeekableReadStream()); | 213 m_pFileRead.reset(pFontStream->MakeSeekableReadStream()); |
| 213 m_pFont = new CFX_Font; | 214 m_pFont = new CFX_Font; |
| 214 if (m_pFont->LoadFile(m_pFileRead.get())) | 215 if (m_pFont->LoadFile(m_pFileRead.get())) |
| 215 return InitFont(); | 216 return InitFont(); |
| 216 m_pFileRead.reset(); | 217 m_pFileRead.reset(); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 | 453 |
| 453 int32_t CFGAS_GEFont::GetDescent() const { | 454 int32_t CFGAS_GEFont::GetDescent() const { |
| 454 return m_pFont->GetDescent(); | 455 return m_pFont->GetDescent(); |
| 455 } | 456 } |
| 456 | 457 |
| 457 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { | 458 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { |
| 458 iGlyphIndex = static_cast<uint32_t>(iGlyphIndex) >> 24; | 459 iGlyphIndex = static_cast<uint32_t>(iGlyphIndex) >> 24; |
| 459 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) | 460 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) |
| 460 : m_SubstFonts[iGlyphIndex - 1]; | 461 : m_SubstFonts[iGlyphIndex - 1]; |
| 461 } | 462 } |
| OLD | NEW |