summaryrefslogtreecommitdiff
path: root/qt5/src/poppler-fontinfo.cc
blob: f2a55790ab14f8436025caa1a2b7aa82dc8c7eed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* poppler-qt.h: qt interface to poppler
 * Copyright (C) 2005, Net Integration Technologies, Inc.
 * Copyright (C) 2005, Tobias Koening <tokoe@kde.org>
 * Copyright (C) 2005, Brad Hards <bradh@frogmouth.net>
 * Copyright (C) 2005-2008, Albert Astals Cid <aacid@kde.org>
 * Copyright (C) 2008, 2009, Pino Toscano <pino@kde.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include "poppler-qt5.h"
#include "poppler-private.h"

namespace Poppler {

FontInfo::FontInfo()
{
	m_data = new FontInfoData();
}

FontInfo::FontInfo( const FontInfoData &fid )
{
	m_data = new FontInfoData(fid);
}

FontInfo::FontInfo( const FontInfo &fi )
{
	m_data = new FontInfoData(*fi.m_data);
}

FontInfo::~FontInfo()
{
	delete m_data;
}

QString FontInfo::name() const
{
	return m_data->fontName;
}

QString FontInfo::file() const
{
	return m_data->fontFile;
}

bool FontInfo::isEmbedded() const
{
	return m_data->isEmbedded;
}

bool FontInfo::isSubset() const
{
	return m_data->isSubset;
}

FontInfo::Type FontInfo::type() const
{
	return m_data->type;
}

QString FontInfo::typeName() const
{
	switch (type()) {
	case unknown:
		return QObject::tr("unknown");
	case Type1:
		return QObject::tr("Type 1");
	case Type1C:
		return QObject::tr("Type 1C");
	case Type3:
		return QObject::tr("Type 3");
	case TrueType:
		return QObject::tr("TrueType");
	case CIDType0:
		return QObject::tr("CID Type 0");
	case CIDType0C:
		return QObject::tr("CID Type 0C");
	case CIDTrueType:
		return QObject::tr("CID TrueType");
	case Type1COT:
		return QObject::tr("Type 1C (OpenType)");
	case TrueTypeOT:
		return QObject::tr("TrueType (OpenType)");
	case CIDType0COT:
		return QObject::tr("CID Type 0C (OpenType)");
	case CIDTrueTypeOT:
		return QObject::tr("CID TrueType (OpenType)");
	}
	return QObject::tr("Bug: unexpected font type. Notify poppler mailing list!");
}

FontInfo& FontInfo::operator=( const FontInfo &fi )
{
	if (this == &fi)
		return *this;

	*m_data = *fi.m_data;
	return *this;
}


FontIterator::FontIterator( int startPage, DocumentData *dd )
	: d( new FontIteratorData( startPage, dd ) )
{
}

FontIterator::~FontIterator()
{
	delete d;
}

QList<FontInfo> FontIterator::next()
{
	++d->currentPage;

	QList<FontInfo> fonts;
	GooList *items = d->fontInfoScanner.scan( 1 );
	if ( !items )
		return fonts;
	for ( int i = 0; i < items->getLength(); ++i ) {
		fonts.append( FontInfo( FontInfoData( ( ::FontInfo* )items->get( i ) ) ) );
	}
	deleteGooList( items, ::FontInfo );
	return fonts;
}

bool FontIterator::hasNext() const
{
	return ( d->currentPage + 1 ) < d->totalPages;
}

int FontIterator::currentPage() const
{
	return d->currentPage;
}

}