// Copyright 2016 The PDFium Authors // 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 #ifndef CORE_FXGE_CFX_FONTMGR_H_ #define CORE_FXGE_CFX_FONTMGR_H_ #include #include #include #include #include #include "core/fxcrt/bytestring.h" #include "core/fxcrt/fixed_uninit_data_vector.h" #include "core/fxcrt/observed_ptr.h" #include "core/fxcrt/retain_ptr.h" #include "core/fxge/cfx_face.h" #include "core/fxge/freetype/fx_freetype.h" #include "third_party/base/span.h" class CFX_FontMapper; class CFX_FontMgr { public: class FontDesc final : public Retainable, public Observable { public: CONSTRUCT_VIA_MAKE_RETAIN; ~FontDesc() override; pdfium::span FontData() const { return m_pFontData; } void SetFace(size_t index, CFX_Face* face); CFX_Face* GetFace(size_t index) const; private: explicit FontDesc(FixedUninitDataVector data); const FixedUninitDataVector m_pFontData; ObservedPtr m_TTCFaces[16]; }; // `index` must be less than `CFX_FontMapper::kNumStandardFonts`. static pdfium::span GetStandardFont(size_t index); static pdfium::span GetGenericSansFont(); static pdfium::span GetGenericSerifFont(); CFX_FontMgr(); ~CFX_FontMgr(); RetainPtr GetCachedFontDesc(const ByteString& face_name, int weight, bool bItalic); RetainPtr AddCachedFontDesc(const ByteString& face_name, int weight, bool bItalic, FixedUninitDataVector data); RetainPtr GetCachedTTCFontDesc(size_t ttc_size, uint32_t checksum); RetainPtr AddCachedTTCFontDesc(size_t ttc_size, uint32_t checksum, FixedUninitDataVector data); RetainPtr NewFixedFace(RetainPtr pDesc, pdfium::span span, size_t face_index); // Always present. CFX_FontMapper* GetBuiltinMapper() const { return m_pBuiltinMapper.get(); } FXFT_LibraryRec* GetFTLibrary() const { return m_FTLibrary.get(); } bool FTLibrarySupportsHinting() const { return m_FTLibrarySupportsHinting; } private: bool FreeTypeVersionSupportsHinting() const; bool SetLcdFilterMode() const; // Must come before |m_pBuiltinMapper| and |m_FaceMap|. ScopedFXFTLibraryRec const m_FTLibrary; std::unique_ptr m_pBuiltinMapper; std::map, ObservedPtr> m_FaceMap; std::map, ObservedPtr> m_TTCFaceMap; const bool m_FTLibrarySupportsHinting; }; #endif // CORE_FXGE_CFX_FONTMGR_H_