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, |
(...skipping 19 matching lines...) Expand all Loading... |
30 m_sAPType("N") {} | 30 m_sAPType("N") {} |
31 | 31 |
32 CBA_FontMap::~CBA_FontMap() {} | 32 CBA_FontMap::~CBA_FontMap() {} |
33 | 33 |
34 void CBA_FontMap::Reset() { | 34 void CBA_FontMap::Reset() { |
35 Empty(); | 35 Empty(); |
36 m_pDefaultFont = NULL; | 36 m_pDefaultFont = NULL; |
37 m_sDefaultFontName = ""; | 37 m_sDefaultFontName = ""; |
38 } | 38 } |
39 | 39 |
40 void CBA_FontMap::Initial(const FX_CHAR* fontname) { | 40 void CBA_FontMap::Initialize() { |
41 int32_t nCharset = DEFAULT_CHARSET; | 41 int32_t nCharset = DEFAULT_CHARSET; |
42 | 42 |
43 if (!m_pDefaultFont) { | 43 if (!m_pDefaultFont) { |
44 m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName); | 44 m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName); |
45 if (m_pDefaultFont) { | 45 if (m_pDefaultFont) { |
46 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) | 46 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) |
47 nCharset = pSubstFont->m_Charset; | 47 nCharset = pSubstFont->m_Charset; |
48 else { | 48 else { |
49 if (m_sDefaultFontName == "Wingdings" || | 49 if (m_sDefaultFontName == "Wingdings" || |
50 m_sDefaultFontName == "Wingdings2" || | 50 m_sDefaultFontName == "Wingdings2" || |
51 m_sDefaultFontName == "Wingdings3" || | 51 m_sDefaultFontName == "Wingdings3" || |
52 m_sDefaultFontName == "Webdings") | 52 m_sDefaultFontName == "Webdings") |
53 nCharset = SYMBOL_CHARSET; | 53 nCharset = SYMBOL_CHARSET; |
54 else | 54 else |
55 nCharset = ANSI_CHARSET; | 55 nCharset = ANSI_CHARSET; |
56 } | 56 } |
57 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); | 57 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); |
58 AddFontToAnnotDict(m_pDefaultFont, m_sDefaultFontName); | 58 AddFontToAnnotDict(m_pDefaultFont, m_sDefaultFontName); |
59 } | 59 } |
60 } | 60 } |
61 | 61 |
62 if (nCharset != ANSI_CHARSET) | 62 if (nCharset != ANSI_CHARSET) |
63 CPWL_FontMap::Initial(fontname); | 63 CPWL_FontMap::Init(); |
64 } | 64 } |
65 | 65 |
66 void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont, | 66 void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont, |
67 const CFX_ByteString& sFontName) { | 67 const CFX_ByteString& sFontName) { |
68 ASSERT(pFont != NULL); | 68 ASSERT(pFont != NULL); |
69 | 69 |
70 if (m_pDefaultFont) | 70 if (m_pDefaultFont) |
71 return; | 71 return; |
72 | 72 |
73 m_pDefaultFont = pFont; | 73 m_pDefaultFont = pFont; |
74 m_sDefaultFontName = sFontName; | 74 m_sDefaultFontName = sFontName; |
75 | 75 |
76 // if (m_sDefaultFontName.IsEmpty()) | |
77 // m_sDefaultFontName = pFont->GetFontTypeName(); | |
78 | |
79 int32_t nCharset = DEFAULT_CHARSET; | 76 int32_t nCharset = DEFAULT_CHARSET; |
80 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) | 77 if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) |
81 nCharset = pSubstFont->m_Charset; | 78 nCharset = pSubstFont->m_Charset; |
82 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); | 79 AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); |
83 } | 80 } |
84 | 81 |
85 CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, | 82 CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, |
86 int32_t nCharset) { | 83 int32_t nCharset) { |
87 ASSERT(m_pAnnotDict != NULL); | 84 ASSERT(m_pAnnotDict != NULL); |
88 | 85 |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 } | 268 } |
272 } | 269 } |
273 | 270 |
274 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; | 271 return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; |
275 } | 272 } |
276 | 273 |
277 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { | 274 void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { |
278 m_sAPType = sAPType; | 275 m_sAPType = sAPType; |
279 | 276 |
280 Reset(); | 277 Reset(); |
281 Initial(); | 278 Initialize(); |
282 } | 279 } |
OLD | NEW |