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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(IFX_Stream* pFontStream, bool bSaveStream) { |
207 if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) | 207 if (m_pFont || m_pFileRead || !pFontStream || pFontStream->GetLength() < 1) |
208 return false; | 208 return false; |
209 if (bSaveStream) | 209 if (bSaveStream) |
210 m_pStream.reset(pFontStream); | 210 m_pStream.reset(pFontStream); |
211 | 211 |
212 m_pFileRead.reset(FX_CreateFileRead(pFontStream, false)); | 212 m_pFileRead.reset(pFontStream->MakeSeekableReadStream()); |
213 m_pFont = new CFX_Font; | 213 m_pFont = new CFX_Font; |
214 if (m_pFont->LoadFile(m_pFileRead.get())) | 214 if (m_pFont->LoadFile(m_pFileRead.get())) |
215 return InitFont(); | 215 return InitFont(); |
216 m_pFileRead.reset(); | 216 m_pFileRead.reset(); |
217 return false; | 217 return false; |
218 } | 218 } |
219 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 219 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
220 | 220 |
221 bool CFGAS_GEFont::LoadFontInternal(CFX_Font* pExternalFont) { | 221 bool CFGAS_GEFont::LoadFontInternal(CFX_Font* pExternalFont) { |
222 if (m_pFont || !pExternalFont) | 222 if (m_pFont || !pExternalFont) |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 452 |
453 int32_t CFGAS_GEFont::GetDescent() const { | 453 int32_t CFGAS_GEFont::GetDescent() const { |
454 return m_pFont->GetDescent(); | 454 return m_pFont->GetDescent(); |
455 } | 455 } |
456 | 456 |
457 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { | 457 CFGAS_GEFont* CFGAS_GEFont::GetSubstFont(int32_t iGlyphIndex) const { |
458 iGlyphIndex = static_cast<uint32_t>(iGlyphIndex) >> 24; | 458 iGlyphIndex = static_cast<uint32_t>(iGlyphIndex) >> 24; |
459 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) | 459 return iGlyphIndex == 0 ? const_cast<CFGAS_GEFont*>(this) |
460 : m_SubstFonts[iGlyphIndex - 1]; | 460 : m_SubstFonts[iGlyphIndex - 1]; |
461 } | 461 } |
OLD | NEW |