| 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/include/fxcodec/fx_codec.h" | 7 #include "../../core/include/fxcodec/fx_codec.h" |
| 8 #include "../../core/include/fxcrt/fx_safe_types.h" | 8 #include "../../core/include/fxcrt/fx_safe_types.h" |
| 9 #include "../../public/fpdf_ext.h" | 9 #include "../../public/fpdf_ext.h" |
| 10 #include "../../public/fpdf_progressive.h" | 10 #include "../../public/fpdf_progressive.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #ifndef _T | 64 #ifndef _T |
| 65 #define _T(x) x | 65 #define _T(x) x |
| 66 #endif | 66 #endif |
| 67 | 67 |
| 68 CCodec_ModuleMgr* g_pCodecModule = nullptr; | 68 CCodec_ModuleMgr* g_pCodecModule = nullptr; |
| 69 | 69 |
| 70 #if _FX_OS_ == _FX_LINUX_EMBEDDED_ | 70 #if _FX_OS_ == _FX_LINUX_EMBEDDED_ |
| 71 class CFontMapper : public IPDF_FontMapper { | 71 class CFontMapper : public IPDF_FontMapper { |
| 72 public: | 72 public: |
| 73 CFontMapper(); | 73 CFontMapper(); |
| 74 virtual ~CFontMapper(); | 74 ~CFontMapper() override; |
| 75 | 75 |
| 76 virtual FT_Face FindSubstFont( | 76 // IPDF_FontMapper |
| 77 FT_Face FindSubstFont( |
| 77 CPDF_Document* pDoc, // [IN] The PDF document | 78 CPDF_Document* pDoc, // [IN] The PDF document |
| 78 const CFX_ByteString& face_name, // [IN] Original name | 79 const CFX_ByteString& face_name, // [IN] Original name |
| 79 FX_BOOL bTrueType, // [IN] TrueType or Type1 | 80 FX_BOOL bTrueType, // [IN] TrueType or Type1 |
| 80 FX_DWORD flags, // [IN] PDF font flags (see PDF Reference section 5.7.1) | 81 FX_DWORD flags, // [IN] PDF font flags (see PDF Reference section 5.7.1) |
| 81 int font_weight, // [IN] original font weight. 0 for not specified | 82 int font_weight, // [IN] original font weight. 0 for not specified |
| 82 int CharsetCP, // [IN] code page for charset (see Win32 GetACP()) | 83 int CharsetCP, // [IN] code page for charset (see Win32 GetACP()) |
| 83 FX_BOOL bVertical, | 84 FX_BOOL bVertical, |
| 84 CPDF_SubstFont* pSubstFont // [OUT] Subst font data | 85 CPDF_SubstFont* pSubstFont // [OUT] Subst font data |
| 85 ); | 86 ) override; |
| 86 | 87 |
| 87 FT_Face m_SysFace; | 88 FT_Face m_SysFace; |
| 88 }; | 89 }; |
| 89 | 90 |
| 90 CFontMapper* g_pFontMapper = NULL; | 91 CFontMapper* g_pFontMapper = NULL; |
| 91 #endif // #if _FX_OS_ == _FX_LINUX_EMBEDDED_ | 92 #endif // #if _FX_OS_ == _FX_LINUX_EMBEDDED_ |
| 92 | 93 |
| 93 DLLEXPORT void STDCALL FPDF_InitLibrary() { | 94 DLLEXPORT void STDCALL FPDF_InitLibrary() { |
| 94 FPDF_InitLibraryWithConfig(nullptr); | 95 FPDF_InitLibraryWithConfig(nullptr); |
| 95 } | 96 } |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 pdfium::base::checked_cast<FX_FILESIZE, size_t>(size); | 198 pdfium::base::checked_cast<FX_FILESIZE, size_t>(size); |
| 198 newPos += offset; | 199 newPos += offset; |
| 199 if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) { | 200 if (!newPos.IsValid() || newPos.ValueOrDie() > (FX_DWORD)m_size) { |
| 200 return FALSE; | 201 return FALSE; |
| 201 } | 202 } |
| 202 FXSYS_memcpy(buffer, m_pBuf + offset, size); | 203 FXSYS_memcpy(buffer, m_pBuf + offset, size); |
| 203 return TRUE; | 204 return TRUE; |
| 204 } | 205 } |
| 205 | 206 |
| 206 private: | 207 private: |
| 208 ~CMemFile() {} |
| 209 |
| 207 uint8_t* m_pBuf; | 210 uint8_t* m_pBuf; |
| 208 FX_FILESIZE m_size; | 211 FX_FILESIZE m_size; |
| 209 }; | 212 }; |
| 210 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, | 213 DLLEXPORT FPDF_DOCUMENT STDCALL FPDF_LoadMemDocument(const void* data_buf, |
| 211 int size, | 214 int size, |
| 212 FPDF_BYTESTRING password) { | 215 FPDF_BYTESTRING password) { |
| 213 CPDF_Parser* pParser = new CPDF_Parser; | 216 CPDF_Parser* pParser = new CPDF_Parser; |
| 214 pParser->SetPassword(password); | 217 pParser->SetPassword(password); |
| 215 CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size); | 218 CMemFile* pMemFile = new CMemFile((uint8_t*)data_buf, size); |
| 216 FX_DWORD err_code = pParser->StartParse(pMemFile); | 219 FX_DWORD err_code = pParser->StartParse(pMemFile); |
| (...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 if (!buffer) { | 915 if (!buffer) { |
| 913 *buflen = len; | 916 *buflen = len; |
| 914 } else if (*buflen >= len) { | 917 } else if (*buflen >= len) { |
| 915 memcpy(buffer, utf16Name.c_str(), len); | 918 memcpy(buffer, utf16Name.c_str(), len); |
| 916 *buflen = len; | 919 *buflen = len; |
| 917 } else { | 920 } else { |
| 918 *buflen = -1; | 921 *buflen = -1; |
| 919 } | 922 } |
| 920 return (FPDF_DEST)pDestObj; | 923 return (FPDF_DEST)pDestObj; |
| 921 } | 924 } |
| OLD | NEW |