From 3fd552ef219e833386eb640e68560ded1475e77b Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 8 Jul 2007 16:07:37 +0000 Subject: [PATCH] Extend the FontInfo class to distinguish the different types of font embedding. svn path=/trunk/KDE/kdegraphics/okular/; revision=685317 --- core/fontinfo.cpp | 14 +++++++------- core/fontinfo.h | 18 ++++++++++++++---- generators/poppler/generator_pdf.cpp | 2 +- ui/propertiesdialog.cpp | 19 ++++++++++++++++++- 4 files changed, 40 insertions(+), 13 deletions(-) diff --git a/core/fontinfo.cpp b/core/fontinfo.cpp index 51b7baa03..333414ccf 100644 --- a/core/fontinfo.cpp +++ b/core/fontinfo.cpp @@ -17,7 +17,7 @@ class Okular::FontInfoPrivate { public: FontInfoPrivate() - : name( 0 ), type( FontInfo::Unknown ), embedded( true ) + : name( 0 ), type( FontInfo::Unknown ), embedType( FontInfo::NotEmbedded ) { } @@ -25,13 +25,13 @@ class Okular::FontInfoPrivate { return name == rhs.name && type == rhs.type && - embedded == rhs.embedded && + embedType == rhs.embedType && file == rhs.file; } QString name; FontInfo::FontType type; - bool embedded; + FontInfo::EmbedType embedType; QString file; }; @@ -70,14 +70,14 @@ void FontInfo::setType( FontInfo::FontType type ) d->type = type; } -bool FontInfo::isEmbedded() const +FontInfo::EmbedType FontInfo::embedType() const { - return d->embedded; + return d->embedType; } -void FontInfo::setEmbedded( bool embedded ) +void FontInfo::setEmbedType( FontInfo::EmbedType type ) { - d->embedded = embedded; + d->embedType = type; } QString FontInfo::file() const diff --git a/core/fontinfo.h b/core/fontinfo.h index f56dea202..697c220bd 100644 --- a/core/fontinfo.h +++ b/core/fontinfo.h @@ -48,6 +48,16 @@ class OKULAR_EXPORT FontInfo CIDTrueTypeOT }; + /** + * The possible kinds of embed. + */ + enum EmbedType + { + NotEmbedded, + EmbeddedSubSet, + Embedded + }; + /** * Construct a new empty font info. */ @@ -80,13 +90,13 @@ class OKULAR_EXPORT FontInfo void setType( FontType type ); /** - * Returns whether the font is embedded into the document. + * Returns the type of font embedding. */ - bool isEmbedded() const; + EmbedType embedType() const; /** - * Sets whether the font is embedded into the document. + * Sets the type of font embedding. */ - void setEmbedded( bool embedded ); + void setEmbedType( EmbedType type ); /** * In case of not embedded font, returns the path of the font that diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp index df64108d0..f7ffab279 100644 --- a/generators/poppler/generator_pdf.cpp +++ b/generators/poppler/generator_pdf.cpp @@ -657,7 +657,7 @@ Okular::FontInfo::List PDFGenerator::fontsForPage( int /*page*/ ) Okular::FontInfo of; of.setName( font.name() ); of.setType( convertPopplerFontInfoTypeToOkularFontInfoType( font.type() ) ); - of.setEmbedded( font.isEmbedded() ); + of.setEmbedType( font.isEmbedded() ? Okular::FontInfo::Embedded : Okular::FontInfo::NotEmbedded ); of.setFile( font.file() ); list.append( of ); diff --git a/ui/propertiesdialog.cpp b/ui/propertiesdialog.cpp index 383f1c1b2..40b9d1b9f 100644 --- a/ui/propertiesdialog.cpp +++ b/ui/propertiesdialog.cpp @@ -231,6 +231,23 @@ static QString descriptionForFontType( Okular::FontInfo::FontType type ) return QString(); } +static QString descriptionForEmbedType( Okular::FontInfo::EmbedType type ) +{ + switch ( type ) + { + case Okular::FontInfo::NotEmbedded: + return i18n("No"); + break; + case Okular::FontInfo::EmbeddedSubSet: + return i18n("Yes (subset)"); + break; + case Okular::FontInfo::Embedded: + return i18n("Yes"); + break; + } + return QString(); +} + QVariant FontsListModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) @@ -246,7 +263,7 @@ QVariant FontsListModel::data( const QModelIndex &index, int role ) const { case 0: return m_fonts.at( index.row() ).name(); break; case 1: return descriptionForFontType( m_fonts.at( index.row() ).type() ); break; - case 2: return m_fonts.at( index.row() ).isEmbedded() ? i18n( "Yes" ) : i18n( "No" ); break; + case 2: return descriptionForEmbedType( m_fonts.at( index.row() ).embedType() ); break; case 3: return m_fonts.at( index.row() ).file(); break; default: return QVariant();