mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-25 02:45:38 +00:00
svn path=/trunk/kdegraphics/kdvi/; revision=87135
This commit is contained in:
parent
9c9ee93e0c
commit
c84d0211f2
2
TODO
2
TODO
|
@ -24,8 +24,6 @@ o Support papersize information given by the dvi-file on a page-by-page
|
|||
|
||||
o Extra enlargement of characters for improved readability should be switchable.
|
||||
|
||||
o Rotated Postscript should be supported.
|
||||
|
||||
|
||||
NOT SO URGENT
|
||||
|
||||
|
|
|
@ -183,15 +183,17 @@ void dviWindow::setMakePK( int flag )
|
|||
|
||||
void dviWindow::setMetafontMode( unsigned int mode )
|
||||
{
|
||||
if (dviFile != NULL)
|
||||
if ((dviFile != NULL) && (mode != font_pool->getMetafontMode()))
|
||||
KMessageBox::sorry( this,
|
||||
i18n("The change in Metafont mode will be effective\n"
|
||||
"only after you start kdvi again!") );
|
||||
|
||||
|
||||
MetafontMode = font_pool->setMetafontMode(mode);
|
||||
basedpi = MFResolutions[MetafontMode];
|
||||
_pixels_per_inch = MFResolutions[MetafontMode];
|
||||
#ifdef DEBUG
|
||||
kdDebug() << "basedpi " << basedpi << endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
1
dviwin.h
1
dviwin.h
|
@ -81,6 +81,7 @@ public:
|
|||
void special(long nbytes);
|
||||
void bang_special(QString cp);
|
||||
void quote_special(QString cp);
|
||||
void ps_special(QString cp);
|
||||
void epsf_special(QString cp);
|
||||
void header_special(QString cp);
|
||||
void html_href_special(QString cp);
|
||||
|
|
|
@ -518,15 +518,14 @@ void dviWindow::draw_page(void)
|
|||
#endif
|
||||
|
||||
// Render the PostScript background, if there is one.
|
||||
foreGroundPaint.fillRect(pixmap->rect(), Qt::white );
|
||||
if (_postscript) {
|
||||
QPixmap *pxm = PS_interface->graphics(current_page);
|
||||
if (pxm != NULL) {
|
||||
foreGroundPaint.drawPixmap(0, 0, *pxm);
|
||||
delete pxm;
|
||||
} else
|
||||
foreGroundPaint.fillRect(pixmap->rect(), Qt::white );
|
||||
} else
|
||||
foreGroundPaint.fillRect(pixmap->rect(), Qt::white );
|
||||
}
|
||||
}
|
||||
|
||||
// Step 4: Now really write the text
|
||||
(void) lseek(fileno(dviFile->file), dviFile->page_offset[current_page], SEEK_SET);
|
||||
|
|
9
font.cpp
9
font.cpp
|
@ -28,16 +28,11 @@ extern int n_files_left;
|
|||
#define VF_ID_BYTE 202
|
||||
#define VF_MAGIC (VF_PRE << 8) + VF_ID_BYTE
|
||||
|
||||
#define DEBUG_FONT 1
|
||||
|
||||
void font::font_name_receiver(KProcess *, char *buffer, int buflen)
|
||||
void font::fontNameReceiver(QString fname)
|
||||
{
|
||||
if (buflen < 3)
|
||||
return;
|
||||
|
||||
flags |= font::FONT_LOADED;
|
||||
|
||||
filename = QString::fromLocal8Bit(buffer, buflen-1);
|
||||
filename = fname;
|
||||
|
||||
#ifdef DEBUG_FONT
|
||||
kdDebug() << "FONT NAME RECEIVED:" << filename << endl;
|
||||
|
|
2
font.h
2
font.h
|
@ -94,7 +94,7 @@ private:
|
|||
void read_PK_index(void);
|
||||
|
||||
public slots:
|
||||
void font_name_receiver(KProcess *proc, char *buffer, int buflen);
|
||||
void fontNameReceiver(QString);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
218
fontpool.cpp
218
fontpool.cpp
|
@ -24,9 +24,9 @@ fontPool::fontPool(void)
|
|||
unsigned int fontPool::setMetafontMode( unsigned int mode )
|
||||
{
|
||||
if (mode >= NumberOfMFModes) {
|
||||
kdError() << "fontPool::setMetafontMode called with argument " << mode
|
||||
kdError(4300) << "fontPool::setMetafontMode called with argument " << mode
|
||||
<< " which is more than the allowed value of " << NumberOfMFModes-1 << endl;
|
||||
kdError() << "setting mode to " << MFModes[DefaultMFMode] << " at "
|
||||
kdError(4300) << "setting mode to " << MFModes[DefaultMFMode] << " at "
|
||||
<< MFResolutions[DefaultMFMode] << "dpi" << endl;
|
||||
mode = DefaultMFMode;
|
||||
}
|
||||
|
@ -37,6 +37,19 @@ unsigned int fontPool::setMetafontMode( unsigned int mode )
|
|||
void fontPool::setMakePK(int flag)
|
||||
{
|
||||
makepk = flag;
|
||||
|
||||
// If we just diabled font generation, there is nothing left to do.
|
||||
if (flag == 0)
|
||||
return;
|
||||
|
||||
// If we enable font generation, we look for fonts which have not
|
||||
// yet been loaded, mark them as "not yet looked up" and try once
|
||||
// more.
|
||||
struct font *fontp;
|
||||
for (fontp=fontList.first(); fontp != 0; fontp=fontList.next() )
|
||||
if (fontp->filename.isEmpty() )
|
||||
fontp->flags &= ~font::FONT_KPSE_NAME;
|
||||
check_if_fonts_are_loaded();
|
||||
}
|
||||
|
||||
|
||||
|
@ -57,14 +70,13 @@ class font *fontPool::appendx(char *fontname, float fsize, long checksum, int ma
|
|||
// if font doesn't exist yet
|
||||
fontp = new font(fontname, fsize, checksum, magstepval, dconv, this);
|
||||
if (fontp == 0) {
|
||||
kdError() << i18n("Could not allocate memory for a font structure!") << endl;
|
||||
kdError(4300) << i18n("Could not allocate memory for a font structure!") << endl;
|
||||
exit(0);
|
||||
}
|
||||
|
||||
fontList.append(fontp);
|
||||
|
||||
// Now start kpsewhich/MetaFont, etc. if necessary
|
||||
check_if_fonts_are_loaded();
|
||||
return fontp;
|
||||
}
|
||||
|
||||
|
@ -96,125 +108,141 @@ void fontPool::status(void)
|
|||
else
|
||||
entry.append(i18n(" filename has not (yet) been looked up"));
|
||||
|
||||
kdDebug() << entry << endl;
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug(4300) << entry << endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char fontPool::check_if_fonts_are_loaded(void)
|
||||
char fontPool::check_if_fonts_are_loaded(unsigned char pass)
|
||||
{
|
||||
struct font *fontp;
|
||||
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug() << "Check if fonts have been looked for..." << endl;
|
||||
kdDebug(4300) << "Check if fonts have been looked for..." << endl;
|
||||
#endif
|
||||
|
||||
// Check if kpsewhich is still running. In that case there certainly
|
||||
// not all fonts have been properly looked up.
|
||||
if (proc != 0) {
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug() << "... no, kpsewhich is still running." << endl;
|
||||
kdDebug(4300) << "... no, kpsewhich is still running." << endl;
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
// Is there a font whose name we did not try to find out yet?
|
||||
for (struct font *fontp=fontList.first(); fontp != 0; fontp=fontList.next() )
|
||||
if ((fontp->flags & font::FONT_KPSE_NAME) == 0) {
|
||||
for (fontp=fontList.first(); fontp != 0; fontp=fontList.next() )
|
||||
if ((fontp->flags & font::FONT_KPSE_NAME) == 0)
|
||||
break;
|
||||
if (fontp == 0) {
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug() << "... no, there are still fonts missing." << endl;
|
||||
kdDebug(4300) << "... yes, all fonts are there, or could not be found." << endl;
|
||||
#endif
|
||||
|
||||
// Mark that we already tried to find the font name, so that we do
|
||||
// not try again, even if that fails.
|
||||
fontp->flags |= font::FONT_KPSE_NAME;
|
||||
return 0; // That says that all fonts are loaded.
|
||||
}
|
||||
|
||||
// Just make sure that MetafontMode is in the permissible range, so
|
||||
// as to avoid core dumps.
|
||||
if (MetafontMode >= NumberOfMFModes) {
|
||||
kdError() << "fontPool::appendx called with bad MetafontMode " << MetafontMode
|
||||
// Just make sure that MetafontMode is in the permissible range, so
|
||||
// as to avoid core dumps.
|
||||
if (MetafontMode >= NumberOfMFModes) {
|
||||
kdError(4300) << "fontPool::appendx called with bad MetafontMode " << MetafontMode
|
||||
<< " which is more than the allowed value of " << NumberOfMFModes-1 << endl;
|
||||
kdError() << "setting mode to " << MFModes[DefaultMFMode] << " at "
|
||||
kdError(4300) << "setting mode to " << MFModes[DefaultMFMode] << " at "
|
||||
<< MFResolutions[DefaultMFMode] << "dpi" << endl;
|
||||
MetafontMode = DefaultMFMode;
|
||||
}
|
||||
MetafontMode = DefaultMFMode;
|
||||
}
|
||||
|
||||
// We attach the ShellProcess to the font. That way the font will be
|
||||
// informed when the file name has been found.
|
||||
proc = new KShellProcess();
|
||||
if (proc == 0) {
|
||||
kdError() << "Could not allocate ShellProcess for the kpsewhich command." << endl;
|
||||
exit(0);
|
||||
}
|
||||
qApp->connect(proc, SIGNAL(receivedStdout(KProcess *, char *, int)),
|
||||
fontp, SLOT(font_name_receiver(KProcess *, char *, int)));
|
||||
// Set up the kpsewhich process. If pass == 0, look for vf-fonts and
|
||||
// disable automatic font generation as vf-fonts can't be
|
||||
// generated. If pass != 0, ennable font generation, if it was
|
||||
// enabled globally.
|
||||
proc = new KShellProcess();
|
||||
if (proc == 0) {
|
||||
kdError(4300) << "Could not allocate ShellProcess for the kpsewhich command." << endl;
|
||||
exit(0);
|
||||
}
|
||||
MetafontOutput.left(0);
|
||||
qApp->connect(proc, SIGNAL(receivedStdout(KProcess *, char *, int)),
|
||||
this, SLOT(kpsewhich_output_receiver(KProcess *, char *, int)));
|
||||
qApp->connect(proc, SIGNAL(processExited(KProcess *)),
|
||||
this, SLOT(kpsewhich_terminated(KProcess *)));
|
||||
qApp->connect(proc, SIGNAL(receivedStderr(KProcess *, char *, int)),
|
||||
this, SLOT(mf_output_receiver(KProcess *, char *, int)));
|
||||
|
||||
// First try if the font is a virtual font
|
||||
proc->clearArguments();
|
||||
*proc << "kpsewhich";
|
||||
*proc << "--format vf";
|
||||
*proc << fontp->fontname;
|
||||
proc->start(KProcess::NotifyOnExit, KProcess::All);
|
||||
while(proc->isRunning())
|
||||
qApp->processEvents();
|
||||
|
||||
// Font not found? Then check if the font is a regular font.
|
||||
if (fontp->filename.isEmpty()) {
|
||||
MetafontOutput.left(0);
|
||||
qApp->connect(proc, SIGNAL(processExited(KProcess *)),
|
||||
this, SLOT(kpsewhich_terminated(KProcess *)));
|
||||
qApp->connect(proc, SIGNAL(receivedStderr(KProcess *, char *, int)),
|
||||
this, SLOT(mf_output_receiver(KProcess *, char *, int)));
|
||||
|
||||
proc->clearArguments();
|
||||
*proc << "kpsewhich";
|
||||
*proc << QString("--dpi %1").arg(MFResolutions[MetafontMode]);
|
||||
*proc << QString("--mode %1").arg(MFModes[MetafontMode]);
|
||||
*proc << "--format pk";
|
||||
if (makepk == 0)
|
||||
*proc << "--no-mktex pk";
|
||||
else
|
||||
*proc << "--mktex pk";
|
||||
*proc << QString("%1.%2").arg(fontp->fontname).arg((int)(fontp->fsize + 0.5));
|
||||
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug() << "kpsewhich"
|
||||
<< QString(" --dpi %1").arg(MFResolutions[MetafontMode])
|
||||
<< QString(" --mode %1").arg(MFModes[MetafontMode])
|
||||
<< " --format pk"
|
||||
<< QString(" %1.%2").arg(fontp->fontname).arg((int)(fontp->fsize + 0.5))
|
||||
<< endl;
|
||||
#endif
|
||||
|
||||
proc->start(KProcess::NotifyOnExit, KProcess::All);
|
||||
return -1;
|
||||
}
|
||||
|
||||
delete proc;
|
||||
proc = 0;
|
||||
|
||||
check_if_fonts_are_loaded();
|
||||
|
||||
return -1; // That says that not all fonts are loaded.
|
||||
proc->clearArguments();
|
||||
*proc << "kpsewhich";
|
||||
*proc << QString("--dpi %1").arg(MFResolutions[MetafontMode]);
|
||||
*proc << QString("--mode %1").arg(MFModes[MetafontMode]);
|
||||
// Enable automatic pk-font generation only in the second pass, and
|
||||
// only if the user expressidly asked for it.
|
||||
if ((makepk == 0) || (pass == 0))
|
||||
*proc << "--no-mktex pk";
|
||||
else
|
||||
*proc << "--mktex pk";
|
||||
for (fontp=fontList.first(); fontp != 0; fontp=fontList.next() )
|
||||
if ((fontp->flags & font::FONT_KPSE_NAME) == 0) {
|
||||
*proc << QString("%1.%2pk").arg(fontp->fontname).arg((int)(fontp->fsize + 0.5));
|
||||
// In the first pass, we look also for virtual fonts.
|
||||
if (pass == 0)
|
||||
*proc << QString("%1.vf").arg(fontp->fontname);
|
||||
// In the second (last) pass, mark the font "looked up". As this
|
||||
// is the last chance that the filename could be found, we
|
||||
// ensure that if the filename is still not found now, we won't
|
||||
// look any further.
|
||||
if (pass != 0)
|
||||
fontp->flags |= font::FONT_KPSE_NAME;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug() << "... yes, all fonts are there, or could not be found." << endl;
|
||||
#endif
|
||||
|
||||
return 0; // That says that all fonts are loaded.
|
||||
kpsewhichOutput = "";
|
||||
proc->start(KProcess::NotifyOnExit, KProcess::All);
|
||||
|
||||
return -1; // That says that not all fonts are loaded.
|
||||
}
|
||||
|
||||
|
||||
void fontPool::kpsewhich_terminated(KProcess *)
|
||||
{
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug() << "kpsewhich terminated" << endl;
|
||||
kdDebug(4300) << "kpsewhich terminated" << endl;
|
||||
#endif
|
||||
|
||||
delete proc;
|
||||
proc = 0;
|
||||
|
||||
if (check_if_fonts_are_loaded() == 0) {
|
||||
kdDebug() << "Emitting fonts_have_been_loaded()" << endl;
|
||||
QStringList fileNameList = QStringList::split('\n', kpsewhichOutput);
|
||||
for (class font *fontp=fontList.first(); fontp != 0; fontp=fontList.next() )
|
||||
if (fontp->filename.isEmpty() == true) {
|
||||
QString fontname = QString("%1.%2pk").arg(fontp->fontname).arg((int)(fontp->fsize + 0.5));
|
||||
QStringList matchingFiles = fileNameList.grep(fontname);
|
||||
if (matchingFiles.isEmpty() != true) {
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug(4300) << "Associated " << fontname << " to " << matchingFiles.first() << endl;
|
||||
#endif
|
||||
fontp->fontNameReceiver(matchingFiles.first());
|
||||
fontp->flags |= font::FONT_KPSE_NAME;
|
||||
continue;
|
||||
}
|
||||
|
||||
fontname = QString("%1.vf").arg(fontp->fontname);
|
||||
matchingFiles = fileNameList.grep(fontname);
|
||||
if (matchingFiles.isEmpty() != true) {
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug(4300) << "Associated " << fontname << "to " << matchingFiles.first() << endl;
|
||||
#endif
|
||||
fontp->fontNameReceiver(matchingFiles.first());
|
||||
fontp->flags |= font::FONT_KPSE_NAME;
|
||||
// Constructing a virtual font will most likely insert other
|
||||
// fonts into the fontList. After that, fontList.next() will
|
||||
// no longer work. It is therefore safer to start over.
|
||||
fontp=fontList.first();
|
||||
}
|
||||
}
|
||||
|
||||
if (check_if_fonts_are_loaded(1) == 0) {
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug(4300) << "Emitting fonts_have_been_loaded()" << endl;
|
||||
#endif
|
||||
emit(fonts_have_been_loaded());
|
||||
}
|
||||
return;
|
||||
|
@ -224,13 +252,13 @@ void fontPool::kpsewhich_terminated(KProcess *)
|
|||
void fontPool::reset_fonts(void)
|
||||
{
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug() << "Reset Fonts" << endl;
|
||||
kdDebug(4300) << "Reset Fonts" << endl;
|
||||
#endif
|
||||
|
||||
struct font *fontp;
|
||||
struct glyph *glyphp;
|
||||
|
||||
for ( fontp =fontList.first(); fontp != 0; fontp=fontList.next() )
|
||||
for ( fontp=fontList.first(); fontp != 0; fontp=fontList.next() )
|
||||
if ((fontp->flags & font::FONT_LOADED) && !(fontp->flags & font::FONT_VIRTUAL))
|
||||
for (glyphp = fontp->glyphtable; glyphp < fontp->glyphtable + font::max_num_of_chars_in_font; ++glyphp)
|
||||
glyphp->clearShrunkCharacter();
|
||||
|
@ -239,7 +267,7 @@ void fontPool::reset_fonts(void)
|
|||
void fontPool::mark_fonts_as_unused(void)
|
||||
{
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug() << "Mark_fonts_as_unused" << endl;
|
||||
kdDebug(4300) << "Mark_fonts_as_unused" << endl;
|
||||
#endif
|
||||
|
||||
struct font *fontp;
|
||||
|
@ -251,7 +279,7 @@ void fontPool::mark_fonts_as_unused(void)
|
|||
void fontPool::release_fonts(void)
|
||||
{
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug() << "Release_fonts" << endl;
|
||||
kdDebug(4300) << "Release_fonts" << endl;
|
||||
#endif
|
||||
|
||||
struct font *fontp = fontList.first();
|
||||
|
@ -277,7 +305,13 @@ void fontPool::mf_output_receiver(KProcess *, char *buffer, int buflen)
|
|||
|
||||
// We'd like to print only full lines of text.
|
||||
while( (numleft = MetafontOutput.find('\n')) != -1) {
|
||||
kdDebug() << "MF OUTPUT RECEIVED: " << MetafontOutput.left(numleft+1);
|
||||
kdDebug(4300) << "MF OUTPUT RECEIVED: " << MetafontOutput.left(numleft+1);
|
||||
MetafontOutput = MetafontOutput.remove(0,numleft+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void fontPool::kpsewhich_output_receiver(KProcess *, char *buffer, int buflen)
|
||||
{
|
||||
kpsewhichOutput.append(QString::fromLocal8Bit(buffer, buflen));
|
||||
}
|
||||
|
|
26
fontpool.h
26
fontpool.h
|
@ -49,6 +49,10 @@ Q_OBJECT
|
|||
the DefaultMFMode as defined in fontPool.h */
|
||||
unsigned int setMetafontMode( unsigned int );
|
||||
|
||||
/** Return the currently set MetafontMode */
|
||||
|
||||
unsigned int getMetafontMode(void) {return MetafontMode;};
|
||||
|
||||
/** Says whether fonts will be generated by running MetaFont, or a
|
||||
similar programm. If (flag == 0), fonts will not be generated,
|
||||
otherwise they will. */
|
||||
|
@ -69,8 +73,19 @@ Q_OBJECT
|
|||
void reset_fonts(void);
|
||||
|
||||
/** Checks if all the fonts are loaded and returns 0 if that is
|
||||
so. Otherwise, returns -1. */
|
||||
char check_if_fonts_are_loaded(void);
|
||||
so. Otherwise, returns -1. The argument is used only internally
|
||||
and should always be 0, except for internal use. Actually, the
|
||||
argument works in the following manner: if pass==0, then the
|
||||
method looks for pk-fonts and virtual fonts, and disables
|
||||
automatic pk generation, even if it is turned on with the
|
||||
setMakePK-method. If pass!=0, then only pk fonts are looked for,
|
||||
and fonts are generated, if necessary. This method works in
|
||||
stages: first, it is called with pass=0, and vf-fonts are
|
||||
loaded. These may define further pk-fonts. The pk-fonts will be
|
||||
loaded/generated in the second stage with pass!=0 which is
|
||||
called automatically when the first instance of the kpsewhich
|
||||
programm exists. */
|
||||
char check_if_fonts_are_loaded(unsigned char pass=0);
|
||||
|
||||
/** This is the list which actually enumerates the fonts in the
|
||||
fontPool */
|
||||
|
@ -105,6 +120,11 @@ public slots:
|
|||
to the fontpool via this slot. */
|
||||
void mf_output_receiver(KProcess *, char *, int);
|
||||
|
||||
/** For internal purposess only. This slot is called when kpsewhich
|
||||
outputs the name of a font which has been found or was
|
||||
generated. */
|
||||
void kpsewhich_output_receiver(KProcess *, char *, int);
|
||||
|
||||
private:
|
||||
/** This flag determined whether we try to have MetaFont generate the
|
||||
font if a bitmap is not available. If makepk == 0, then bitmaps
|
||||
|
@ -122,6 +142,8 @@ private:
|
|||
programm while we are waiting for a full screen line */
|
||||
QString MetafontOutput;
|
||||
|
||||
QString kpsewhichOutput;
|
||||
|
||||
/** This is the ShellProcess which is used to run the kpsewhich
|
||||
command which locates the font-files for us. */
|
||||
KShellProcess *proc;
|
||||
|
|
2
kdvi.h
2
kdvi.h
|
@ -8,5 +8,5 @@
|
|||
// Define the following flags to generate debugging output
|
||||
|
||||
// #define DEBUG_FONT 1
|
||||
#define DEBUG_FONTPOOL 1
|
||||
// #define DEBUG_FONTPOOL 1
|
||||
// #define DEBUG_PK 1
|
||||
|
|
|
@ -289,7 +289,7 @@ void KDVIMultiPage::preferencesChanged()
|
|||
config->writeEntry( "MetafontMode", mfmode = DefaultMFMode );
|
||||
window->setMetafontMode( mfmode );
|
||||
|
||||
int makepk = config->readNumEntry( "MakePK" );
|
||||
int makepk = config->readBoolEntry( "MakePK", true );
|
||||
if ( makepk != window->makePK() )
|
||||
window->setMakePK( makepk );
|
||||
|
||||
|
|
|
@ -45,15 +45,27 @@ OptionDialog::OptionDialog( QWidget *parent, const char *name, bool modal )
|
|||
setHelp("opts", "kdvi");
|
||||
makeFontPage();
|
||||
makeRenderingPage();
|
||||
|
||||
KConfig *config = _instance->config();
|
||||
config->setGroup("kdvi");
|
||||
|
||||
// Font page
|
||||
// Important! The default values here must be the same as in kdvi_multipage.cpp
|
||||
for(int i=0; i<NumberOfMFModes; i++)
|
||||
mFont.metafontMode->insertItem(QString("%1 dpi / %2").arg(MFResolutions[i]).arg(MFModenames[i]));
|
||||
mFont.metafontMode->setCurrentItem( config->readNumEntry( "MetafontMode" , DefaultMFMode ));
|
||||
mFont.fontPathCheck->setChecked( config->readBoolEntry( "MakePK", true ) );
|
||||
|
||||
// Rendering page
|
||||
mRender.showSpecialCheck->setChecked( config->readNumEntry( "ShowPS", 1 ) );
|
||||
mRender.showHyperLinksCheck->setChecked(config->readNumEntry("ShowHyperLinks", 1));
|
||||
}
|
||||
|
||||
|
||||
void OptionDialog::show()
|
||||
{
|
||||
if( isVisible() == false ) {
|
||||
setup();
|
||||
if( isVisible() == false )
|
||||
showPage(0);
|
||||
}
|
||||
KDialogBase::show();
|
||||
}
|
||||
|
||||
|
@ -79,25 +91,6 @@ void OptionDialog::slotApply()
|
|||
}
|
||||
|
||||
|
||||
void OptionDialog::setup()
|
||||
{
|
||||
KConfig *config = _instance->config();
|
||||
config->setGroup("kdvi");
|
||||
|
||||
// Font page
|
||||
// Important! The default values here must be the same as in kdvi_multipage.cpp
|
||||
for(int i=0; i<NumberOfMFModes; i++)
|
||||
mFont.metafontMode->insertItem(QString("%1 dpi / %2").arg(MFResolutions[i]).arg(MFModenames[i]));
|
||||
mFont.metafontMode->setCurrentItem( config->readNumEntry( "MetafontMode" , DefaultMFMode ));
|
||||
mFont.fontPathCheck->setChecked( config->readNumEntry( "MakePK" ) );
|
||||
|
||||
// Rendering page
|
||||
mRender.showSpecialCheck->setChecked( config->readNumEntry( "ShowPS", 1 ) );
|
||||
mRender.showHyperLinksCheck->setChecked(config->readNumEntry("ShowHyperLinks", 1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void OptionDialog::makeFontPage()
|
||||
{
|
||||
QFrame *page = addPage( i18n("Fonts") );
|
||||
|
|
|
@ -59,7 +59,6 @@ class OptionDialog : public KDialogBase
|
|||
virtual void slotApply();
|
||||
|
||||
private:
|
||||
void setup();
|
||||
void makeFontPage();
|
||||
void makeRenderingPage();
|
||||
|
||||
|
|
71
special.cpp
71
special.cpp
|
@ -4,7 +4,7 @@
|
|||
// Methods for dviwin which deal with "\special" commands found in the
|
||||
// DVI file
|
||||
|
||||
// Copyright 2000, Stefan Kebekus (stefan.kebekus@uni-bayreuth.de).
|
||||
// Copyright 2000--2001, Stefan Kebekus (stefan.kebekus@uni-bayreuth.de).
|
||||
|
||||
|
||||
#include <qfile.h>
|
||||
|
@ -29,8 +29,8 @@ void dviWindow::html_anchor_special(QString cp)
|
|||
if (PostScriptOutPutString != NULL) { // only during scanning, not during rendering
|
||||
cp.truncate(cp.find('"'));
|
||||
#ifdef DEBUG_SPECIAL
|
||||
kdDebug() << "HTML-special, anchor " << cp.latin1() << endl;
|
||||
kdDebug() << "page " << current_page << endl;
|
||||
kdDebug(4300) << "HTML-special, anchor " << cp.latin1() << endl;
|
||||
kdDebug(4300) << "page " << current_page << endl;
|
||||
#endif
|
||||
|
||||
AnchorList_String[numAnchors] = cp;
|
||||
|
@ -46,7 +46,7 @@ void dviWindow::html_href_special(QString cp)
|
|||
cp.truncate(cp.find('"'));
|
||||
|
||||
#ifdef DEBUG_SPECIAL
|
||||
kdDebug() << "HTML-special, href " << cp.latin1() << endl;
|
||||
kdDebug(4300) << "HTML-special, href " << cp.latin1() << endl;
|
||||
#endif
|
||||
|
||||
if (!PostScriptOutPutString) { // only when rendering really takes place
|
||||
|
@ -57,7 +57,7 @@ void dviWindow::html_href_special(QString cp)
|
|||
void dviWindow::html_anchor_end(void)
|
||||
{
|
||||
#ifdef DEBUG_SPECIAL
|
||||
kdDebug() << "HTML-special, anchor-end" << endl;
|
||||
kdDebug(4300) << "HTML-special, anchor-end" << endl;
|
||||
#endif
|
||||
|
||||
if (HTML_href != NULL) {
|
||||
|
@ -70,7 +70,7 @@ void dviWindow::html_anchor_end(void)
|
|||
void dviWindow::header_special(QString cp)
|
||||
{
|
||||
#ifdef DEBUG_SPECIAL
|
||||
kdDebug() << "PostScript-special, header " << cp.latin1() << endl;
|
||||
kdDebug(4300) << "PostScript-special, header " << cp.latin1() << endl;
|
||||
#endif
|
||||
|
||||
if (PostScriptOutPutString && QFile::exists(cp)) {
|
||||
|
@ -92,7 +92,7 @@ static void parse_special_argument(QString strg, const char *argument_name, int
|
|||
*variable = tmp_int;
|
||||
else
|
||||
// Maybe we should open a dialog here.
|
||||
kdError() << i18n("Malformed parameter in the epsf special command.") << endl;
|
||||
kdError(4300) << i18n("Malformed parameter in the epsf special command.") << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ static void parse_special_argument(QString strg, const char *argument_name, int
|
|||
void dviWindow::epsf_special(QString cp)
|
||||
{
|
||||
#ifdef DEBUG_SPECIAL
|
||||
kdDebug() << "epsf-special: psfile=" << cp <<endl;
|
||||
kdDebug(4300) << "epsf-special: psfile=" << cp <<endl;
|
||||
#endif
|
||||
|
||||
QString include_command = cp.simplifyWhiteSpace();
|
||||
|
@ -137,6 +137,7 @@ void dviWindow::epsf_special(QString cp)
|
|||
int ury = 0;
|
||||
int rwi = 0;
|
||||
int rhi = 0;
|
||||
int angle = 0;
|
||||
|
||||
// just to avoid ambiguities; the filename could contain keywords
|
||||
include_command = include_command.mid(include_command.find(' '));
|
||||
|
@ -147,6 +148,7 @@ void dviWindow::epsf_special(QString cp)
|
|||
parse_special_argument(include_command, "ury=", &ury);
|
||||
parse_special_argument(include_command, "rwi=", &rwi);
|
||||
parse_special_argument(include_command, "rhi=", &rhi);
|
||||
parse_special_argument(include_command, "angle=", &angle);
|
||||
|
||||
if (PostScriptOutPutString) {
|
||||
if (QFile::exists(EPSfilename)) {
|
||||
|
@ -162,6 +164,8 @@ void dviWindow::epsf_special(QString cp)
|
|||
PostScriptOutPutString->append( QString(" %1 @rwi").arg(rwi) );
|
||||
if (rhi != 0)
|
||||
PostScriptOutPutString->append( QString(" %1 @rhi").arg(rhi) );
|
||||
if (angle != 0)
|
||||
PostScriptOutPutString->append( QString(" %1 @angle").arg(angle) );
|
||||
PostScriptOutPutString->append( " @setspecial \n" );
|
||||
PostScriptOutPutString->append( QString(" (%1) run\n").arg(EPSfilename) );
|
||||
PostScriptOutPutString->append( "@endspecial \n" );
|
||||
|
@ -205,7 +209,7 @@ void dviWindow::epsf_special(QString cp)
|
|||
void dviWindow::bang_special(QString cp)
|
||||
{
|
||||
#ifdef DEBUG_SPECIAL
|
||||
kdDebug() << "PostScript-special, literal header " << cp.latin1() << endl;
|
||||
kdDebug(4300) << "PostScript-special, literal header " << cp.latin1() << endl;
|
||||
#endif
|
||||
|
||||
if (currwin.win == mane.win && PostScriptOutPutString) {
|
||||
|
@ -220,7 +224,7 @@ void dviWindow::bang_special(QString cp)
|
|||
void dviWindow::quote_special(QString cp)
|
||||
{
|
||||
#ifdef DEBUG_SPECIAL
|
||||
// kdError() << "PostScript-special, literal PostScript " << cp.latin1() << endl;
|
||||
kdError(4300) << "PostScript-special, literal PostScript " << cp.latin1() << endl;
|
||||
#endif
|
||||
|
||||
if (currwin.win == mane.win && PostScriptOutPutString) {
|
||||
|
@ -234,6 +238,35 @@ void dviWindow::quote_special(QString cp)
|
|||
}
|
||||
|
||||
|
||||
void dviWindow::ps_special(QString cp)
|
||||
{
|
||||
#ifdef DEBUG_SPECIAL
|
||||
kdError(4300) << "PostScript-special, direct PostScript " << cp.latin1() << endl;
|
||||
#endif
|
||||
|
||||
if (currwin.win == mane.win && PostScriptOutPutString) {
|
||||
double PS_H = (DVI_H*300.0)/(65536*basedpi)-300;
|
||||
double PS_V = (DVI_V*300.0)/(65536*basedpi)-300;
|
||||
|
||||
if (cp.find("ps::[begin]", 0, false) == 0) {
|
||||
PostScriptOutPutString->append( QString(" %1 %2 moveto\n").arg(PS_H).arg(PS_V) );
|
||||
PostScriptOutPutString->append( QString(" %1\n").arg(cp.mid(11)) );
|
||||
} else {
|
||||
if (cp.find("ps::[end]", 0, false) == 0) {
|
||||
PostScriptOutPutString->append( QString(" %1\n").arg(cp.mid(9)) );
|
||||
} else {
|
||||
if (cp.find("ps::", 0, false) == 0) {
|
||||
PostScriptOutPutString->append( QString(" %1\n").arg(cp.mid(4)) );
|
||||
} else {
|
||||
PostScriptOutPutString->append( QString(" %1 %2 moveto\n").arg(PS_H).arg(PS_V) );
|
||||
PostScriptOutPutString->append( QString(" %1\n").arg(cp.mid(3)) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void dviWindow::applicationDoSpecial(char *cp)
|
||||
{
|
||||
QString special_command(cp);
|
||||
|
@ -244,6 +277,12 @@ void dviWindow::applicationDoSpecial(char *cp)
|
|||
return;
|
||||
}
|
||||
|
||||
// PS-Postscript inclusion
|
||||
if (special_command.find("ps:", 0, false) == 0) {
|
||||
ps_special(special_command);
|
||||
return;
|
||||
}
|
||||
|
||||
// Literal Postscript Header
|
||||
if (special_command[0] == '!') {
|
||||
bang_special(special_command.mid(1));
|
||||
|
@ -251,35 +290,35 @@ void dviWindow::applicationDoSpecial(char *cp)
|
|||
}
|
||||
|
||||
// Encapsulated Postscript File
|
||||
if (special_command.find("PSfile=") == 0 || special_command.find("psfile=") == 0) {
|
||||
if (special_command.find("PSfile=", 0, false) == 0) {
|
||||
epsf_special(special_command.mid(7));
|
||||
return;
|
||||
}
|
||||
|
||||
// Postscript Header File
|
||||
if (special_command.find("header=") == 0) {
|
||||
if (special_command.find("header=", 0, false) == 0) {
|
||||
header_special(special_command.mid(7));
|
||||
return;
|
||||
}
|
||||
|
||||
// HTML reference
|
||||
if (special_command.find("html:<A href=") == 0) {
|
||||
if (special_command.find("html:<A href=", 0, false) == 0) {
|
||||
html_href_special(special_command.mid(14));
|
||||
return;
|
||||
}
|
||||
|
||||
// HTML anchor end
|
||||
if (special_command.find("html:</A>") == 0) {
|
||||
if (special_command.find("html:</A>", 0, false) == 0) {
|
||||
html_anchor_end();
|
||||
return;
|
||||
}
|
||||
|
||||
// HTML anchor special
|
||||
if (special_command.find("html:<A name=") == 0) {
|
||||
if (special_command.find("html:<A name=", 0, false) == 0) {
|
||||
html_anchor_special(special_command.mid(14));
|
||||
return;
|
||||
}
|
||||
|
||||
kdError() << i18n("The special command\"") << cp << i18n("\" is not implemented.") << endl;
|
||||
kdError(4300) << i18n("The special command \"") << special_command << i18n("\" is not implemented.") << endl;
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue