OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/fpdfdoc/cpvt_fontmap.h" | 7 #include "core/fpdfdoc/cpvt_fontmap.h" |
8 | 8 |
9 #include "core/fpdfapi/font/cpdf_font.h" | 9 #include "core/fpdfapi/font/cpdf_font.h" |
10 #include "core/fpdfapi/parser/cpdf_dictionary.h" | 10 #include "core/fpdfapi/parser/cpdf_dictionary.h" |
11 #include "core/fpdfapi/parser/cpdf_document.h" | 11 #include "core/fpdfapi/parser/cpdf_document.h" |
| 12 #include "core/fpdfapi/parser/cpdf_reference.h" |
12 #include "core/fpdfdoc/cpdf_interform.h" | 13 #include "core/fpdfdoc/cpdf_interform.h" |
13 | 14 |
14 CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc, | 15 CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc, |
15 CPDF_Dictionary* pResDict, | 16 CPDF_Dictionary* pResDict, |
16 CPDF_Font* pDefFont, | 17 CPDF_Font* pDefFont, |
17 const CFX_ByteString& sDefFontAlias) | 18 const CFX_ByteString& sDefFontAlias) |
18 : m_pDocument(pDoc), | 19 : m_pDocument(pDoc), |
19 m_pResDict(pResDict), | 20 m_pResDict(pResDict), |
20 m_pDefFont(pDefFont), | 21 m_pDefFont(pDefFont), |
21 m_sDefFontAlias(sDefFontAlias), | 22 m_sDefFontAlias(sDefFontAlias), |
(...skipping 10 matching lines...) Expand all Loading... |
32 return; | 33 return; |
33 | 34 |
34 CFX_ByteString sFontAlias; | 35 CFX_ByteString sFontAlias; |
35 CPDF_Dictionary* pFormDict = pDoc->GetRoot()->GetDictFor("AcroForm"); | 36 CPDF_Dictionary* pFormDict = pDoc->GetRoot()->GetDictFor("AcroForm"); |
36 CPDF_Font* pPDFFont = AddNativeInterFormFont(pFormDict, pDoc, sSysFontAlias); | 37 CPDF_Font* pPDFFont = AddNativeInterFormFont(pFormDict, pDoc, sSysFontAlias); |
37 if (!pPDFFont) | 38 if (!pPDFFont) |
38 return; | 39 return; |
39 | 40 |
40 CPDF_Dictionary* pFontList = pResDict->GetDictFor("Font"); | 41 CPDF_Dictionary* pFontList = pResDict->GetDictFor("Font"); |
41 if (pFontList && !pFontList->KeyExist(sSysFontAlias)) { | 42 if (pFontList && !pFontList->KeyExist(sSysFontAlias)) { |
42 pFontList->SetReferenceFor(sSysFontAlias, pDoc, | 43 pFontList->SetNewFor<CPDF_Reference>(sSysFontAlias, pDoc, |
43 pPDFFont->GetFontDict()->GetObjNum()); | 44 pPDFFont->GetFontDict()->GetObjNum()); |
44 } | 45 } |
45 pSysFont = pPDFFont; | 46 pSysFont = pPDFFont; |
46 } | 47 } |
47 | 48 |
48 CPDF_Font* CPVT_FontMap::GetPDFFont(int32_t nFontIndex) { | 49 CPDF_Font* CPVT_FontMap::GetPDFFont(int32_t nFontIndex) { |
49 switch (nFontIndex) { | 50 switch (nFontIndex) { |
50 case 0: | 51 case 0: |
51 return m_pDefFont; | 52 return m_pDefFont; |
52 case 1: | 53 case 1: |
53 if (!m_pSysFont) { | 54 if (!m_pSysFont) { |
(...skipping 30 matching lines...) Expand all Loading... |
84 | 85 |
85 int32_t CPVT_FontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) { | 86 int32_t CPVT_FontMap::CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) { |
86 ASSERT(false); | 87 ASSERT(false); |
87 return 0; | 88 return 0; |
88 } | 89 } |
89 | 90 |
90 int32_t CPVT_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) { | 91 int32_t CPVT_FontMap::CharSetFromUnicode(uint16_t word, int32_t nOldCharset) { |
91 ASSERT(false); | 92 ASSERT(false); |
92 return FXFONT_ANSI_CHARSET; | 93 return FXFONT_ANSI_CHARSET; |
93 } | 94 } |
OLD | NEW |