summaryrefslogtreecommitdiff
path: root/core/fpdfapi/font/cfx_stockfontarray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/font/cfx_stockfontarray.cpp')
-rw-r--r--core/fpdfapi/font/cfx_stockfontarray.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/core/fpdfapi/font/cfx_stockfontarray.cpp b/core/fpdfapi/font/cfx_stockfontarray.cpp
new file mode 100644
index 0000000000..0808471c82
--- /dev/null
+++ b/core/fpdfapi/font/cfx_stockfontarray.cpp
@@ -0,0 +1,35 @@
+// Copyright 2017 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/fpdfapi/font/cfx_stockfontarray.h"
+
+#include <memory>
+#include <utility>
+
+#include "core/fxcrt/fx_memory.h"
+
+CFX_StockFontArray::CFX_StockFontArray() {}
+
+CFX_StockFontArray::~CFX_StockFontArray() {
+ for (size_t i = 0; i < FX_ArraySize(m_StockFonts); ++i) {
+ if (m_StockFonts[i])
+ delete m_StockFonts[i]->GetFontDict();
+ }
+}
+
+CPDF_Font* CFX_StockFontArray::GetFont(uint32_t index) const {
+ if (index >= FX_ArraySize(m_StockFonts))
+ return nullptr;
+ return m_StockFonts[index].get();
+}
+
+CPDF_Font* CFX_StockFontArray::SetFont(uint32_t index,
+ std::unique_ptr<CPDF_Font> pFont) {
+ CPDF_Font* result = pFont.get();
+ if (index < FX_ArraySize(m_StockFonts))
+ m_StockFonts[index] = std::move(pFont);
+ return result;
+}