"Fossies" - the Fresh Open Source Software Archive

Member "poppler-0.82.0/qt5/tests/poppler-fonts.cpp" (25 Oct 2019, 2308 Bytes) of package /linux/misc/poppler-0.82.0.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

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