| 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/fxcrt/fx_system.h" | 7 #include "core/fxcrt/fx_system.h" |
| 8 | 8 |
| 9 #define FPF_SKIAMATCHWEIGHT_NAME1 62 | 9 #define FPF_SKIAMATCHWEIGHT_NAME1 62 |
| 10 #define FPF_SKIAMATCHWEIGHT_NAME2 60 | 10 #define FPF_SKIAMATCHWEIGHT_NAME2 60 |
| 11 #define FPF_SKIAMATCHWEIGHT_1 16 | 11 #define FPF_SKIAMATCHWEIGHT_1 16 |
| 12 #define FPF_SKIAMATCHWEIGHT_2 8 | 12 #define FPF_SKIAMATCHWEIGHT_2 8 |
| 13 | 13 |
| 14 #include <algorithm> | 14 #include <algorithm> |
| 15 | 15 |
| 16 #include "core/fxcrt/fx_ext.h" | 16 #include "core/fxcrt/fx_ext.h" |
| 17 #include "core/fxcrt/fx_memory.h" | 17 #include "core/fxcrt/fx_memory.h" |
| 18 #include "core/fxge/android/fpf_skiafont.h" | 18 #include "core/fxge/android/fpf_skiafont.h" |
| 19 #include "core/fxge/android/fpf_skiafontmgr.h" | 19 #include "core/fxge/android/fpf_skiafontmgr.h" |
| 20 #include "core/fxge/fx_freetype.h" | 20 #include "core/fxge/fx_freetype.h" |
| 21 | 21 |
| 22 #ifdef __cplusplus | 22 #ifdef __cplusplus |
| 23 extern "C" { | 23 extern "C" { |
| 24 #endif | 24 #endif |
| 25 static unsigned long FPF_SkiaStream_Read(FXFT_Stream stream, | 25 static unsigned long FPF_SkiaStream_Read(FXFT_Stream stream, |
| 26 unsigned long offset, | 26 unsigned long offset, |
| 27 unsigned char* buffer, | 27 unsigned char* buffer, |
| 28 unsigned long count) { | 28 unsigned long count) { |
| 29 IFX_FileRead* pFileRead = (IFX_FileRead*)stream->descriptor.pointer; | 29 IFX_SeekableReadStream* pFileRead = |
| 30 (IFX_SeekableReadStream*)stream->descriptor.pointer; |
| 30 if (!pFileRead) | 31 if (!pFileRead) |
| 31 return 0; | 32 return 0; |
| 32 if (count > 0) { | 33 if (count > 0) { |
| 33 if (!pFileRead->ReadBlock(buffer, (FX_FILESIZE)offset, (size_t)count)) | 34 if (!pFileRead->ReadBlock(buffer, (FX_FILESIZE)offset, (size_t)count)) |
| 34 return 0; | 35 return 0; |
| 35 } | 36 } |
| 36 return count; | 37 return count; |
| 37 } | 38 } |
| 38 | 39 |
| 39 static void FPF_SkiaStream_Close(FXFT_Stream stream) {} | 40 static void FPF_SkiaStream_Close(FXFT_Stream stream) {} |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 CFPF_SkiaFont* pFont = new CFPF_SkiaFont; | 349 CFPF_SkiaFont* pFont = new CFPF_SkiaFont; |
| 349 if (pFont->InitFont(this, pBestFontDes, bsFamilyname, dwStyle, uCharset)) { | 350 if (pFont->InitFont(this, pBestFontDes, bsFamilyname, dwStyle, uCharset)) { |
| 350 m_FamilyFonts[dwHash] = pFont; | 351 m_FamilyFonts[dwHash] = pFont; |
| 351 return pFont->Retain(); | 352 return pFont->Retain(); |
| 352 } | 353 } |
| 353 pFont->Release(); | 354 pFont->Release(); |
| 354 } | 355 } |
| 355 return nullptr; | 356 return nullptr; |
| 356 } | 357 } |
| 357 | 358 |
| 358 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_FileRead* pFileRead, | 359 FXFT_Face CFPF_SkiaFontMgr::GetFontFace(IFX_SeekableReadStream* pFileRead, |
| 359 int32_t iFaceIndex) { | 360 int32_t iFaceIndex) { |
| 360 if (!pFileRead) | 361 if (!pFileRead) |
| 361 return nullptr; | 362 return nullptr; |
| 362 if (pFileRead->GetSize() == 0) | 363 if (pFileRead->GetSize() == 0) |
| 363 return nullptr; | 364 return nullptr; |
| 364 if (iFaceIndex < 0) | 365 if (iFaceIndex < 0) |
| 365 return nullptr; | 366 return nullptr; |
| 366 FXFT_StreamRec streamRec; | 367 FXFT_StreamRec streamRec; |
| 367 FXSYS_memset(&streamRec, 0, sizeof(FXFT_StreamRec)); | 368 FXSYS_memset(&streamRec, 0, sizeof(FXFT_StreamRec)); |
| 368 streamRec.size = pFileRead->GetSize(); | 369 streamRec.size = pFileRead->GetSize(); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 if ((uSerif > 1 && uSerif < 10) || uSerif > 13) | 472 if ((uSerif > 1 && uSerif < 10) || uSerif > 13) |
| 472 pFontDesc->m_dwStyle |= FXFONT_SERIF; | 473 pFontDesc->m_dwStyle |= FXFONT_SERIF; |
| 473 } | 474 } |
| 474 } | 475 } |
| 475 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) | 476 if (pOS2 && (pOS2->ulCodePageRange1 & (1 << 31))) |
| 476 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; | 477 pFontDesc->m_dwStyle |= FXFONT_SYMBOLIC; |
| 477 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); | 478 pFontDesc->m_dwCharsets = FPF_SkiaGetFaceCharset(pOS2); |
| 478 pFontDesc->m_iFaceIndex = face->face_index; | 479 pFontDesc->m_iFaceIndex = face->face_index; |
| 479 pFontDesc->m_iGlyphNum = face->num_glyphs; | 480 pFontDesc->m_iGlyphNum = face->num_glyphs; |
| 480 } | 481 } |
| OLD | NEW |