Commit a738c98c authored by Jan Grulich's avatar Jan Grulich Committed by Albert Astals Cid

Add information about substituting font into properties dialog

Reviewers: aacid

Subscribers: pino, ngraham, okular-devel

Tags: #okular

Differential Revision: https://phabricator.kde.org/D23027
parent f9e6b3e6
......@@ -27,6 +27,7 @@ class Okular::FontInfoPrivate
bool operator==( const FontInfoPrivate &rhs ) const
{
return name == rhs.name &&
substituteName == rhs.substituteName &&
type == rhs.type &&
embedType == rhs.embedType &&
file == rhs.file &&
......@@ -34,6 +35,7 @@ class Okular::FontInfoPrivate
}
QString name;
QString substituteName;
FontInfo::FontType type;
FontInfo::EmbedType embedType;
bool canBeExtracted;
......@@ -66,6 +68,16 @@ void FontInfo::setName( const QString& name )
d->name = name;
}
QString FontInfo::substituteName() const
{
return d->substituteName;
}
void FontInfo::setSubstituteName( const QString& substituteName )
{
d->substituteName = substituteName;
}
FontInfo::FontType FontInfo::type() const
{
return d->type;
......
......@@ -84,6 +84,16 @@ class OKULARCORE_EXPORT FontInfo
*/
void setName( const QString& name );
/**
* Returns the substitute name for the font.
*/
QString substituteName() const;
/**
* Sets a new substitute name for the font.
*/
void setSubstituteName( const QString& substituteName );
/**
* Returns the type of the font.
*/
......
......@@ -156,6 +156,16 @@ int main()
}
" HAVE_POPPLER_0_79)
check_cxx_source_compiles("
#include <poppler-qt5.h>
int main()
{
Poppler::FontInfo info;
QString substituteName = info.substituteName();
return 0;
}
" HAVE_POPPLER_0_80)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/config-okular-poppler.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/config-okular-poppler.h
......
......@@ -48,3 +48,6 @@
/* Defined if we have the 0.79 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_79 1
/* Defined if we have the 0.80 version of the Poppler library */
#cmakedefine HAVE_POPPLER_0_80 1
......@@ -942,6 +942,9 @@ Okular::FontInfo::List PDFGenerator::fontsForPage( int page )
{
Okular::FontInfo of;
of.setName( font.name() );
#ifdef HAVE_POPPLER_0_80
of.setSubstituteName( font.substituteName() );
#endif
of.setType( convertPopplerFontInfoTypeToOkularFontInfoType( font.type() ) );
of.setEmbedType( embedTypeForPopplerFontInfo( font) );
of.setFile( font.file() );
......
......@@ -355,7 +355,12 @@ QVariant FontsListModel::data( const QModelIndex &index, int role ) const
{
case 0:
{
QString fontname = m_fonts.at( index.row() ).name();
const Okular::FontInfo &fi = m_fonts.at( index.row() );
const QString fontname = fi.name();
const QString substituteName = fi.substituteName();
if ( fi.embedType() == Okular::FontInfo::NotEmbedded && !substituteName.isEmpty() && !fontname.isEmpty() && substituteName != fontname ) {
return i18nc("Replacing missing font with another one", "%1 (substituting with %2)", fontname, substituteName);
}
return fontname.isEmpty() ? i18nc( "font name not available (empty)", "[n/a]" ) : fontname;
break;
}
......
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