| 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 "core/fxge/fx_font.h" | 7 #include "core/fxge/fx_font.h" |
| 8 | 8 |
| 9 #include "core/fpdfapi/font/cpdf_font.h" | 9 #include "core/fpdfapi/font/cpdf_font.h" |
| 10 #include "core/fxge/cfx_facecache.h" | 10 #include "core/fxge/cfx_facecache.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 #ifdef PDF_ENABLE_XFA | 33 #ifdef PDF_ENABLE_XFA |
| 34 | 34 |
| 35 unsigned long FTStreamRead(FXFT_Stream stream, | 35 unsigned long FTStreamRead(FXFT_Stream stream, |
| 36 unsigned long offset, | 36 unsigned long offset, |
| 37 unsigned char* buffer, | 37 unsigned char* buffer, |
| 38 unsigned long count) { | 38 unsigned long count) { |
| 39 if (count == 0) | 39 if (count == 0) |
| 40 return 0; | 40 return 0; |
| 41 | 41 |
| 42 IFX_FileRead* pFile = static_cast<IFX_FileRead*>(stream->descriptor.pointer); | 42 IFX_SeekableReadStream* pFile = |
| 43 static_cast<IFX_SeekableReadStream*>(stream->descriptor.pointer); |
| 43 return pFile->ReadBlock(buffer, offset, count) ? count : 0; | 44 return pFile->ReadBlock(buffer, offset, count) ? count : 0; |
| 44 } | 45 } |
| 45 | 46 |
| 46 void FTStreamClose(FXFT_Stream stream) {} | 47 void FTStreamClose(FXFT_Stream stream) {} |
| 47 | 48 |
| 48 FX_BOOL LoadFileImp(FXFT_Library library, | 49 FX_BOOL LoadFileImp(FXFT_Library library, |
| 49 FXFT_Face* Face, | 50 FXFT_Face* Face, |
| 50 IFX_FileRead* pFile, | 51 IFX_SeekableReadStream* pFile, |
| 51 int32_t faceIndex, | 52 int32_t faceIndex, |
| 52 std::unique_ptr<FXFT_StreamRec>* stream) { | 53 std::unique_ptr<FXFT_StreamRec>* stream) { |
| 53 std::unique_ptr<FXFT_StreamRec> stream1(new FXFT_StreamRec()); | 54 std::unique_ptr<FXFT_StreamRec> stream1(new FXFT_StreamRec()); |
| 54 stream1->base = nullptr; | 55 stream1->base = nullptr; |
| 55 stream1->size = static_cast<unsigned long>(pFile->GetSize()); | 56 stream1->size = static_cast<unsigned long>(pFile->GetSize()); |
| 56 stream1->pos = 0; | 57 stream1->pos = 0; |
| 57 stream1->descriptor.pointer = pFile; | 58 stream1->descriptor.pointer = pFile; |
| 58 stream1->close = FTStreamClose; | 59 stream1->close = FTStreamClose; |
| 59 stream1->read = FTStreamRead; | 60 stream1->read = FTStreamRead; |
| 60 FXFT_Open_Args args; | 61 FXFT_Open_Args args; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 m_Face = CFX_GEModule::Get()->GetFontMgr()->FindSubstFont( | 325 m_Face = CFX_GEModule::Get()->GetFontMgr()->FindSubstFont( |
| 325 face_name, bTrueType, flags, weight, italic_angle, CharsetCP, | 326 face_name, bTrueType, flags, weight, italic_angle, CharsetCP, |
| 326 m_pSubstFont.get()); | 327 m_pSubstFont.get()); |
| 327 if (m_Face) { | 328 if (m_Face) { |
| 328 m_pFontData = FXFT_Get_Face_Stream_Base(m_Face); | 329 m_pFontData = FXFT_Get_Face_Stream_Base(m_Face); |
| 329 m_dwSize = FXFT_Get_Face_Stream_Size(m_Face); | 330 m_dwSize = FXFT_Get_Face_Stream_Size(m_Face); |
| 330 } | 331 } |
| 331 } | 332 } |
| 332 | 333 |
| 333 #ifdef PDF_ENABLE_XFA | 334 #ifdef PDF_ENABLE_XFA |
| 334 FX_BOOL CFX_Font::LoadFile(IFX_FileRead* pFile, | 335 FX_BOOL CFX_Font::LoadFile(IFX_SeekableReadStream* pFile, |
| 335 int nFaceIndex, | 336 int nFaceIndex, |
| 336 int* pFaceCount) { | 337 int* pFaceCount) { |
| 337 m_bEmbedded = FALSE; | 338 m_bEmbedded = FALSE; |
| 338 | 339 |
| 339 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); | 340 CFX_FontMgr* pFontMgr = CFX_GEModule::Get()->GetFontMgr(); |
| 340 pFontMgr->InitFTLibrary(); | 341 pFontMgr->InitFTLibrary(); |
| 341 FXFT_Library library = pFontMgr->GetFTLibrary(); | 342 FXFT_Library library = pFontMgr->GetFTLibrary(); |
| 342 | 343 |
| 343 std::unique_ptr<FXFT_StreamRec> stream; | 344 std::unique_ptr<FXFT_StreamRec> stream; |
| 344 if (!LoadFileImp(library, &m_Face, pFile, nFaceIndex, &stream)) | 345 if (!LoadFileImp(library, &m_Face, pFile, nFaceIndex, &stream)) |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 const CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, | 707 const CFX_PathData* CFX_Font::LoadGlyphPath(uint32_t glyph_index, |
| 707 int dest_width) const { | 708 int dest_width) const { |
| 708 return GetFaceCache()->LoadGlyphPath(this, glyph_index, dest_width); | 709 return GetFaceCache()->LoadGlyphPath(this, glyph_index, dest_width); |
| 709 } | 710 } |
| 710 | 711 |
| 711 #ifdef _SKIA_SUPPORT_ | 712 #ifdef _SKIA_SUPPORT_ |
| 712 CFX_TypeFace* CFX_Font::GetDeviceCache() const { | 713 CFX_TypeFace* CFX_Font::GetDeviceCache() const { |
| 713 return GetFaceCache()->GetDeviceCache(this); | 714 return GetFaceCache()->GetDeviceCache(this); |
| 714 } | 715 } |
| 715 #endif | 716 #endif |
| OLD | NEW |