| 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 "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" | 7 #include "fpdfsdk/include/formfiller/FFL_CBA_Fontmap.h" |
| 8 #include "fpdfsdk/include/formfiller/FormFiller.h" | 8 #include "fpdfsdk/include/formfiller/FormFiller.h" |
| 9 | 9 |
| 10 CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot, | 10 CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot, |
| 11 IFX_SystemHandler* pSystemHandler) | 11 IFX_SystemHandler* pSystemHandler) |
| 12 : CPWL_FontMap(pSystemHandler), | 12 : CPWL_FontMap(pSystemHandler), |
| 13 m_pDocument(NULL), | 13 m_pDocument(NULL), |
| 14 m_pAnnotDict(NULL), | 14 m_pAnnotDict(NULL), |
| 15 m_pDefaultFont(NULL), | 15 m_pDefaultFont(NULL), |
| 16 m_sAPType("N") { | 16 m_sAPType("N") { |
| 17 CPDF_Page* pPage = pAnnot->GetPDFPage(); | 17 CPDF_Page* pPage = pAnnot->GetPDFPage(); |
| 18 | 18 |
| 19 m_pDocument = pPage->m_pDocument; | 19 m_pDocument = pPage->m_pDocument; |
| 20 m_pAnnotDict = pAnnot->GetPDFAnnot()->GetAnnotDict(); | 20 m_pAnnotDict = pAnnot->GetPDFAnnot()->GetAnnotDict(); |
| 21 Initialize(); |
| 21 } | 22 } |
| 22 | 23 |
| 23 CBA_FontMap::CBA_FontMap(CPDF_Document* pDocument, | |
| 24 CPDF_Dictionary* pAnnotDict, | |
| 25 IFX_SystemHandler* pSystemHandler) | |
| 26 : CPWL_FontMap(pSystemHandler), | |
| 27 m_pDocument(pDocument), | |
| 28 m_pAnnotDict(pAnnotDict), | |
| 29 m_pDefaultFont(NULL), | |
| 30 m_sAPType("N") {} | |
| 31 | |
| 32 CBA_FontMap::~CBA_FontMap() {} | 24 CBA_FontMap::~CBA_FontMap() {} |
| 33 | 25 |
| 34 void CBA_FontMap::Reset() { | 26 void CBA_FontMap::Reset() { |
| 35 Empty(); | 27 Empty(); |
| 36 m_pDefaultFont = NULL; | 28 m_pDefaultFont = NULL; |
| 37 m_sDefaultFontName = ""; | 29 m_sDefaultFontName = ""; |
| 38 } | 30 } |
| 39 | 31 |
| 40 void CBA_FontMap::Initial(const FX_CHAR* fontname) { | 32 void CBA_FontMap::Initialize() { |
| 41 int32_t nCharset = DEFAULT_CHARSET; | 33 int32_t nCharset = DEFAULT_CHARSET; |
| 42 | 34 |
| 43 if (!m_pDefaultFont) { | 35 if (!m_pDefaultFont) { |
| 44 m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName); | 36 m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName); |
| 45 if (m_pDefaultFont) { | 37 if (m_pDefaultFont) { |
| 46 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) | 38 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) |
| 47 nCharset = pSubstFont->m_Charset; | 39 nCharset = pSubstFont->m_Charset; |
| 48 else { | 40 else { |
| 49 if (m_sDefaultFontName == "Wingdings" || | 41 if (m_sDefaultFontName == "Wingdings" || |
| 50 m_sDefaultFontName == "Wingdings2" || | 42 m_sDefaultFontName == "Wingdings2" || |
| 51 m_sDefaultFontName == "Wingdings3" || | 43 m_sDefaultFontName == "Wingdings3" || |
| 52 m_sDefaultFontName == "Webdings") | 44 m_sDefaultFontName == "Webdings") |
| 53 nCharset = SYMBOL_CHARSET; | 45 nCharset = SYMBOL_CHARSET; |
| 54 else | 46 else |
| 55 nCharset = ANSI_CHARSET; | 47 nCharset = ANSI_CHARSET; |
| 56 } | 48 } |
| 57 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); | 49 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); |
| 58 AddFontToAnnotDict(m_pDefaultFont, m_sDefaultFontName); | 50 AddFontToAnnotDict(m_pDefaultFont, m_sDefaultFontName); |
| 59 } | 51 } |
| 60 } | 52 } |
| 61 | 53 |
| 62 if (nCharset != ANSI_CHARSET) | 54 if (nCharset != ANSI_CHARSET) |
| 63 CPWL_FontMap::Initial(fontname); | 55 CPWL_FontMap::Initialize(); |
| 64 } | 56 } |
| 65 | 57 |
| 66 void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont, | 58 void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont, |
| 67 const CFX_ByteString& sFontName) { | 59 const CFX_ByteString& sFontName) { |
| 68 ASSERT(pFont != NULL); | 60 ASSERT(pFont != NULL); |
| 69 | 61 |
| 70 if (m_pDefaultFont) | 62 if (m_pDefaultFont) |
| 71 return; | 63 return; |
| 72 | 64 |
| 73 m_pDefaultFont = pFont; | 65 m_pDefaultFont = pFont; |
| 74 m_sDefaultFontName = sFontName; | 66 m_sDefaultFontName = sFontName; |
| 75 | 67 |
| 76 // if (m_sDefaultFontName.IsEmpty()) | |
| 77 // m_sDefaultFontName = pFont->GetFontTypeName(); | |
| 78 | |
| 79 int32_t nCharset = DEFAULT_CHARSET; | 68 int32_t nCharset = DEFAULT_CHARSET; |
| 80 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) | 69 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) |
| 81 nCharset = pSubstFont->m_Charset; | 70 nCharset = pSubstFont->m_Charset; |
| 82 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); | 71 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); |
| 83 } | 72 } |
| 84 | 73 |
| 85 CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, | 74 CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, |
| 86 int32_t nCharset) { | 75 int32_t nCharset) { |
| 87 ASSERT(m_pAnnotDict != NULL); | 76 ASSERT(m_pAnnotDict != NULL); |
| 88 | 77 |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 } | 260 } |
| 272 } | 261 } |
| 273 | 262 |
| 274 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; | 263 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; |
| 275 } | 264 } |
| 276 | 265 |
| 277 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { | 266 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { |
| 278 m_sAPType = sAPType; | 267 m_sAPType = sAPType; |
| 279 | 268 |
| 280 Reset(); | 269 Reset(); |
| 281 Initial(); | 270 Initialize(); |
| 282 } | 271 } |
| OLD | NEW |