1 // Copyright 2016 The PDFium Authors 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 #ifndef CORE_FPDFAPI_FONT_CPDF_SIMPLEFONT_H_ 8 #define CORE_FPDFAPI_FONT_CPDF_SIMPLEFONT_H_ 9 10 #include <stdint.h> 11 12 #include <vector> 13 14 #include "core/fpdfapi/font/cpdf_font.h" 15 #include "core/fpdfapi/font/cpdf_fontencoding.h" 16 #include "core/fxcrt/fx_string.h" 17 18 class CPDF_SimpleFont : public CPDF_Font { 19 public: 20 ~CPDF_SimpleFont() override; 21 22 // CPDF_Font 23 int GetCharWidthF(uint32_t charcode) override; 24 FX_RECT GetCharBBox(uint32_t charcode) override; 25 int GlyphFromCharCode(uint32_t charcode, bool* pVertGlyph) override; 26 bool IsUnicodeCompatible() const override; 27 WideString UnicodeFromCharCode(uint32_t charcode) const override; 28 uint32_t CharCodeFromUnicode(wchar_t Unicode) const override; 29 GetEncoding()30 const CPDF_FontEncoding* GetEncoding() const { return &m_Encoding; } 31 32 bool HasFontWidths() const override; 33 34 protected: 35 static constexpr size_t kInternalTableSize = 256; 36 37 CPDF_SimpleFont(CPDF_Document* pDocument, 38 RetainPtr<CPDF_Dictionary> pFontDict); 39 40 virtual void LoadGlyphMap() = 0; 41 42 bool LoadCommon(); 43 void LoadSubstFont(); 44 void LoadCharMetrics(int charcode); 45 void LoadCharWidths(const CPDF_Dictionary* font_desc); 46 void LoadDifferences(const CPDF_Dictionary* encoding); 47 void LoadPDFEncoding(bool bEmbedded, bool bTrueType); 48 49 CPDF_FontEncoding m_Encoding{FontEncoding::kBuiltin}; 50 FontEncoding m_BaseEncoding = FontEncoding::kBuiltin; 51 bool m_bUseFontWidth = false; 52 std::vector<ByteString> m_CharNames; 53 uint16_t m_GlyphIndex[kInternalTableSize]; 54 uint16_t m_CharWidth[kInternalTableSize]; 55 FX_RECT m_CharBBox[kInternalTableSize]; 56 }; 57 58 #endif // CORE_FPDFAPI_FONT_CPDF_SIMPLEFONT_H_ 59