| 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 "../../public/fpdf_sysfontinfo.h" | 7 #include "../../public/fpdf_sysfontinfo.h" |
| 8 #include "../include/fsdk_define.h" | 8 #include "../include/fsdk_define.h" |
| 9 #include "../include/pdfwindow/PWL_FontMap.h" | 9 #include "../include/pdfwindow/PWL_FontMap.h" |
| 10 | 10 |
| 11 class CSysFontInfo_Ext final : public IFX_SystemFontInfo | 11 class CFX_ExternalFontInfo final : public IFX_SystemFontInfo |
| 12 { | 12 { |
| 13 public: | 13 public: |
| 14 » FPDF_SYSFONTINFO*» m_pInfo; | 14 » CFX_ExternalFontInfo(FPDF_SYSFONTINFO* pInfo) : m_pInfo(pInfo) { } |
| 15 | 15 |
| 16 virtual void Release() override | 16 virtual void Release() override |
| 17 { | 17 { |
| 18 if (m_pInfo->Release) | 18 if (m_pInfo->Release) |
| 19 m_pInfo->Release(m_pInfo); | 19 m_pInfo->Release(m_pInfo); |
| 20 delete this; | 20 delete this; |
| 21 } | 21 } |
| 22 | 22 |
| 23 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override | 23 virtual FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override |
| 24 { | 24 { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 return FALSE; | 71 return FALSE; |
| 72 } | 72 } |
| 73 | 73 |
| 74 virtual void DeleteFont(void* hFont) override | 74 virtual void DeleteFont(void* hFont) override |
| 75 { | 75 { |
| 76 if (m_pInfo->DeleteFont) | 76 if (m_pInfo->DeleteFont) |
| 77 m_pInfo->DeleteFont(m_pInfo, hFont); | 77 m_pInfo->DeleteFont(m_pInfo, hFont); |
| 78 } | 78 } |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 ~CSysFontInfo_Ext() { } | 81 » ~CFX_ExternalFontInfo() { } |
| 82 |
| 83 » FPDF_SYSFONTINFO* const m_pInfo; |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, const char* name, int
charset) | 86 DLLEXPORT void STDCALL FPDF_AddInstalledFont(void* mapper, const char* name, int
charset) |
| 85 { | 87 { |
| 86 ((CFX_FontMapper*)mapper)->AddInstalledFont(name, charset); | 88 ((CFX_FontMapper*)mapper)->AddInstalledFont(name, charset); |
| 87 } | 89 } |
| 88 | 90 |
| 89 DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfoExt) | 91 DLLEXPORT void STDCALL FPDF_SetSystemFontInfo(FPDF_SYSFONTINFO* pFontInfoExt) |
| 90 { | 92 { |
| 91 » if (pFontInfoExt->version != 1) return; | 93 » if (pFontInfoExt->version != 1) |
| 94 » » return; |
| 92 | 95 |
| 93 » CSysFontInfo_Ext* pFontInfo = new CSysFontInfo_Ext; | 96 » CFX_GEModule::Get()->GetFontMgr()->SetSystemFontInfo( |
| 94 » pFontInfo->m_pInfo = pFontInfoExt; | 97 » » new CFX_ExternalFontInfo(pFontInfoExt)); |
| 95 » CFX_GEModule::Get()->GetFontMgr()->SetSystemFontInfo(pFontInfo); | |
| 96 } | 98 } |
| 97 | 99 |
| 98 DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap() | 100 DLLEXPORT const FPDF_CharsetFontMap* STDCALL FPDF_GetDefaultTTFMap() |
| 99 { | 101 { |
| 100 return CPWL_FontMap::defaultTTFMap; | 102 return CPWL_FontMap::defaultTTFMap; |
| 101 } | 103 } |
| 102 | 104 |
| 103 struct FPDF_SYSFONTINFO_DEFAULT : public FPDF_SYSFONTINFO | 105 struct FPDF_SYSFONTINFO_DEFAULT : public FPDF_SYSFONTINFO |
| 104 { | 106 { |
| 105 IFX_SystemFontInfo* m_pFontInfo; | 107 IFX_SystemFontInfo* m_pFontInfo; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 pFontInfoExt->GetFaceName = DefaultGetFaceName; | 165 pFontInfoExt->GetFaceName = DefaultGetFaceName; |
| 164 pFontInfoExt->GetFont = DefaultGetFont; | 166 pFontInfoExt->GetFont = DefaultGetFont; |
| 165 pFontInfoExt->GetFontCharset = DefaultGetFontCharset; | 167 pFontInfoExt->GetFontCharset = DefaultGetFontCharset; |
| 166 pFontInfoExt->GetFontData = DefaultGetFontData; | 168 pFontInfoExt->GetFontData = DefaultGetFontData; |
| 167 pFontInfoExt->MapFont = DefaultMapFont; | 169 pFontInfoExt->MapFont = DefaultMapFont; |
| 168 pFontInfoExt->Release = DefaultRelease; | 170 pFontInfoExt->Release = DefaultRelease; |
| 169 pFontInfoExt->version = 1; | 171 pFontInfoExt->version = 1; |
| 170 pFontInfoExt->m_pFontInfo = pFontInfo; | 172 pFontInfoExt->m_pFontInfo = pFontInfo; |
| 171 return pFontInfoExt; | 173 return pFontInfoExt; |
| 172 } | 174 } |
| OLD | NEW |