// Copyright 2014 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 XFA_FGAS_FONT_CFGAS_GEFONT_H_ #define XFA_FGAS_FONT_CFGAS_GEFONT_H_ #include #include #include #include #include #include #include "build/build_config.h" #include "core/fxcrt/fx_codepage_forward.h" #include "core/fxcrt/fx_coordinates.h" #include "core/fxcrt/fx_string.h" #include "core/fxcrt/maybe_owned.h" #include "core/fxcrt/retain_ptr.h" class CFX_Font; class CFX_UnicodeEncodingEx; class CPDF_Document; class CPDF_Font; class CFGAS_GEFont final : public Retainable { public: CONSTRUCT_VIA_MAKE_RETAIN; static RetainPtr LoadFont(const wchar_t* pszFontFamily, uint32_t dwFontStyles, FX_CodePage wCodePage); static RetainPtr LoadFont(RetainPtr pFont); static RetainPtr LoadFont(std::unique_ptr pFont); static RetainPtr LoadStockFont(CPDF_Document* pDoc, const ByteString& font_family); uint32_t GetFontStyles() const; std::optional GetCharWidth(wchar_t wUnicode); int32_t GetGlyphIndex(wchar_t wUnicode); int32_t GetAscent() const; int32_t GetDescent() const; std::optional GetCharBBox(wchar_t wUnicode); RetainPtr GetSubstFont(int32_t iGlyphIndex); CFX_Font* GetDevFont() const { return m_pFont.Get(); } void SetLogicalFontStyle(uint32_t dwLogFontStyle) { m_dwLogFontStyle = dwLogFontStyle; } private: CFGAS_GEFont(); ~CFGAS_GEFont() override; #if BUILDFLAG(IS_WIN) bool LoadFontInternal(const wchar_t* pszFontFamily, uint32_t dwFontStyles, FX_CodePage wCodePage); #endif bool LoadFontInternal(std::unique_ptr pInternalFont); bool LoadFontInternal(RetainPtr pPDFFont); bool InitFont(); std::pair> GetGlyphIndexAndFont( wchar_t wUnicode, bool bRecursive); WideString GetFamilyName() const; std::optional m_dwLogFontStyle; RetainPtr m_pPDFFont; // Must come before |m_pFont|. MaybeOwned m_pFont; // Must come before |m_pFontEncoding|. std::unique_ptr m_pFontEncoding; std::map> m_CharWidthMap; std::map m_BBoxMap; std::vector> m_SubstFonts; std::map> m_FontMapper; }; #endif // XFA_FGAS_FONT_CFGAS_GEFONT_H_