Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cfx_fontmgr.h
Go to the documentation of this file.
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_FXGE_CFX_FONTMGR_H_
8#define CORE_FXGE_CFX_FONTMGR_H_
9
10#include <stddef.h>
11#include <stdint.h>
12
13#include <array>
14#include <map>
15#include <memory>
16#include <tuple>
17
18#include "core/fxcrt/bytestring.h"
19#include "core/fxcrt/fixed_size_data_vector.h"
20#include "core/fxcrt/observed_ptr.h"
21#include "core/fxcrt/retain_ptr.h"
22#include "core/fxcrt/span.h"
23#include "core/fxge/cfx_face.h"
24#include "core/fxge/freetype/fx_freetype.h"
25
26class CFX_FontMapper;
27
29 public:
30 class FontDesc final : public Retainable, public Observable {
31 public:
33
34 pdfium::span<const uint8_t> FontData() const { return m_pFontData; }
35 void SetFace(size_t index, CFX_Face* face);
36 CFX_Face* GetFace(size_t index) const;
37
38 private:
39 explicit FontDesc(FixedSizeDataVector<uint8_t> data);
40 ~FontDesc() override;
41
42 const FixedSizeDataVector<uint8_t> m_pFontData;
43 std::array<ObservedPtr<CFX_Face>, 16> m_TTCFaces;
44 };
45
46 // `index` must be less than `CFX_FontMapper::kNumStandardFonts`.
47 static pdfium::span<const uint8_t> GetStandardFont(size_t index);
48 static pdfium::span<const uint8_t> GetGenericSansFont();
49 static pdfium::span<const uint8_t> GetGenericSerifFont();
50
53
54 RetainPtr<FontDesc> GetCachedFontDesc(const ByteString& face_name,
55 int weight,
56 bool bItalic);
57 RetainPtr<FontDesc> AddCachedFontDesc(const ByteString& face_name,
58 int weight,
59 bool bItalic,
60 FixedSizeDataVector<uint8_t> data);
61
62 RetainPtr<FontDesc> GetCachedTTCFontDesc(size_t ttc_size, uint32_t checksum);
63 RetainPtr<FontDesc> AddCachedTTCFontDesc(size_t ttc_size,
64 uint32_t checksum,
65 FixedSizeDataVector<uint8_t> data);
66
67 RetainPtr<CFX_Face> NewFixedFace(RetainPtr<FontDesc> pDesc,
68 pdfium::span<const uint8_t> span,
69 size_t face_index);
70
71 // Always present.
72 CFX_FontMapper* GetBuiltinMapper() const { return m_pBuiltinMapper.get(); }
73
74 FXFT_LibraryRec* GetFTLibrary() const { return m_FTLibrary.get(); }
75 bool FTLibrarySupportsHinting() const { return m_FTLibrarySupportsHinting; }
76
77 private:
78 bool FreeTypeVersionSupportsHinting() const;
79 bool SetLcdFilterMode() const;
80
81 // Must come before |m_pBuiltinMapper| and |m_FaceMap|.
82 ScopedFXFTLibraryRec const m_FTLibrary;
83 std::unique_ptr<CFX_FontMapper> m_pBuiltinMapper;
84 std::map<std::tuple<ByteString, int, bool>, ObservedPtr<FontDesc>> m_FaceMap;
86 const bool m_FTLibrarySupportsHinting;
87};
88
89#endif // CORE_FXGE_CFX_FONTMGR_H_
fxcrt::ByteString ByteString
Definition bytestring.h:180
bool HasLocalizedFont(ByteStringView name) const
bool HasInstalledFont(ByteStringView name) const
static bool IsStandardFontName(const ByteString &name)
CFX_Face * GetFace(size_t index) const
pdfium::span< const uint8_t > FontData() const
Definition cfx_fontmgr.h:34
void SetFace(size_t index, CFX_Face *face)
FXFT_LibraryRec * GetFTLibrary() const
Definition cfx_fontmgr.h:74
RetainPtr< FontDesc > AddCachedFontDesc(const ByteString &face_name, int weight, bool bItalic, FixedSizeDataVector< uint8_t > data)
RetainPtr< FontDesc > GetCachedFontDesc(const ByteString &face_name, int weight, bool bItalic)
RetainPtr< FontDesc > AddCachedTTCFontDesc(size_t ttc_size, uint32_t checksum, FixedSizeDataVector< uint8_t > data)
static pdfium::span< const uint8_t > GetGenericSerifFont()
static pdfium::span< const uint8_t > GetStandardFont(size_t index)
RetainPtr< CFX_Face > NewFixedFace(RetainPtr< FontDesc > pDesc, pdfium::span< const uint8_t > span, size_t face_index)
bool FTLibrarySupportsHinting() const
Definition cfx_fontmgr.h:75
CFX_FontMapper * GetBuiltinMapper() const
Definition cfx_fontmgr.h:72
RetainPtr< FontDesc > GetCachedTTCFontDesc(size_t ttc_size, uint32_t checksum)
static pdfium::span< const uint8_t > GetGenericSansFont()
static ByteString GetDefaultFontNameByCharset(FX_Charset nCharset)
Definition cfx_font.cpp:116
static const char kDefaultAnsiFontName[]
Definition cfx_font.h:54
static const char kUniversalDefaultFontName[]
Definition cfx_font.h:55
static FX_Charset GetCharSetFromUnicode(uint16_t word)
Definition cfx_font.cpp:126
static CFX_GEModule * Get()
CFX_FontMgr * GetFontMgr() const
int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word) override
FX_Charset CharSetFromUnicode(uint16_t word, FX_Charset nOldCharset) override
RetainPtr< CPDF_Font > GetPDFFont(int32_t nFontIndex) override
~CPDF_BAFontMap() override
static FX_Charset GetNativeCharset()
CPDF_BAFontMap(CPDF_Document *pDocument, RetainPtr< CPDF_Dictionary > pAnnotDict, const ByteString &sAPType)
int32_t GetWordFontIndex(uint16_t word, FX_Charset nCharset, int32_t nFontIndex) override
ByteString GetPDFFontAlias(int32_t nFontIndex) override
CPDF_DefaultAppearance(const ByteString &csDA)
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
static CPDF_DocPageData * FromDocument(const CPDF_Document *pDoc)
CPDF_FontEncoding(FontEncoding predefined_encoding)
static RetainPtr< const CPDF_Object > GetFieldAttrForDict(const CPDF_Dictionary *pFieldDict, const ByteString &name)
virtual int32_t GetWordFontIndex(uint16_t word, FX_Charset charset, int32_t nFontIndex)=0
virtual RetainPtr< CPDF_Font > GetPDFFont(int32_t nFontIndex)=0
virtual int32_t CharCodeFromUnicode(int32_t nFontIndex, uint16_t word)=0
virtual ByteString GetPDFFontAlias(int32_t nFontIndex)=0
virtual ~IPVT_FontMap()=default
virtual FX_Charset CharSetFromUnicode(uint16_t word, FX_Charset nOldCharset)=0
static ByteString Format(const char *pFormat,...)
ByteString & operator+=(const ByteString &str)
ByteString()=default
bool operator==(const char *ptr) const
ByteString & operator=(ByteString &&that) noexcept
FontEncoding
FX_CodePage FX_GetCodePageFromCharset(FX_Charset charset)
FX_Charset
Definition fx_codepage.h:71
FX_Charset FX_GetCharsetFromCodePage(FX_CodePage codepage)
FX_CodePage FX_GetACP()
struct FT_LibraryRec_ FXFT_LibraryRec
Definition fx_freetype.h:23
std::unique_ptr< FXFT_LibraryRec, FXFTLibraryRecDeleter > ScopedFXFTLibraryRec
Definition fx_freetype.h:40
#define CONSTRUCT_VIA_MAKE_RETAIN
Definition retain_ptr.h:222
fxcrt::ByteStringView ByteStringView