1 | #include <QtCore/QCoreApplication> |
---|---|
2 | #include <QtCore/QDebug> |
3 | |
4 | #include <iostream> |
5 | |
6 | #include <poppler-qt6.h> |
7 | |
8 | int main(int argc, char **argv) |
9 | { |
10 | QCoreApplication a(argc, argv); // QApplication required! |
11 | |
12 | if (!(argc == 2)) { |
13 | qWarning() << "usage: poppler-fonts filename"; |
14 | exit(status: 1); |
15 | } |
16 | |
17 | std::unique_ptr<Poppler::Document> doc = Poppler::Document::load(filePath: argv[1]); |
18 | if (!doc) { |
19 | qWarning() << "doc not loaded"; |
20 | exit(status: 1); |
21 | } |
22 | |
23 | std::cout << "name type emb sub font file"; |
24 | std::cout << std::endl; |
25 | std::cout << "------------------------------------ ------------ --- --- ---------"; |
26 | std::cout << std::endl; |
27 | |
28 | foreach (const Poppler::FontInfo &font, doc->fonts()) { |
29 | if (font.name().isNull()) { |
30 | std::cout << qPrintable(QStringLiteral("%1").arg(QStringLiteral( "[none]"), -37)); |
31 | } else { |
32 | std::cout << qPrintable(QStringLiteral("%1").arg(font.name(), -37)); |
33 | } |
34 | switch (font.type()) { |
35 | case Poppler::FontInfo::unknown: |
36 | std::cout << "unknown "; |
37 | break; |
38 | case Poppler::FontInfo::Type1: |
39 | std::cout << "Type 1 "; |
40 | break; |
41 | case Poppler::FontInfo::Type1C: |
42 | std::cout << "Type 1C "; |
43 | break; |
44 | case Poppler::FontInfo::Type3: |
45 | std::cout << "Type 3 "; |
46 | break; |
47 | case Poppler::FontInfo::TrueType: |
48 | std::cout << "TrueType "; |
49 | break; |
50 | case Poppler::FontInfo::CIDType0: |
51 | std::cout << "CID Type 0 "; |
52 | break; |
53 | case Poppler::FontInfo::CIDType0C: |
54 | std::cout << "CID Type 0C "; |
55 | break; |
56 | case Poppler::FontInfo::CIDTrueType: |
57 | std::cout << "CID TrueType "; |
58 | break; |
59 | case Poppler::FontInfo::Type1COT: |
60 | std::cout << "Type 1C (OT) "; |
61 | break; |
62 | case Poppler::FontInfo::TrueTypeOT: |
63 | std::cout << "TrueType (OT) "; |
64 | break; |
65 | case Poppler::FontInfo::CIDType0COT: |
66 | std::cout << "CID Type 0C (OT) "; |
67 | break; |
68 | case Poppler::FontInfo::CIDTrueTypeOT: |
69 | std::cout << "CID TrueType (OT) "; |
70 | break; |
71 | } |
72 | |
73 | if (font.isEmbedded()) { |
74 | std::cout << "yes "; |
75 | } else { |
76 | std::cout << "no "; |
77 | } |
78 | if (font.isSubset()) { |
79 | std::cout << "yes "; |
80 | } else { |
81 | std::cout << "no "; |
82 | } |
83 | std::cout << qPrintable(font.file()); |
84 | std::cout << std::endl; |
85 | } |
86 | } |
87 |