further implementation of new font searching mechanism

svn path=/trunk/kdegraphics/kdvi/; revision=72326
This commit is contained in:
Stefan Kebekus 2000-11-26 12:33:45 +00:00
parent ba43dc5529
commit e41aeda365
12 changed files with 32 additions and 454 deletions

View file

@ -258,14 +258,14 @@ font *define_font(FILE *file, unsigned int cmnd, font *vfparent, QIntDict<struct
if (fontp == NULL) { /* if font doesn't exist yet */
fontp = new font(fontname, fsize, checksum, magstepval, scale * scale_dimconv / (1<<20));
fontp->set_char_p = &dviWindow::load_n_set_char;
//@@@fontp->set_char_p = &dviWindow::load_n_set_char;
/* With virtual fonts, we might be opening another font
(pncb.vf), instead of what we just allocated for
(rpncb), thus leaving garbage in the structure for
when close_a_file comes along looking for something. */
//@@@ if (vfparent == NULL)
//@@@ font_not_found |= font_pool.load_font(fontp);
font_pool.append(fontp);
font_pool.appendx(fontp);
break;
}

View file

@ -170,11 +170,8 @@ void dviWindow::setShowHyperLinks( int flag )
void dviWindow::setMakePK( int flag )
{
if (dviFile != NULL)
KMessageBox::sorry( this,
i18n("The change in font generation will be effective\n"
"only after you start kdvi again!") );
makepk = flag;
font_pool.setMakePK(makepk);
}
void dviWindow::setMetafontMode( const QString & mfm )

View file

@ -77,7 +77,6 @@ public:
void draw_part(struct frame *minframe, double current_dimconv);
void draw_page(void);
void set_vf_char(unsigned int cmd, unsigned int ch);
void load_n_set_char(unsigned int cmd, unsigned int ch);
void set_char(unsigned int cmd, unsigned int ch);
void set_empty_char(unsigned int cmd, unsigned int ch);
void set_no_char(unsigned int cmd, unsigned int ch);

View file

@ -224,24 +224,6 @@ void dviWindow::set_empty_char(unsigned int cmd, unsigned int ch)
return;
}
void dviWindow::load_n_set_char(unsigned int cmd, unsigned int ch)
{
#ifdef DEBUG_RENDER
kdDebug() << "load_n_set_char" << endl;
#endif
if ( currinf.fontp->load_font() ) { /* if not found */
kdError() << "Character(s) will be left blank." << endl;
currinf.set_char_p = currinf.fontp->set_char_p = &dviWindow::set_empty_char;
return;
}
currinf.set_char_p = currinf.fontp->set_char_p;
(this->*currinf.set_char_p)(cmd, ch);
return;
}
void dviWindow::set_vf_char(unsigned int cmd, unsigned int ch)
{
#ifdef DEBUG_RENDER

View file

@ -7,6 +7,7 @@
#include <qapplication.h>
#include <stdio.h>
#include "dviwin.h"
#include "font.h"
#include "kdvi.h"
@ -50,15 +51,18 @@ void font::font_name_receiver(KProcess *, char *buffer, int buflen)
set_char_p = &dviWindow::set_char;
int magic = two(file);
if (magic == PK_MAGIC)
if (magic == PK_MAGIC) {
// Achtung! Read_PK_index kann auch schiefgehen!
read_PK_index();
else
set_char_p = &dviWindow::set_char;
} else
if (magic == GF_MAGIC)
oops(QString(i18n("The GF format for font file %1 is no longer supported")).arg(filename) );
else
if (magic == VF_MAGIC)
if (magic == VF_MAGIC) {
read_VF_index();
else
set_char_p = &dviWindow::set_vf_char;
} else
oops(QString(i18n("Cannot recognize format for font file %1")).arg(filename) );
}
@ -77,6 +81,10 @@ font::font(char *nfontname, float nfsize, long chk, int mag, double dconv)
file = NULL;
filename = "";
dimconv = dconv;
// By default, this font contains only empty characters. After the
// font has been loaded, this function pointer will be replaced by another one.
set_char_p = &dviWindow::set_empty_char;
}
font::~font()
@ -109,51 +117,6 @@ font::~font()
/** load_font locates the raster file and reads the index of
characters, plus whatever other preprocessing is done (depending
on the format). */
unsigned char font::load_font(void)
{
#ifdef DEBUG_FONT
kdDebug() << "loading font " << fontname << " at " << (int) (fsize + 0.5) << " dpi" << endl;
#endif
// Find the font name. We use the external program "kpsewhich" for
// that purpose.
KShellProcess proc;
connect(&proc, SIGNAL(receivedStdout(KProcess *, char *, int)),
this, SLOT(font_name_receiver(KProcess *, char *, int)));
// First try if the font is a virtual font
proc.clearArguments();
proc << "kpsewhich";
proc << "--dpi 600";
proc << "--mode ljfour";
proc << "--format vf";
proc << 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 (filename.isEmpty()) {
proc.clearArguments();
proc << "kpsewhich";
proc << "--dpi 600";
proc << "--mode ljfour";
proc << "--format pk";
proc << "--mktex pk";
proc << QString("%1.%2").arg(fontname).arg((int)(fsize + 0.5));
proc.start(KProcess::NotifyOnExit, KProcess::All);
while(proc.isRunning())
qApp->processEvents();
}
return False;
}
/** mark_as_used marks the font, and all the fonts it referrs to, as

3
font.h
View file

@ -38,8 +38,6 @@ struct macro {
};
typedef void (dviWindow::*set_char_proc)(unsigned int, unsigned int);
class font : public QObject {
Q_OBJECT
@ -62,7 +60,6 @@ public:
~font();
glyph *glyphptr(unsigned int ch);
void mark_as_used(void);
unsigned char load_font(void);
char *fontname; // name of font, such as "cmr10"
unsigned char flags; // flags byte (see values below)

View file

@ -15,6 +15,11 @@ void fontPool::setMetafontMode( const QString &mode )
MetafontMode = mode;
}
void fontPool::setMakePK(int flag)
{
makepk = flag;
kdDebug() << "MakeTexPK " << flag << endl;
}
void fontPool::appendx(const struct font *fontp)
{
@ -35,8 +40,6 @@ void fontPool::appendx(const struct font *fontp)
// First try if the font is a virtual font
proc.clearArguments();
proc << "kpsewhich";
// proc << QString("--dpi %1").arg(Resolution);
// proc << QString("--mode %1").arg(MetafontMode);
proc << "--format vf";
proc << fontp->fontname;
proc.start(KProcess::NotifyOnExit, KProcess::All);
@ -50,7 +53,10 @@ void fontPool::appendx(const struct font *fontp)
proc << QString("--dpi %1").arg(Resolution);
proc << QString("--mode %1").arg(MetafontMode);
proc << "--format pk";
proc << "--mktex 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));
proc.start(KProcess::NotifyOnExit, KProcess::All);
while(proc.isRunning())
@ -65,5 +71,4 @@ void fontPool::status(void)
for ( fontp=this->first(); fontp != 0; fontp=this->next() )
kdDebug() << fontp->fontname << ": " << fontp->flags << endl;
}

View file

@ -37,6 +37,11 @@ class fontPool : public QList<struct font> {
* loaded ---expect funny results when changing the data in the
* mid-work. */
void setMetafontMode( const QString & );
/** Says whether fonts will be generated by running MetaFont, or a
similar programm. If (flag == 0), fonts will not be generated,
otherwise they will. */
void setMakePK( int flag );
/** This method adds a font to the list. If the font is not
* currently loaded, it's file will be located and font::load_font
@ -50,6 +55,7 @@ class fontPool : public QList<struct font> {
void status();
private:
int makepk;
int Resolution;
QString MetafontMode;
};

1
kdvi.h
View file

@ -8,3 +8,4 @@
// Define the following flags to generate debugging output
// #define DEBUG_FONT 0
// #define DEBUG_PK 1

4
pk.cpp
View file

@ -51,11 +51,11 @@
#include <kdebug.h>
#include <klocale.h>
#include "font.h"
#include "dviwin.h"
#include "kdvi.h" // This is where debugging flags are set.
#include <stdio.h>
#include <stdlib.h>
@ -66,8 +66,6 @@ extern char *xmalloc (unsigned, const char *);
extern void oops(QString message);
extern void alloc_bitmap(bitmap *bitmap);
#define DEBUG_PK 1
BMUNIT bit_masks[33] = {
0x0, 0x1, 0x3, 0x7,
0xf, 0x1f, 0x3f, 0x7f,

200
print.dlg
View file

@ -1,200 +0,0 @@
DlgEdit:v1.2:Dialog:
Dialog {
ClassHeader {print.h}
ClassSource {print.cpp}
ClassName {print}
DataHeader {printData.h}
DataSource {printData.cpp}
DataName {printData}
WindowBaseClass {QDialog}
IsModal {TRUE}
WindowCaption {Print}
}
WidgetLayout {
Rect {5 102 400 350}
Grid {10}
ButtonGroup {
Title {Page order}
Alignment {Left}
Style {49}
Rect {10 220 380 60}
Name {ButtonGroup_3}
}
ButtonGroup {
Exclusive {1}
Title {Pages}
Alignment {Left}
Style {49}
Rect {10 120 380 90}
Name {ButtonGroup_2}
}
ButtonGroup {
Title {Print to}
Alignment {Left}
Style {49}
Rect {10 10 380 100}
Name {printToGroup}
}
Label {
Text {&File Name:}
Alignment {290}
AutoResize {FALSE}
Margin {8}
Rect {18 70 91 30}
Name {Label_1}
Variable {fileNameLabel}
}
Label {
Text {-}
Alignment {292}
AutoResize {FALSE}
Margin {-1}
Rect {300 170 20 30}
Name {Label_2}
}
ComboBox {
Style {ReadWrite}
SizeLimit {20}
Policy {AtBottom}
AutoResize {FALSE}
Item {Default Printer}
Item {File}
Rect {110 30 270 30}
Name {ComboBox_1}
Variable {printer}
Signal {[Protected] activated --> printDestinationChanged (int)}
}
LineEdit {
Text {}
EchoMode {Normal}
MaxLength {32767}
FrameShown {TRUE}
Rect {110 70 270 30}
Name {printFileName}
Variable {printFileName}
}
RadioButton {
Checked {TRUE}
Text {&All}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {30 140 100 30}
Name {RadioButton_1}
Variable {printAll}
}
RadioButton {
Checked {FALSE}
Text {&Current}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {150 140 100 30}
Name {RadioButton_2}
Variable {printCurrent}
}
RadioButton {
Checked {FALSE}
Text {&Marked}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {30 170 100 30}
Name {RadioButton_3}
Variable {printMarked}
}
RadioButton {
Checked {FALSE}
Text {&Range}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {150 170 100 30}
Name {RadioButton_4}
Variable {printRange}
Signal {[Protected] toggled --> rangeToggled (bool)}
}
LineEdit {
Text {}
EchoMode {Normal}
MaxLength {32767}
FrameShown {TRUE}
Rect {250 170 50 30}
Name {LineEdit_2}
Variable {rangeFrom}
}
LineEdit {
Text {}
EchoMode {Normal}
MaxLength {32767}
FrameShown {TRUE}
Rect {320 170 50 30}
Name {LineEdit_3}
Variable {rangeTo}
}
CheckBox {
Checked {FALSE}
Text {Re&verse}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {30 240 90 30}
Name {CheckBox_1}
Variable {printReverse}
}
ComboBox {
Style {ReadOnly}
SizeLimit {10}
Policy {AtBottom}
AutoResize {FALSE}
Item {1 page on sheet}
Item {2 pages on sheet}
Item {4 pages on sheet}
Rect {120 240 140 30}
Name {ComboBox_2}
Variable {nupCombo}
Signal {[Protected] activated --> nupPressed (int)}
}
ComboBox {
Style {ReadOnly}
SizeLimit {10}
Policy {AtBottom}
AutoResize {FALSE}
Item {Fill rows}
Item {Fill columns}
Rect {270 240 110 30}
Name {ComboBox_3}
Variable {colOrder}
}
PushButton {
ToggleButton {FALSE}
Default {FALSE}
AutoDefault {FALSE}
Text {OK}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {30 300 100 30}
Name {PushButton_1}
Variable {okButton}
Signal {[Protected] clicked --> okPressed ()}
}
PushButton {
ToggleButton {FALSE}
Default {FALSE}
AutoDefault {FALSE}
Text {&Setup}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {150 300 100 30}
Name {PushButton_2}
Variable {setupButton}
Signal {[Protected] clicked --> setupPressed ()}
}
PushButton {
ToggleButton {FALSE}
Default {FALSE}
AutoDefault {FALSE}
Text {Cancel}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {270 300 100 30}
Name {PushButton_3}
Variable {cancelButton}
Signal {[Protected] clicked --> cancelPressed ()}
}}

View file

@ -1,170 +0,0 @@
DlgEdit:v1.2:Dialog:
Dialog {
ClassHeader {printSetup.h}
ClassSource {printSetup.cpp}
ClassName {printSetup}
DataHeader {printSetupData.h}
DataSource {printSetupData.cpp}
DataName {printSetupData}
WindowBaseClass {QDialog}
IsModal {TRUE}
WindowCaption {Print setup}
}
WidgetLayout {
Rect {5 102 410 340}
Grid {10}
PushButton {
ToggleButton {FALSE}
Default {FALSE}
AutoDefault {FALSE}
Text {Cancel}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {290 300 100 30}
Name {PushButton_4}
Signal {[Protected] clicked --> reject ()}
}
GroupBox {
Title {Printers}
Alignment {Left}
Style {49}
Rect {150 10 250 240}
Name {GroupBox_1}
}
ButtonGroup {
Title {n-up}
Alignment {Left}
Style {49}
Rect {10 140 130 110}
Name {ButtonGroup_5}
}
ButtonGroup {
Title {Printing method}
Alignment {Left}
Style {49}
Rect {10 10 130 120}
Name {ButtonGroup_4}
}
RadioButton {
Checked {FALSE}
Text {&Internal}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {30 30 100 30}
Name {RadioButton_5}
Variable {internal}
}
RadioButton {
Checked {FALSE}
Text {dvi&ps}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {30 60 100 30}
Name {RadioButton_6}
Variable {dvips}
}
RadioButton {
Checked {FALSE}
Text {dvi&lj4}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {30 90 100 30}
Name {RadioButton_7}
Variable {dvilj4}
}
RadioButton {
Checked {FALSE}
Text {Use ps&nup}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {30 170 100 30}
Name {RadioButton_8}
Variable {psnup}
}
RadioButton {
Checked {FALSE}
Text {Use &mpage}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {30 200 100 30}
Name {RadioButton_9}
Variable {mpage}
}
ListBox {
DragSelect {TRUE}
AutoScroll {TRUE}
ScrollBar {FALSE}
AutoScrollBar {TRUE}
BottomScrollBar {FALSE}
AutoBottomScrollBar {TRUE}
SmoothScrolling {TRUE}
Style {51}
LineWidth {2}
Rect {170 30 210 120}
Name {ListBox_1}
Variable {printers}
}
LineEdit {
Text {}
EchoMode {Normal}
MaxLength {32767}
FrameShown {TRUE}
Rect {170 160 210 30}
Name {LineEdit_4}
Variable {newPrinter}
Signal {[Protected] returnPressed --> addPrinter ()}
}
PushButton {
ToggleButton {FALSE}
Default {FALSE}
AutoDefault {FALSE}
Text {&Add}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {170 200 100 30}
Name {PushButton_5}
Signal {[Protected] clicked --> addPrinter ()}
}
PushButton {
ToggleButton {FALSE}
Default {FALSE}
AutoDefault {FALSE}
Text {&Remove}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {280 200 100 30}
Name {PushButton_6}
Signal {[Protected] clicked --> removePrinter ()}
}
PushButton {
ToggleButton {FALSE}
Default {FALSE}
AutoDefault {FALSE}
Text {OK}
AutoRepeat {FALSE}
AutoResize {FALSE}
Rect {170 300 100 30}
Name {PushButton_7}
Variable {okButton}
Signal {[Protected] clicked --> okPressed ()}
}
LineEdit {
Text {}
EchoMode {Normal}
MaxLength {32767}
FrameShown {TRUE}
Rect {150 260 250 30}
Name {LineEdit_2}
Variable {spoolerCommand}
}
Label {
Text {&Spooler command:}
Alignment {290}
AutoResize {FALSE}
Margin {4}
Style {50}
Rect {10 260 130 30}
Name {Label_1}
Variable {spoolerLabel}
}}