59 friend class PdfCommon;
75 PdfFont* SearchFont(
const std::string_view& fontPattern,
const PdfFontCreateParams& createParams);
77 PdfFont& GetStandard14Font(PdfStandard14FontType stdFont,
78 const PdfFontCreateParams& params = { });
80 PdfFont& GetOrCreateFont(
const std::string_view& fontPath,
unsigned faceIndex,
81 const PdfFontCreateParams& params = { });
83 PdfFont& GetOrCreateFontFromBuffer(
const bufferview& buffer,
unsigned faceIndex,
84 const PdfFontCreateParams& params = { });
86 PdfFont& GetOrCreateFont(
const std::string_view& fontPath,
87 const PdfFontCreateParams& params = { });
89 PdfFont& GetOrCreateFontFromBuffer(
const bufferview& buffer,
90 const PdfFontCreateParams& params = { });
92 PdfFont& GetOrCreateFont(
const PdfFontMetricsConstPtr& metrics,
93 const PdfFontCreateParams& params = { });
98 PdfFont* GetCachedFont(
const PdfReference& ref);
105 const PdfFontSearchParams&
params = { });
107#if defined(_WIN32) && defined(PODOFO_HAVE_WIN32GDI)
111#ifdef PODOFO_HAVE_FONTCONFIG
119 static void SetFontConfigWrapper(
const std::shared_ptr<PdfFontConfigWrapper>& fontConfig);
121 static PdfFontConfigWrapper& GetFontConfigWrapper();
133 PdfFontManager(PdfDocument& doc);
136 const PdfFont* GetLoadedFont(
const PdfResources& resources,
const std::string_view& name);
145 PdfFont* AddImported(std::unique_ptr<PdfFont>&& font);
149 std::string GenerateSubsetPrefix();
151 static void AddFontDirectory(
const std::string_view& path);
156 static PdfFontMetricsConstPtr SearchFontMetrics(
const std::string_view& fontPattern,
157 const PdfFontSearchParams& params,
const PdfFontMetrics& metrics,
bool skipNormalization);
164 Descriptor(
const std::string_view& name, PdfStandard14FontType stdType,
165 const PdfEncoding& encoding,
bool hasFontStyle, PdfFontStyle style);
167 Descriptor(
const Descriptor& rhs) =
default;
169 const std::string Name;
170 const PdfStandard14FontType StdType;
171 const unsigned EncodingId;
172 const bool HasFontStyle;
173 const PdfFontStyle Style;
176 struct PathDescriptor
178 PathDescriptor(
const std::string_view& filepath,
unsigned faceIndex,
const PdfEncoding& encoding);
180 PathDescriptor(
const PathDescriptor& rhs) =
default;
182 const std::string FilePath;
183 const unsigned FaceIndex;
184 const unsigned EncodingId;
189 size_t operator()(
const Descriptor& elem)
const;
190 size_t operator()(
const PathDescriptor& elem)
const;
195 bool operator()(
const Descriptor& lhs,
const Descriptor& rhs)
const;
196 bool operator()(
const PathDescriptor& lhs,
const PathDescriptor& rhs)
const;
199 using CachedPaths = std::unordered_map<PathDescriptor, PdfFont*, HashElement, EqualElement>;
200 using CachedQueries = std::unordered_map<Descriptor, std::vector<PdfFont*>, HashElement, EqualElement>;
205 std::unique_ptr<PdfFont> Font;
208 using FontMap = std::unordered_map<PdfReference, Storage>;
211 static std::unique_ptr<const PdfFontMetrics> searchFontMetrics(
const std::string_view& fontName,
212 const PdfFontSearchParams& params,
const PdfFontMetrics* refMetrics,
bool skipNormalization);
213 PdfFont* getImportedFont(
const std::string_view& pattern,
214 const PdfFontSearchParams& searchParams,
const PdfFontCreateParams& createParams);
215 PdfFont* addImported(std::vector<PdfFont*>& fonts, std::unique_ptr<PdfFont>&& font);
216 PdfFont& getOrCreateFontHashed(
const PdfFontMetricsConstPtr& metrics,
const PdfFontCreateParams& params);
218#if defined(_WIN32) && defined(PODOFO_HAVE_WIN32GDI)
219 static std::unique_ptr<charbuff> getWin32FontData(
const std::string_view& fontName,
220 const PdfFontSearchParams& params);
224 PdfFontManager(
const PdfFontManager&) =
delete;
225 PdfFontManager& operator=(
const PdfFontManager&) =
delete;
229 std::string m_currentPrefix;
232 CachedQueries m_cachedQueries;
235 CachedPaths m_cachedPaths;
241 std::unordered_map<std::string, std::unique_ptr<PdfFont>> m_inlineFonts;
243#ifdef PODOFO_HAVE_FONTCONFIG
244 static std::shared_ptr<PdfFontConfigWrapper> m_fontConfig;