1 // Copyright 2017 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/fpdfapi/font/cfx_stockfontarray.h" 8 9 #include <memory> 10 #include <utility> 11 12 #include "core/fxcrt/fx_memory.h" 13 CFX_StockFontArray()14CFX_StockFontArray::CFX_StockFontArray() {} 15 ~CFX_StockFontArray()16CFX_StockFontArray::~CFX_StockFontArray() { 17 for (size_t i = 0; i < FX_ArraySize(m_StockFonts); ++i) { 18 if (m_StockFonts[i]) 19 delete m_StockFonts[i]->GetFontDict(); 20 } 21 } 22 GetFont(uint32_t index) const23CPDF_Font* CFX_StockFontArray::GetFont(uint32_t index) const { 24 if (index >= FX_ArraySize(m_StockFonts)) 25 return nullptr; 26 return m_StockFonts[index].get(); 27 } 28 SetFont(uint32_t index,std::unique_ptr<CPDF_Font> pFont)29CPDF_Font* CFX_StockFontArray::SetFont(uint32_t index, 30 std::unique_ptr<CPDF_Font> pFont) { 31 CPDF_Font* result = pFont.get(); 32 if (index < FX_ArraySize(m_StockFonts)) 33 m_StockFonts[index] = std::move(pFont); 34 return result; 35 } 36