Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Side by Side Diff: core/fpdfdoc/cpvt_fontmap.cpp

Issue 1840413002: Split core/include/fpdfdoc/fpdf_ap.h (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfdoc/cpvt_fontmap.h ('k') | core/fpdfdoc/cpvt_generateap.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "core/fpdfdoc/cpvt_fontmap.h"
8
9 #include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
11 #include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
12 #include "core/fpdfdoc/doc_utils.h"
13
14 CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc,
15 CPDF_Dictionary* pResDict,
16 CPDF_Font* pDefFont,
17 const CFX_ByteString& sDefFontAlias)
18 : m_pDocument(pDoc),
19 m_pResDict(pResDict),
20 m_pDefFont(pDefFont),
21 m_sDefFontAlias(sDefFontAlias),
22 m_pSysFont(nullptr),
23 m_sSysFontAlias() {}
24
25 CPVT_FontMap::~CPVT_FontMap() {}
26
27 void CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc,
28 const CPDF_Dictionary* pResDict,
29 CPDF_Font*& pSysFont,
30 CFX_ByteString& sSysFontAlias) {
31 if (!pDoc || !pResDict)
32 return;
33
34 CFX_ByteString sFontAlias;
35 CPDF_Dictionary* pFormDict = pDoc->GetRoot()->GetDictBy("AcroForm");
36 CPDF_Font* pPDFFont = AddNativeInterFormFont(pFormDict, pDoc, sSysFontAlias);
37 if (!pPDFFont)
38 return;
39
40 if (CPDF_Dictionary* pFontList = pResDict->GetDictBy("Font")) {
41 if (!pFontList->KeyExist(sSysFontAlias))
42 pFontList->SetAtReference(sSysFontAlias, pDoc, pPDFFont->GetFontDict());
43 }
44 pSysFont = pPDFFont;
45 }
46
47 CPDF_Font* CPVT_FontMap::GetPDFFont(int32_t nFontIndex) {
48 switch (nFontIndex) {
49 case 0:
50 return m_pDefFont;
51 case 1:
52 if (!m_pSysFont) {
53 GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont,
54 m_sSysFontAlias);
55 }
56 return m_pSysFont;
57 default:
58 return nullptr;
59 }
60 }
61
62 CFX_ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) {
63 switch (nFontIndex) {
64 case 0:
65 return m_sDefFontAlias;
66 case 1:
67 if (!m_pSysFont) {
68 GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont,
69 m_sSysFontAlias);
70 }
71 return m_sSysFontAlias;
72 default:
73 return "";
74 }
75 }
OLDNEW
« no previous file with comments | « core/fpdfdoc/cpvt_fontmap.h ('k') | core/fpdfdoc/cpvt_generateap.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698