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

Unified 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, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « core/fpdfdoc/cpvt_fontmap.h ('k') | core/fpdfdoc/cpvt_generateap.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: core/fpdfdoc/cpvt_fontmap.cpp
diff --git a/core/fpdfdoc/cpvt_fontmap.cpp b/core/fpdfdoc/cpvt_fontmap.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..529f85169e569e37d90a90f5983aa656df8de8c7
--- /dev/null
+++ b/core/fpdfdoc/cpvt_fontmap.cpp
@@ -0,0 +1,75 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#include "core/fpdfdoc/cpvt_fontmap.h"
+
+#include "core/fpdfapi/fpdf_font/include/cpdf_font.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h"
+#include "core/fpdfapi/fpdf_parser/include/cpdf_document.h"
+#include "core/fpdfdoc/doc_utils.h"
+
+CPVT_FontMap::CPVT_FontMap(CPDF_Document* pDoc,
+ CPDF_Dictionary* pResDict,
+ CPDF_Font* pDefFont,
+ const CFX_ByteString& sDefFontAlias)
+ : m_pDocument(pDoc),
+ m_pResDict(pResDict),
+ m_pDefFont(pDefFont),
+ m_sDefFontAlias(sDefFontAlias),
+ m_pSysFont(nullptr),
+ m_sSysFontAlias() {}
+
+CPVT_FontMap::~CPVT_FontMap() {}
+
+void CPVT_FontMap::GetAnnotSysPDFFont(CPDF_Document* pDoc,
+ const CPDF_Dictionary* pResDict,
+ CPDF_Font*& pSysFont,
+ CFX_ByteString& sSysFontAlias) {
+ if (!pDoc || !pResDict)
+ return;
+
+ CFX_ByteString sFontAlias;
+ CPDF_Dictionary* pFormDict = pDoc->GetRoot()->GetDictBy("AcroForm");
+ CPDF_Font* pPDFFont = AddNativeInterFormFont(pFormDict, pDoc, sSysFontAlias);
+ if (!pPDFFont)
+ return;
+
+ if (CPDF_Dictionary* pFontList = pResDict->GetDictBy("Font")) {
+ if (!pFontList->KeyExist(sSysFontAlias))
+ pFontList->SetAtReference(sSysFontAlias, pDoc, pPDFFont->GetFontDict());
+ }
+ pSysFont = pPDFFont;
+}
+
+CPDF_Font* CPVT_FontMap::GetPDFFont(int32_t nFontIndex) {
+ switch (nFontIndex) {
+ case 0:
+ return m_pDefFont;
+ case 1:
+ if (!m_pSysFont) {
+ GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont,
+ m_sSysFontAlias);
+ }
+ return m_pSysFont;
+ default:
+ return nullptr;
+ }
+}
+
+CFX_ByteString CPVT_FontMap::GetPDFFontAlias(int32_t nFontIndex) {
+ switch (nFontIndex) {
+ case 0:
+ return m_sDefFontAlias;
+ case 1:
+ if (!m_pSysFont) {
+ GetAnnotSysPDFFont(m_pDocument, m_pResDict, m_pSysFont,
+ m_sSysFontAlias);
+ }
+ return m_sSysFontAlias;
+ default:
+ return "";
+ }
+}
« 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