1//========================================================================
2//
3// FontInfo.h
4//
5// Copyright (C) 2005 Kristian Høgsberg <krh@redhat.com>
6// Copyright (C) 2005-2008, 2010, 2011, 2018, 2019, 2021, 2023 Albert Astals Cid <aacid@kde.org>
7// Copyright (C) 2005 Brad Hards <bradh@frogmouth.net>
8// Copyright (C) 2009 Pino Toscano <pino@kde.org>
9// Copyright (C) 2012 Adrian Johnson <ajohnson@redneon.com>
10// Copyright (C) 2013 Thomas Freitag <Thomas.Freitag@alfa.de>
11// Copyright (C) 2019, 2021, 2022 Oliver Sander <oliver.sander@tu-dresden.de>
12// Copyright (C) 2019 Adam Reichold <adam.reichold@t-online.de>
13//
14// To see a description of the changes please see the Changelog file that
15// came with your tarball or type make ChangeLog if you are building from git
16//
17//========================================================================
18
19//========================================================================
20//
21// Based on code from pdffonts.cc
22//
23// Copyright 2001-2007 Glyph & Cog, LLC
24//
25//========================================================================
26
27#ifndef FONT_INFO_H
28#define FONT_INFO_H
29
30#include "Object.h"
31#include "poppler_private_export.h"
32
33#include <optional>
34#include <string>
35#include <unordered_set>
36
37class GfxFont;
38class PDFDoc;
39
40class POPPLER_PRIVATE_EXPORT FontInfo
41{
42public:
43 enum Type
44 {
45 unknown,
46 Type1,
47 Type1C,
48 Type1COT,
49 Type3,
50 TrueType,
51 TrueTypeOT,
52 CIDType0,
53 CIDType0C,
54 CIDType0COT,
55 CIDTrueType,
56 CIDTrueTypeOT
57 };
58
59 // Constructor.
60 FontInfo(GfxFont *fontA, XRef *xrefA);
61 // Copy constructor
62 FontInfo(const FontInfo &f) = default;
63
64 FontInfo &operator=(const FontInfo &) = delete;
65
66 const std::optional<std::string> &getName() const { return name; };
67 const std::optional<std::string> &getSubstituteName() const { return substituteName; };
68 const std::optional<std::string> &getFile() const { return file; };
69 const std::string &getEncoding() const { return encoding; };
70 Type getType() const { return type; };
71 bool getEmbedded() const { return emb; };
72 bool getSubset() const { return subset; };
73 bool getToUnicode() const { return hasToUnicode; };
74 Ref getRef() const { return fontRef; };
75 Ref getEmbRef() const { return embRef; };
76
77private:
78 std::optional<std::string> name;
79 std::optional<std::string> substituteName;
80 std::optional<std::string> file;
81 std::string encoding;
82 Type type;
83 bool emb;
84 bool subset;
85 bool hasToUnicode;
86 Ref fontRef;
87 Ref embRef;
88};
89
90class POPPLER_PRIVATE_EXPORT FontInfoScanner
91{
92public:
93 // Constructor.
94 explicit FontInfoScanner(PDFDoc *doc, int firstPage = 0);
95 // Destructor.
96 ~FontInfoScanner();
97
98 std::vector<FontInfo *> scan(int nPages);
99
100private:
101 PDFDoc *doc;
102 int currentPage;
103 std::unordered_set<int> fonts;
104 RefRecursionChecker visitedObjects;
105
106 void scanFonts(XRef *xrefA, Dict *resDict, std::vector<FontInfo *> *fontsList);
107};
108
109#endif
110

source code of poppler/poppler/FontInfo.h