John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
Dan Sinclair | edbb319 | 2016-03-21 09:08:24 -0400 | [diff] [blame] | 7 | #include "fpdfsdk/formfiller/cba_fontmap.h" |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 8 | |
dan sinclair | 61b2fc7 | 2016-03-23 19:21:44 -0400 | [diff] [blame] | 9 | #include "core/fpdfapi/fpdf_font/include/cpdf_font.h" |
Dan Sinclair | 455a419 | 2016-03-16 09:48:56 -0400 | [diff] [blame] | 10 | #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
Dan Sinclair | aa403d3 | 2016-03-15 14:57:22 -0400 | [diff] [blame] | 11 | #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h" |
| 12 | #include "core/fpdfapi/fpdf_parser/include/cpdf_simple_parser.h" |
dan sinclair | 61b2fc7 | 2016-03-23 19:21:44 -0400 | [diff] [blame] | 13 | #include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h" |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 14 | #include "fpdfsdk/include/fsdk_baseannot.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 15 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 16 | CBA_FontMap::CBA_FontMap(CPDFSDK_Annot* pAnnot, |
dsinclair | b959010 | 2016-04-27 06:38:59 -0700 | [diff] [blame] | 17 | CFX_SystemHandler* pSystemHandler) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 18 | : CPWL_FontMap(pSystemHandler), |
| 19 | m_pDocument(NULL), |
| 20 | m_pAnnotDict(NULL), |
| 21 | m_pDefaultFont(NULL), |
| 22 | m_sAPType("N") { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 23 | CPDF_Page* pPage = pAnnot->GetPDFPage(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 24 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 25 | m_pDocument = pPage->m_pDocument; |
| 26 | m_pAnnotDict = pAnnot->GetPDFAnnot()->GetAnnotDict(); |
Lei Zhang | fcfa3b8 | 2015-12-24 21:07:28 -0800 | [diff] [blame] | 27 | Initialize(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 28 | } |
| 29 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 30 | CBA_FontMap::~CBA_FontMap() {} |
| 31 | |
| 32 | void CBA_FontMap::Reset() { |
| 33 | Empty(); |
| 34 | m_pDefaultFont = NULL; |
| 35 | m_sDefaultFontName = ""; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 36 | } |
| 37 | |
Lei Zhang | fcfa3b8 | 2015-12-24 21:07:28 -0800 | [diff] [blame] | 38 | void CBA_FontMap::Initialize() { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 39 | int32_t nCharset = DEFAULT_CHARSET; |
| 40 | |
| 41 | if (!m_pDefaultFont) { |
| 42 | m_pDefaultFont = GetAnnotDefaultFont(m_sDefaultFontName); |
| 43 | if (m_pDefaultFont) { |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 44 | if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 45 | nCharset = pSubstFont->m_Charset; |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 46 | } else { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 47 | if (m_sDefaultFontName == "Wingdings" || |
| 48 | m_sDefaultFontName == "Wingdings2" || |
| 49 | m_sDefaultFontName == "Wingdings3" || |
| 50 | m_sDefaultFontName == "Webdings") |
| 51 | nCharset = SYMBOL_CHARSET; |
| 52 | else |
| 53 | nCharset = ANSI_CHARSET; |
| 54 | } |
| 55 | AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); |
| 56 | AddFontToAnnotDict(m_pDefaultFont, m_sDefaultFontName); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | if (nCharset != ANSI_CHARSET) |
Lei Zhang | fcfa3b8 | 2015-12-24 21:07:28 -0800 | [diff] [blame] | 61 | CPWL_FontMap::Initialize(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 62 | } |
| 63 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 64 | void CBA_FontMap::SetDefaultFont(CPDF_Font* pFont, |
| 65 | const CFX_ByteString& sFontName) { |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 66 | ASSERT(pFont); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 67 | |
| 68 | if (m_pDefaultFont) |
| 69 | return; |
| 70 | |
| 71 | m_pDefaultFont = pFont; |
| 72 | m_sDefaultFontName = sFontName; |
| 73 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 74 | int32_t nCharset = DEFAULT_CHARSET; |
| 75 | if (const CFX_SubstFont* pSubstFont = m_pDefaultFont->GetSubstFont()) |
| 76 | nCharset = pSubstFont->m_Charset; |
| 77 | AddFontData(m_pDefaultFont, m_sDefaultFontName, nCharset); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 80 | CPDF_Font* CBA_FontMap::FindFontSameCharset(CFX_ByteString& sFontAlias, |
| 81 | int32_t nCharset) { |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 82 | if (m_pAnnotDict->GetStringBy("Subtype") == "Widget") { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 83 | CPDF_Document* pDocument = GetDocument(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 84 | CPDF_Dictionary* pRootDict = pDocument->GetRoot(); |
| 85 | if (!pRootDict) |
| 86 | return NULL; |
| 87 | |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 88 | CPDF_Dictionary* pAcroFormDict = pRootDict->GetDictBy("AcroForm"); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 89 | if (!pAcroFormDict) |
| 90 | return NULL; |
| 91 | |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 92 | CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR"); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 93 | if (!pDRDict) |
| 94 | return NULL; |
| 95 | |
| 96 | return FindResFontSameCharset(pDRDict, sFontAlias, nCharset); |
| 97 | } |
| 98 | |
| 99 | return NULL; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 102 | CPDF_Document* CBA_FontMap::GetDocument() { |
| 103 | return m_pDocument; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 106 | CPDF_Font* CBA_FontMap::FindResFontSameCharset(CPDF_Dictionary* pResDict, |
| 107 | CFX_ByteString& sFontAlias, |
| 108 | int32_t nCharset) { |
| 109 | if (!pResDict) |
| 110 | return NULL; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 111 | |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 112 | CPDF_Dictionary* pFonts = pResDict->GetDictBy("Font"); |
Lei Zhang | 412e908 | 2015-12-14 18:34:00 -0800 | [diff] [blame] | 113 | if (!pFonts) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 114 | return NULL; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 115 | |
Lei Zhang | 5eca305 | 2016-02-22 20:32:21 -0800 | [diff] [blame] | 116 | CPDF_Document* pDocument = GetDocument(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 117 | CPDF_Font* pFind = NULL; |
Oliver Chang | 3f1c71f | 2016-01-11 08:45:31 -0800 | [diff] [blame] | 118 | for (const auto& it : *pFonts) { |
| 119 | const CFX_ByteString& csKey = it.first; |
| 120 | CPDF_Object* pObj = it.second; |
Lei Zhang | 412e908 | 2015-12-14 18:34:00 -0800 | [diff] [blame] | 121 | if (!pObj) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 122 | continue; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 123 | |
Dan Sinclair | f1251c1 | 2015-10-20 16:24:45 -0400 | [diff] [blame] | 124 | CPDF_Dictionary* pElement = ToDictionary(pObj->GetDirect()); |
| 125 | if (!pElement) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 126 | continue; |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 127 | if (pElement->GetStringBy("Type") != "Font") |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 128 | continue; |
| 129 | |
| 130 | CPDF_Font* pFont = pDocument->LoadFont(pElement); |
Lei Zhang | 412e908 | 2015-12-14 18:34:00 -0800 | [diff] [blame] | 131 | if (!pFont) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 132 | continue; |
| 133 | const CFX_SubstFont* pSubst = pFont->GetSubstFont(); |
Lei Zhang | 412e908 | 2015-12-14 18:34:00 -0800 | [diff] [blame] | 134 | if (!pSubst) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 135 | continue; |
| 136 | if (pSubst->m_Charset == nCharset) { |
| 137 | sFontAlias = csKey; |
| 138 | pFind = pFont; |
| 139 | } |
| 140 | } |
| 141 | return pFind; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 142 | } |
| 143 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 144 | void CBA_FontMap::AddedFont(CPDF_Font* pFont, |
| 145 | const CFX_ByteString& sFontAlias) { |
| 146 | AddFontToAnnotDict(pFont, sFontAlias); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 147 | } |
| 148 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 149 | void CBA_FontMap::AddFontToAnnotDict(CPDF_Font* pFont, |
| 150 | const CFX_ByteString& sAlias) { |
| 151 | if (!pFont) |
| 152 | return; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 153 | |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 154 | CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP"); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 155 | |
Lei Zhang | 412e908 | 2015-12-14 18:34:00 -0800 | [diff] [blame] | 156 | if (!pAPDict) { |
Tom Sepez | ae51c81 | 2015-08-05 12:34:06 -0700 | [diff] [blame] | 157 | pAPDict = new CPDF_Dictionary; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 158 | m_pAnnotDict->SetAt("AP", pAPDict); |
| 159 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 160 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 161 | // to avoid checkbox and radiobutton |
tsepez | 7b1ccf9 | 2016-04-14 11:04:57 -0700 | [diff] [blame] | 162 | CPDF_Object* pObject = pAPDict->GetObjectBy(m_sAPType); |
Dan Sinclair | f1251c1 | 2015-10-20 16:24:45 -0400 | [diff] [blame] | 163 | if (ToDictionary(pObject)) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 164 | return; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 165 | |
tsepez | 7b1ccf9 | 2016-04-14 11:04:57 -0700 | [diff] [blame] | 166 | CPDF_Stream* pStream = pAPDict->GetStreamBy(m_sAPType); |
Lei Zhang | 412e908 | 2015-12-14 18:34:00 -0800 | [diff] [blame] | 167 | if (!pStream) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 168 | pStream = new CPDF_Stream(NULL, 0, NULL); |
| 169 | int32_t objnum = m_pDocument->AddIndirectObject(pStream); |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame^] | 170 | pAPDict->SetAtReference(m_sAPType, m_pDocument, objnum); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 171 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 172 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 173 | CPDF_Dictionary* pStreamDict = pStream->GetDict(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 174 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 175 | if (!pStreamDict) { |
Tom Sepez | ae51c81 | 2015-08-05 12:34:06 -0700 | [diff] [blame] | 176 | pStreamDict = new CPDF_Dictionary; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 177 | pStream->InitStream(NULL, 0, pStreamDict); |
| 178 | } |
| 179 | |
| 180 | if (pStreamDict) { |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 181 | CPDF_Dictionary* pStreamResList = pStreamDict->GetDictBy("Resources"); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 182 | if (!pStreamResList) { |
Tom Sepez | ae51c81 | 2015-08-05 12:34:06 -0700 | [diff] [blame] | 183 | pStreamResList = new CPDF_Dictionary(); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 184 | pStreamDict->SetAt("Resources", pStreamResList); |
| 185 | } |
| 186 | |
| 187 | if (pStreamResList) { |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 188 | CPDF_Dictionary* pStreamResFontList = pStreamResList->GetDictBy("Font"); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 189 | if (!pStreamResFontList) { |
| 190 | pStreamResFontList = new CPDF_Dictionary; |
| 191 | int32_t objnum = m_pDocument->AddIndirectObject(pStreamResFontList); |
| 192 | pStreamResList->SetAtReference("Font", m_pDocument, objnum); |
| 193 | } |
tsepez | 7b1ccf9 | 2016-04-14 11:04:57 -0700 | [diff] [blame] | 194 | if (!pStreamResFontList->KeyExist(sAlias)) |
| 195 | pStreamResFontList->SetAtReference(sAlias, m_pDocument, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 196 | pFont->GetFontDict()); |
| 197 | } |
| 198 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 199 | } |
| 200 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 201 | CPDF_Font* CBA_FontMap::GetAnnotDefaultFont(CFX_ByteString& sAlias) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 202 | CPDF_Dictionary* pAcroFormDict = NULL; |
Tom Sepez | 007e6c0 | 2016-02-26 14:31:56 -0800 | [diff] [blame] | 203 | const bool bWidget = (m_pAnnotDict->GetStringBy("Subtype") == "Widget"); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 204 | if (bWidget) { |
| 205 | if (CPDF_Dictionary* pRootDict = m_pDocument->GetRoot()) |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 206 | pAcroFormDict = pRootDict->GetDictBy("AcroForm"); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | CFX_ByteString sDA; |
Wei Li | d4e8f12 | 2016-03-21 11:20:44 -0700 | [diff] [blame] | 210 | CPDF_Object* pObj = FPDF_GetFieldAttr(m_pAnnotDict, "DA"); |
| 211 | if (pObj) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 212 | sDA = pObj->GetString(); |
| 213 | |
| 214 | if (bWidget) { |
| 215 | if (sDA.IsEmpty()) { |
| 216 | pObj = FPDF_GetFieldAttr(pAcroFormDict, "DA"); |
| 217 | sDA = pObj ? pObj->GetString() : CFX_ByteString(); |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | CPDF_Dictionary* pFontDict = NULL; |
| 222 | |
| 223 | if (!sDA.IsEmpty()) { |
tsepez | 4c3debb | 2016-04-08 12:20:38 -0700 | [diff] [blame] | 224 | CPDF_SimpleParser syntax(sDA.AsStringC()); |
Wei Li | 970c11e | 2016-02-16 14:26:22 -0800 | [diff] [blame] | 225 | syntax.FindTagParamFromStart("Tf", 2); |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame^] | 226 | CFX_ByteString sFontName(syntax.GetWord()); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 227 | sAlias = PDF_NameDecode(sFontName).Mid(1); |
| 228 | |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 229 | if (CPDF_Dictionary* pDRDict = m_pAnnotDict->GetDictBy("DR")) |
| 230 | if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font")) |
tsepez | 7b1ccf9 | 2016-04-14 11:04:57 -0700 | [diff] [blame] | 231 | pFontDict = pDRFontDict->GetDictBy(sAlias); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 232 | |
| 233 | if (!pFontDict) |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 234 | if (CPDF_Dictionary* pAPDict = m_pAnnotDict->GetDictBy("AP")) |
| 235 | if (CPDF_Dictionary* pNormalDict = pAPDict->GetDictBy("N")) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 236 | if (CPDF_Dictionary* pNormalResDict = |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 237 | pNormalDict->GetDictBy("Resources")) |
| 238 | if (CPDF_Dictionary* pResFontDict = |
| 239 | pNormalResDict->GetDictBy("Font")) |
tsepez | 7b1ccf9 | 2016-04-14 11:04:57 -0700 | [diff] [blame] | 240 | pFontDict = pResFontDict->GetDictBy(sAlias); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 241 | |
| 242 | if (bWidget) { |
| 243 | if (!pFontDict) { |
| 244 | if (pAcroFormDict) { |
Wei Li | 9b76113 | 2016-01-29 15:44:20 -0800 | [diff] [blame] | 245 | if (CPDF_Dictionary* pDRDict = pAcroFormDict->GetDictBy("DR")) |
| 246 | if (CPDF_Dictionary* pDRFontDict = pDRDict->GetDictBy("Font")) |
tsepez | 7b1ccf9 | 2016-04-14 11:04:57 -0700 | [diff] [blame] | 247 | pFontDict = pDRFontDict->GetDictBy(sAlias); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 248 | } |
| 249 | } |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | return pFontDict ? m_pDocument->LoadFont(pFontDict) : nullptr; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 254 | } |
| 255 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 256 | void CBA_FontMap::SetAPType(const CFX_ByteString& sAPType) { |
| 257 | m_sAPType = sAPType; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 258 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 259 | Reset(); |
Lei Zhang | fcfa3b8 | 2015-12-24 21:07:28 -0800 | [diff] [blame] | 260 | Initialize(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 261 | } |