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 <map>
14#include <memory>
15#include <tuple>
16
17#include "core/fxcrt/bytestring.h"
18#include "core/fxcrt/fixed_size_data_vector.h"
19#include "core/fxcrt/observed_ptr.h"
20#include "core/fxcrt/retain_ptr.h"
21#include "core/fxge/cfx_face.h"
22#include "core/fxge/freetype/fx_freetype.h"
23#include "third_party/base/containers/span.h"
24
25class CFX_FontMapper;
26
28 public:
29 class FontDesc final : public Retainable, public Observable {
30 public:
32
33 pdfium::span<const uint8_t> FontData() const { return m_pFontData; }
34 void SetFace(size_t index, CFX_Face* face);
35 CFX_Face* GetFace(size_t index) const;
36
37 private:
38 explicit FontDesc(FixedSizeDataVector<uint8_t> data);
39 ~FontDesc() override;
40
41 const FixedSizeDataVector<uint8_t> m_pFontData;
42 ObservedPtr<CFX_Face> m_TTCFaces[16];
43 };
44
45 // `index` must be less than `CFX_FontMapper::kNumStandardFonts`.
46 static pdfium::span<const uint8_t> GetStandardFont(size_t index);
47 static pdfium::span<const uint8_t> GetGenericSansFont();
48 static pdfium::span<const uint8_t> GetGenericSerifFont();
49
52
53 RetainPtr<FontDesc> GetCachedFontDesc(const ByteString& face_name,
54 int weight,
55 bool bItalic);
56 RetainPtr<FontDesc> AddCachedFontDesc(const ByteString& face_name,
57 int weight,
58 bool bItalic,
59 FixedSizeDataVector<uint8_t> data);
60
61 RetainPtr<FontDesc> GetCachedTTCFontDesc(size_t ttc_size, uint32_t checksum);
62 RetainPtr<FontDesc> AddCachedTTCFontDesc(size_t ttc_size,
63 uint32_t checksum,
64 FixedSizeDataVector<uint8_t> data);
65
66 RetainPtr<CFX_Face> NewFixedFace(RetainPtr<FontDesc> pDesc,
67 pdfium::span<const uint8_t> span,
68 size_t face_index);
69
70 // Always present.
71 CFX_FontMapper* GetBuiltinMapper() const { return m_pBuiltinMapper.get(); }
72
73 FXFT_LibraryRec* GetFTLibrary() const { return m_FTLibrary.get(); }
74 bool FTLibrarySupportsHinting() const { return m_FTLibrarySupportsHinting; }
75
76 private:
77 bool FreeTypeVersionSupportsHinting() const;
78 bool SetLcdFilterMode() const;
79
80 // Must come before |m_pBuiltinMapper| and |m_FaceMap|.
81 ScopedFXFTLibraryRec const m_FTLibrary;
82 std::unique_ptr<CFX_FontMapper> m_pBuiltinMapper;
83 std::map<std::tuple<ByteString, int, bool>, ObservedPtr<FontDesc>> m_FaceMap;
85 const bool m_FTLibrarySupportsHinting;
86};
87
88#endif // CORE_FXGE_CFX_FONTMGR_H_
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:33
void SetFace(size_t index, CFX_Face *face)
FXFT_LibraryRec * GetFTLibrary() const
Definition cfx_fontmgr.h:73
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:74
CFX_FontMapper * GetBuiltinMapper() const
Definition cfx_fontmgr.h:71
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:103
static const char kDefaultAnsiFontName[]
Definition cfx_font.h:58
static const char kUniversalDefaultFontName[]
Definition cfx_font.h:59
static FX_Charset GetCharSetFromUnicode(uint16_t word)
Definition cfx_font.cpp:112
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)
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)
bool operator==(const char *ptr) const
ByteString & operator=(ByteString &&that) noexcept
bool IsEmpty() const
Definition bytestring.h:119
FontEncoding
FX_CodePage FX_GetCodePageFromCharset(FX_Charset charset)
FX_Charset
Definition fx_codepage.h:70
FX_Charset FX_GetCharsetFromCodePage(FX_CodePage codepage)
FX_CodePage FX_GetACP()
#define CONSTRUCT_VIA_MAKE_RETAIN
Definition retain_ptr.h:224