~ubuntu-branches/ubuntu/maverick/kdegraphics/maverick-proposed

« back to all changes in this revision

Viewing changes to okular/generators/dvi/generator_dvi.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-12-02 14:03:43 UTC
  • mfrom: (1.1.35 upstream)
  • Revision ID: james.westby@ubuntu.com-20091202140343-2732gbkj69g89arq
Tags: 4:4.3.80-0ubuntu1
* New upstream beta release:
  - Add build-depend on shared-desktop-ontologies for nepomuk integration
  - Bump .so versions for libkexiv, libkdcraw and libkipi
  - Update various .install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/***************************************************************************
2
 
 *   Copyright (C) 2006 by Luigi Toscano <luigi.toscano@tiscali.it>        *
 
2
 *   Copyright (C) 2006-2009 by Luigi Toscano <luigi.toscano@tiscali.it>   *
3
3
 *                                                                         *
4
4
 *   This program is free software; you can redistribute it and/or modify  *
5
5
 *   it under the terms of the GNU General Public License as published by  *
21
21
#include "dviRenderer.h"
22
22
#include "pageSize.h"
23
23
#include "dviexport.h"
 
24
#include "TeXFont.h"
24
25
 
25
26
#include <qapplication.h>
26
27
#include <qstring.h>
62
63
OKULAR_EXPORT_PLUGIN( DviGenerator, createAboutData() )
63
64
 
64
65
DviGenerator::DviGenerator( QObject *parent, const QVariantList &args ) : Okular::Generator( parent, args ),
65
 
  m_docInfo( 0 ), m_docSynopsis( 0 ), m_dviRenderer( 0 )
 
66
  m_fontExtracted( false ), m_docInfo( 0 ), m_docSynopsis( 0 ), m_dviRenderer( 0 )
66
67
{
67
68
    setFeature( Threaded );
68
69
    setFeature( TextExtraction );
 
70
    setFeature( FontInfo );
69
71
    setFeature( PrintPostscript );
70
72
    if ( Okular::FilePrinter::ps2pdfAvailable() )
71
73
        setFeature( PrintToFile );
78
80
 
79
81
    (void)userMutex();
80
82
 
81
 
    m_dviRenderer = new dviRenderer();
 
83
    m_dviRenderer = new dviRenderer(documentMetaData("TextHinting", QVariant()).toBool());
82
84
#ifdef DVI_OPEN_BUSYLOOP
83
85
    static const ushort s_waitTime = 800; // milliseconds
84
86
    static const int s_maxIterations = 10;
135
137
    m_dviRenderer = 0;
136
138
 
137
139
    m_linkGenerated.clear();
 
140
    m_fontExtracted = false;
138
141
 
139
142
    return true;
140
143
}
402
405
    return m_docSynopsis;
403
406
}
404
407
 
 
408
Okular::FontInfo::List DviGenerator::fontsForPage( int page )
 
409
{
 
410
    Q_UNUSED( page );
 
411
 
 
412
    Okular::FontInfo::List list;
 
413
 
 
414
    // the list of the fonts is extracted once 
 
415
    if ( m_fontExtracted )
 
416
        return list;
 
417
 
 
418
    if ( m_dviRenderer && m_dviRenderer->dviFile &&
 
419
         m_dviRenderer->dviFile->font_pool )
 
420
    {
 
421
        QList<TeXFontDefinition*> fonts = m_dviRenderer->dviFile->font_pool->fontList;
 
422
 
 
423
        foreach (const TeXFontDefinition* font, fonts)
 
424
        {
 
425
            Okular::FontInfo of;
 
426
            QString name;
 
427
            int zoom = (int)(font->enlargement*100 + 0.5);
 
428
            if ( font->getFullFontName().isEmpty() ) 
 
429
            {
 
430
                name = QString( "%1, %2%" )
 
431
                        .arg( font->fontname )
 
432
                        .arg( zoom );
 
433
            }
 
434
            else
 
435
            {
 
436
                name = QString( "%1 (%2), %3%" ) 
 
437
                        .arg( font->fontname )
 
438
                        .arg( font->getFullFontName() ) 
 
439
                        .arg( zoom ); 
 
440
            }
 
441
            of.setName( name );
 
442
 
 
443
            QString fontFileName;
 
444
            if (!(font->flags & TeXFontDefinition::FONT_VIRTUAL)) {
 
445
                if ( font->font != 0 )
 
446
                    fontFileName = font->font->errorMessage;
 
447
                else
 
448
                    fontFileName = i18n("Font file not found");
 
449
 
 
450
                if ( fontFileName.isEmpty() )
 
451
                    fontFileName = font->filename;
 
452
            }
 
453
 
 
454
            of.setFile( fontFileName );
 
455
 
 
456
            Okular::FontInfo::FontType ft;
 
457
            switch ( font->getFontType() )
 
458
            {
 
459
                case TeXFontDefinition::TEX_PK:
 
460
                    ft = Okular::FontInfo::TeXPK;
 
461
                    break;
 
462
                case TeXFontDefinition::TEX_VIRTUAL:
 
463
                    ft = Okular::FontInfo::TeXVirtual;
 
464
                    break;
 
465
                case TeXFontDefinition::TEX_FONTMETRIC:
 
466
                    ft = Okular::FontInfo::TeXFontMetric;
 
467
                    break;
 
468
                case TeXFontDefinition::FREETYPE:
 
469
                    ft = Okular::FontInfo::TeXFreeTypeHandled;
 
470
                    break;
 
471
            }
 
472
            of.setType( ft );
 
473
 
 
474
            // DVI has not the concept of "font embedding"
 
475
            of.setEmbedType( Okular::FontInfo::NotEmbedded );
 
476
            of.setCanBeExtracted( false );
 
477
 
 
478
            list.append( of );
 
479
        }
 
480
 
 
481
        m_fontExtracted = true;
 
482
 
 
483
    }
 
484
 
 
485
    return list;
 
486
}
 
487
 
405
488
void DviGenerator::loadPages( QVector< Okular::Page * > &pagesVector )
406
489
{
407
490
    QSize pageRequiredSize;