7#include "core/fxge/cfx_fontmgr.h"
13#include "core/fxcrt/fixed_size_data_vector.h"
14#include "core/fxge/cfx_fontmapper.h"
15#include "core/fxge/cfx_substfont.h"
16#include "core/fxge/fontdata/chromefontdata/chromefontdata.h"
17#include "core/fxge/fx_font.h"
18#include "core/fxge/systemfontinfo_iface.h"
19#include "third_party/base/check_op.h"
24 const uint8_t* m_pFontData;
28constexpr BuiltinFont kFoxitFonts[] = {
50FXFT_LibraryRec* FTLibraryInitHelper() {
51 FXFT_LibraryRec* pLibrary =
nullptr;
52 FT_Init_FreeType(&pLibrary);
59 : m_pFontData(std::move(data)) {}
64 CHECK_LT(index, std::size(m_TTCFaces));
65 m_TTCFaces[index].Reset(face);
69 CHECK_LT(index, std::size(m_TTCFaces));
70 return m_TTCFaces[index].Get();
76 m_FTLibrarySupportsHinting(SetLcdFilterMode() ||
77 FreeTypeVersionSupportsHinting()) {}
82 const ByteString& face_name,
85 auto it = m_FaceMap.find({face_name, weight, bItalic});
86 return it != m_FaceMap.end() ? pdfium::WrapRetain(it->second.Get()) :
nullptr;
90 const ByteString& face_name,
94 auto pFontDesc = pdfium::MakeRetain<FontDesc>(
std::move(data));
95 m_FaceMap[{face_name, weight, bItalic}].Reset(pFontDesc.Get());
102 auto it = m_TTCFaceMap.find({ttc_size, checksum});
103 return it != m_TTCFaceMap.end() ? pdfium::WrapRetain(it->second.Get())
111 auto pNewDesc = pdfium::MakeRetain<FontDesc>(
std::move(data));
112 m_TTCFaceMap[{ttc_size, checksum}].Reset(pNewDesc.Get());
117 pdfium::span<
const uint8_t> span,
120 CFX_Face::New(m_FTLibrary.get(), std::move(pDesc), span,
121 static_cast<FT_Long>(face_index));
125 if (FT_Set_Pixel_Sizes(face->GetRec(), 64, 64) != 0)
132pdfium::span<
const uint8_t>
CFX_FontMgr::GetStandardFont(size_t index) {
133 CHECK_LT(index,
std::size(kFoxitFonts));
134 return pdfium::make_span(kFoxitFonts[index].m_pFontData,
135 kFoxitFonts[index].m_dwSize);
140 return pdfium::make_span(kGenericSansFont.m_pFontData,
141 kGenericSansFont.m_dwSize);
146 return pdfium::make_span(kGenericSerifFont.m_pFontData,
147 kGenericSerifFont.m_dwSize);
150bool CFX_FontMgr::FreeTypeVersionSupportsHinting()
const {
154 FT_Library_Version(m_FTLibrary.get(), &major, &minor, &patch);
157 return major > 2 || (major == 2 && minor > 8) ||
158 (major == 2 && minor == 8 && patch >= 1);
162 return FT_Library_SetLcdFilter(m_FTLibrary.get(), FT_LCD_FILTER_DEFAULT) !=
163 FT_Err_Unimplemented_Feature;
const unsigned char kFoxitSerifMMFontData[113417]
const unsigned char kFoxitSerifFontData[19469]
const unsigned char kFoxitSerifBoldFontData[19395]
const unsigned char kFoxitSansFontData[15025]
const unsigned char kFoxitSansMMFontData[66919]
const unsigned char kFoxitFixedItalicFontData[18746]
const unsigned char kFoxitSansBoldItalicFontData[16418]
const unsigned char kFoxitSansBoldFontData[16344]
const unsigned char kFoxitFixedBoldFontData[18055]
const unsigned char kFoxitSansItalicFontData[16339]
const unsigned char kFoxitSymbolFontData[16729]
const unsigned char kFoxitFixedFontData[17597]
const unsigned char kFoxitDingbatsFontData[29513]
const unsigned char kFoxitSerifBoldItalicFontData[20733]
const unsigned char kFoxitSerifItalicFontData[21227]
const unsigned char kFoxitFixedBoldItalicFontData[19151]
static constexpr int kNumStandardFonts
CFX_Face * GetFace(size_t index) const
void SetFace(size_t index, CFX_Face *face)
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()
RetainPtr< CFX_Face > NewFixedFace(RetainPtr< FontDesc > pDesc, pdfium::span< const uint8_t > span, size_t face_index)
RetainPtr< FontDesc > GetCachedTTCFontDesc(size_t ttc_size, uint32_t checksum)
static pdfium::span< const uint8_t > GetGenericSansFont()