1 | /* poppler-qt.h: qt interface to poppler |
2 | * Copyright (C) 2005, Net Integration Technologies, Inc. |
3 | * Copyright (C) 2005, Tobias Koening <tokoe@kde.org> |
4 | * Copyright (C) 2005, Brad Hards <bradh@frogmouth.net> |
5 | * Copyright (C) 2005-2008, 2015, Albert Astals Cid <aacid@kde.org> |
6 | * Copyright (C) 2008, 2009, Pino Toscano <pino@kde.org> |
7 | * Copyright (C) 2018, Adam Reichold <adam.reichold@t-online.de> |
8 | * Copyright (C) 2019, Oliver Sander <oliver.sander@tu-dresden.de> |
9 | * Copyright (C) 2019, Jan Grulich <jgrulich@redhat.com> |
10 | * |
11 | * This program is free software; you can redistribute it and/or modify |
12 | * it under the terms of the GNU General Public License as published by |
13 | * the Free Software Foundation; either version 2, or (at your option) |
14 | * any later version. |
15 | * |
16 | * This program is distributed in the hope that it will be useful, |
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19 | * GNU General Public License for more details. |
20 | * |
21 | * You should have received a copy of the GNU General Public License |
22 | * along with this program; if not, write to the Free Software |
23 | * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. |
24 | */ |
25 | |
26 | #include "poppler-qt6.h" |
27 | #include "poppler-private.h" |
28 | |
29 | namespace Poppler { |
30 | |
31 | FontInfo::FontInfo() |
32 | { |
33 | m_data = new FontInfoData(); |
34 | } |
35 | |
36 | FontInfo::FontInfo(const FontInfoData &fid) |
37 | { |
38 | m_data = new FontInfoData(fid); |
39 | } |
40 | |
41 | FontInfo::FontInfo(const FontInfo &fi) |
42 | { |
43 | m_data = new FontInfoData(*fi.m_data); |
44 | } |
45 | |
46 | FontInfo::~FontInfo() |
47 | { |
48 | delete m_data; |
49 | } |
50 | |
51 | QString FontInfo::name() const |
52 | { |
53 | return m_data->fontName; |
54 | } |
55 | |
56 | QString FontInfo::substituteName() const |
57 | { |
58 | return m_data->fontSubstituteName; |
59 | } |
60 | |
61 | QString FontInfo::file() const |
62 | { |
63 | return m_data->fontFile; |
64 | } |
65 | |
66 | bool FontInfo::isEmbedded() const |
67 | { |
68 | return m_data->isEmbedded; |
69 | } |
70 | |
71 | bool FontInfo::isSubset() const |
72 | { |
73 | return m_data->isSubset; |
74 | } |
75 | |
76 | FontInfo::Type FontInfo::type() const |
77 | { |
78 | return m_data->type; |
79 | } |
80 | |
81 | QString FontInfo::typeName() const |
82 | { |
83 | switch (type()) { |
84 | case unknown: |
85 | return QObject::tr(s: "unknown" ); |
86 | case Type1: |
87 | return QObject::tr(s: "Type 1" ); |
88 | case Type1C: |
89 | return QObject::tr(s: "Type 1C" ); |
90 | case Type3: |
91 | return QObject::tr(s: "Type 3" ); |
92 | case TrueType: |
93 | return QObject::tr(s: "TrueType" ); |
94 | case CIDType0: |
95 | return QObject::tr(s: "CID Type 0" ); |
96 | case CIDType0C: |
97 | return QObject::tr(s: "CID Type 0C" ); |
98 | case CIDTrueType: |
99 | return QObject::tr(s: "CID TrueType" ); |
100 | case Type1COT: |
101 | return QObject::tr(s: "Type 1C (OpenType)" ); |
102 | case TrueTypeOT: |
103 | return QObject::tr(s: "TrueType (OpenType)" ); |
104 | case CIDType0COT: |
105 | return QObject::tr(s: "CID Type 0C (OpenType)" ); |
106 | case CIDTrueTypeOT: |
107 | return QObject::tr(s: "CID TrueType (OpenType)" ); |
108 | } |
109 | return QObject::tr(s: "Bug: unexpected font type. Notify poppler mailing list!" ); |
110 | } |
111 | |
112 | FontInfo &FontInfo::operator=(const FontInfo &fi) |
113 | { |
114 | if (this == &fi) { |
115 | return *this; |
116 | } |
117 | |
118 | *m_data = *fi.m_data; |
119 | return *this; |
120 | } |
121 | |
122 | FontIterator::FontIterator(int startPage, DocumentData *dd) : d(new FontIteratorData(startPage, dd)) { } |
123 | |
124 | FontIterator::~FontIterator() |
125 | { |
126 | delete d; |
127 | } |
128 | |
129 | QList<FontInfo> FontIterator::next() |
130 | { |
131 | ++d->currentPage; |
132 | |
133 | QList<FontInfo> fonts; |
134 | const std::vector<::FontInfo *> items = d->fontInfoScanner.scan(nPages: 1); |
135 | fonts.reserve(asize: items.size()); |
136 | for (::FontInfo *entry : items) { |
137 | fonts.append(t: FontInfo(FontInfoData(entry))); |
138 | delete entry; |
139 | } |
140 | |
141 | return fonts; |
142 | } |
143 | |
144 | bool FontIterator::hasNext() const |
145 | { |
146 | return (d->currentPage + 1) < d->totalPages; |
147 | } |
148 | |
149 | int FontIterator::currentPage() const |
150 | { |
151 | return d->currentPage; |
152 | } |
153 | |
154 | } |
155 | |