Commit 6a7b1eaa authored by Brad Hards's avatar Brad Hards

* qt4/src/poppler-qt4.h:

  qt4/src/fontinfo.cc: add implementation for FontInfo::typeName()

* qt4/tests/check_fonts.cpp:
* qt4/tests/Makefile.am: add unit test for fonts

* qt4/src/Mainpage.dox: Minor typo fixes.
parent 31b28b4c
2005-12-04 Brad Hards <bradh@frogmouth.net>
* qt4/src/poppler-qt4.h:
qt4/src/fontinfo.cc: add implementation for
FontInfo::typeName()
* qt4/tests/check_fonts.cpp:
* qt4/tests/Makefile.am: add unit test for fonts
* qt4/src/Mainpage.dox: Minor typo fixes.
2005-12-03 Kristian Høgsberg <krh@redhat.com>
* glib/poppler-page.cc (poppler_page_set_selection_alpha): Use
......
/**
@mainpage The Poppler Qt4 interface library
The Poppler Qt4 interface library, libpoppler-qt4, is library that
The Poppler Qt4 interface library, libpoppler-qt4, is a library that
allows Qt4 programmers to easily load and render PDF files. The
Poppler Qt4 interface library uses poppler internally to do its job,
but the Qt4 programmer will never have to worry about poppler
......@@ -38,7 +38,8 @@ simply need to add the following two lines to their C++ source files:
@endcode
The #define statement is required at the moment. You indicate that you
think you know what you are doing.
think you know what you are doing, and understand that the API is
subject to change.
A PDF document can then be loaded as follows.
@code
......
......@@ -66,4 +66,28 @@ FontInfo::Type FontInfo::type() const
return m_data->type;
}
const 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");
default:
return QObject::tr("Bug: unexpected font type. Notify poppler mailing list!");
}
}
}
......@@ -96,10 +96,22 @@ namespace Poppler {
/**
The type of font encoding
\return a enumerated value corresponding to the font encoding used
\sa typeName for a string equivalent
*/
Type type() const;
const QString &typeName() const;
/**
The name of the font encoding used
\note if you are looking for the name of the font (as opposed to the
encoding format used), you probably want name().
\sa type for a enumeration version
*/
const QString typeName() const;
private:
FontInfoData *m_data;
......
......@@ -46,6 +46,7 @@ stress_poppler_qt4_LDADD = $(LDADDS)
if BUILD_POPPLER_QT4TESTS
TESTS = \
check_fonts \
check_metadata \
check_permissions \
check_pagemode \
......@@ -53,6 +54,10 @@ TESTS = \
check_PROGRAMS = $(TESTS)
check_fonts_SOURCES = check_fonts.cpp
check_fonts.$(OBJEXT): check_fonts.moc
check_fonts_LDADD = $(UT_LDADDS)
check_metadata_SOURCES = check_metadata.cpp
check_metadata.$(OBJEXT): check_metadata.moc
check_metadata_LDADD = $(UT_LDADDS)
......
#include <QtTest/QtTest>
#define UNSTABLE_POPPLER_QT4
#include <poppler-qt4.h>
class TestFontsData: public QObject
{
Q_OBJECT
private slots:
void checkNoFonts();
void checkType1();
};
void TestFontsData::checkNoFonts()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/tests/image.pdf");
QVERIFY( doc );
QList<Poppler::FontInfo> listOfFonts = doc->fonts();
QCOMPARE( listOfFonts.size(), 0 );
}
void TestFontsData::checkType1()
{
Poppler::Document *doc;
doc = Poppler::Document::load("../../../test/tests/text.pdf");
QVERIFY( doc );
QList<Poppler::FontInfo> listOfFonts = doc->fonts();
QCOMPARE( listOfFonts.size(), 1 );
QCOMPARE( listOfFonts.at(0).name(), QString("Helvetica") );
QCOMPARE( listOfFonts.at(0).type(), Poppler::FontInfo::Type1 );
QCOMPARE( listOfFonts.at(0).typeName(), QString("Type 1") );
QCOMPARE( listOfFonts.at(0).isEmbedded(), false );
QCOMPARE( listOfFonts.at(0).isSubset(), false );
}
QTEST_MAIN(TestFontsData)
#include "check_fonts.moc"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment