started to re-implement the PostScript interface

svn path=/trunk/kdegraphics/kdvi/; revision=52400
This commit is contained in:
Stefan Kebekus 2000-06-07 01:41:55 +00:00
parent 4cf0bd42de
commit be544056a7
12 changed files with 397 additions and 762 deletions

59
TODO
View file

@ -1,30 +1,43 @@
TODO:
~~~~~
URGENT:
ToDo-List for kdvi
- Release unsued fonts after reloading a file.
URGENT
- Update Manual.
- Useful Zooms
o Re-Implement PostScript specials, including proper handling of header (="bang")
specials.
--------
o Proper Error handling with throw/catch
NOT SO URGENT:
o Update the Manual.
- Document info dialog
- More paper types, currently only those from xdvi are available
- Better online help
- Internal printing using QPrinter
- Redirect error messages to a window (partly done)
- Better, more robust PostScript handling (use the PostScript-Widget from kghostview)
- More background processing to keep the UI responsive
- Magnifier window
- Two page view
- Support for more TeX specials
- Popup-Window to inform the user when Fonts are generated
o Document the technical specs.
- Colored Fonts
- Hyperlinks to click on
- Search option
- SOURCE CLEANUP
o Bugfixing
HIGHLY DESIRABLE
o Support for Hyperlatex specials (xxx.lanl.gov, probably the world's largest
collection of dvi-files, uses Hyperlatex for every file!)
o Support for TPic and colored font specials
o Support for click-on-dvi => editor (klyx!) jumps to proper position. This is
included in the windows distribution of TeX. We should really catch up!
o Support papersize informational given by the dvi-file on a page-by-page
basis.
NOT SO URGENT
o Document info dialog
o Better online help
o Internal printing using QPrinter
o Redirect error messages to a window (partly done)
o More background processing to keep the UI responsive
o Magnifier window
o Two page view
o Support for even more TeX specials
o Popup-Window to inform the user when Fonts are generated
o Search option

View file

@ -85,8 +85,6 @@ extern char *xmalloc (unsigned, _Xconst char *);
#define dvi_oops(str) (dvi_oops_msg = (str), longjmp(dvi_env, 1))
static Boolean font_not_found;
Boolean _hush_spec;
Boolean _hush_chk;
QDateTime dvi_time;
/*
@ -298,7 +296,7 @@ static void find_postamble()
* It also takes care of reading in all of the pixel files for the fonts
* used in the job.
*/
static void read_postamble()
void dviWindow::read_postamble(void)
{
unsigned char cmnd;
struct font *fontp;
@ -312,10 +310,10 @@ static void read_postamble()
|| magnification != four(dvi_file))
dvi_oops("Postamble doesn't match preamble");
/* read largest box height and width */
unshrunk_page_h = (spell_conv(sfour(dvi_file)) >> 16) + offset_y;
unshrunk_page_h = (spell_conv(sfour(dvi_file)) >> 16) + basedpi;
if (unshrunk_page_h < unshrunk_paper_h)
unshrunk_page_h = unshrunk_paper_h;
unshrunk_page_w = (spell_conv(sfour(dvi_file)) >> 16) + offset_x;
unshrunk_page_w = (spell_conv(sfour(dvi_file)) >> 16) + basedpi;
if (unshrunk_page_w < unshrunk_paper_w)
unshrunk_page_w = unshrunk_paper_w;
(void) two(dvi_file); /* max stack size */
@ -339,21 +337,18 @@ static void read_postamble()
static void prepare_pages()
{
int i;
page_offset = (long *) xmalloc((unsigned) total_pages * sizeof(long),
"page directory");
i = total_pages;
page_offset[--i] = last_page_offset;
Fseek(dvi_file, last_page_offset, 0);
/*
* Follow back pointers through pages in the DVI file,
* storing the offsets in the page_offset table.
*/
while (i > 0) {
Fseek(dvi_file, (long) (1+4+(9*4)), 1);
Fseek(dvi_file, page_offset[--i] = four(dvi_file), 0);
}
page_offset = (long *) xmalloc((unsigned) total_pages * sizeof(long), "page directory");
int i = total_pages;
page_offset[--i] = last_page_offset;
Fseek(dvi_file, last_page_offset, 0);
/*
* Follow back pointers through pages in the DVI file,
* storing the offsets in the page_offset table.
*/
while (i > 0) {
Fseek(dvi_file, (long) (1+4+(9*4)), 1);
Fseek(dvi_file, page_offset[--i] = four(dvi_file), 0);
}
}
void init_page()
@ -365,7 +360,7 @@ void init_page()
/** init_dvi_file is the main subroutine for reading the startup
* information from the dvi file. Returns True on success. */
static Boolean init_dvi_file()
Boolean dviWindow::init_dvi_file()
{
if (QFileInfo(dvi_name).isDir())
return False;
@ -380,7 +375,6 @@ static Boolean init_dvi_file()
init_page();
if (current_page >= total_pages)
current_page = total_pages - 1;
hush_spec_now = hush_spec;
return True;
}
@ -389,7 +383,7 @@ static Boolean init_dvi_file()
** Check for changes in dvi file.
**/
extern Boolean check_dvi_file(void)
Boolean dviWindow::check_dvi_file(void)
{
if (dvi_file == NULL || (dvi_time != QFileInfo(dvi_name).lastModified())) {
if (dvi_file) {

View file

@ -39,7 +39,6 @@ extern struct WindowRec alt;
struct drawinf currinf;
int _debug;
Boolean hush_spec_now;
char *prog;
Display *DISP;
int min_x, max_x, min_y, max_y;
@ -58,7 +57,6 @@ unsigned int unshrunk_paper_w, unshrunk_paper_h;
unsigned int unshrunk_page_w, unshrunk_page_h;
unsigned int page_w, page_h;
unsigned char maxchar;
int offset_x, offset_y;
long *page_offset;
QIntDict<struct font> tn_table;
@ -85,7 +83,6 @@ extern int min_x;
extern int min_y;
extern int max_x;
extern int max_y;
extern int offset_x, offset_y;
extern unsigned int unshrunk_paper_w, unshrunk_paper_h;
extern unsigned int unshrunk_page_w, unshrunk_page_h;
extern unsigned int page_w, page_h;
@ -123,7 +120,8 @@ double xres;
//------ next the drawing functions called from C-code (dvi_draw.c) ----
QPainter *dcp;
QPainter foreGroundPaint; // QPainter used for text
extern void qt_processEvents(void)
{
@ -265,8 +263,6 @@ void dviWindow::setResolution( int bdpi )
"only after you start kdvi again!") );
basedpi = bdpi;
_pixels_per_inch = bdpi;
offset_x = bdpi;
offset_y = bdpi;
}
int dviWindow::resolution()
@ -331,14 +327,13 @@ void dviWindow::drawPage()
return;
if ( !pixmap->paintingActive() ) {
QPainter paint;
paint.begin( pixmap );
foreGroundPaint.begin( pixmap );
QApplication::setOverrideCursor( waitCursor );
dcp = &paint;
if (setjmp(dvi_env)) { // dvi_oops called
dvi_time.setTime_t(0); // force init_dvi_file
QApplication::restoreOverrideCursor();
paint.end();
foreGroundPaint.end();
KMessageBox::error( this,
i18n("What's this? DVI problem!\n")
+ dvi_oops_msg);
@ -349,7 +344,7 @@ void dviWindow::drawPage()
draw_page();
}
QApplication::restoreOverrideCursor();
paint.end();
foreGroundPaint.end();
}
resize(pixmap->width(), pixmap->height());
repaint();

View file

@ -41,10 +41,17 @@ public:
// for the preview
QPixmap *pix() { return pixmap; };
// These should not be public... only for the moment
void read_postamble(void);
char init_dvi_file(void);
char check_dvi_file(void);
void draw_part(struct frame *minframe, double current_dimconv);
void draw_page(void);
public slots:
void setFile(const char *fname);
void gotoPage(int page);
void setFile(const char *fname);
void gotoPage(int page);
// void setZoom(int zoom);
void setZoom(double zoom);
@ -61,15 +68,14 @@ protected:
private:
void initDVI();
void changePageSize();
QString filename;
QString filename;
int basedpi, makepk;
QPixmap * pixmap;
QString MetafontMode;
QString FontPath;
QString paper_type;
QPixmap *pixmap;
QString MetafontMode;
QString FontPath;
QString paper_type;
int ChangesPossible;
double _zoom;
};

View file

@ -51,22 +51,18 @@
#define DEBUG 0
/* The stuff from the path searching library. */
#include "dviwin.h"
#include <stdlib.h>
#include <kpathsea/config.h>
#include <kpathsea/c-ctype.h>
#include <kpathsea/c-fopen.h>
#include <kpathsea/c-vararg.h>
#include "dviwin.h"
#include "glyph.h"
#include "oconfig.h"
#include "dvi.h"
#include <kdebug.h>
#include <kprocess.h>
#include <qpainter.h>
#include <qbitmap.h>
#include <qimage.h>
#include <qkeycode.h>
#include <qpaintdevice.h>
#include <qfileinfo.h>
@ -74,92 +70,45 @@ extern char *xmalloc (unsigned, _Xconst char *);
extern FILE *xfopen(char *filename, char *type);
extern Boolean check_dvi_file(void);
Boolean _hush_chars;
// If PostScriptOutPutFile is non-zero, then rendering takes
// place. Instead, the PostScript code which is generated by the
// \special-commands is written to the PostScriptString
FILE *PostScriptOutPutFile;
QString PostScriptString;
static struct frame frame0; /* dummy head of list */
static struct frame *scan_frame; /* head frame for scanning */
static struct frame frame0; /* dummy head of list */
#ifndef DVI_BUFFER_LEN
#define DVI_BUFFER_LEN 512
#endif
extern QPainter *dcp;
extern QPainter foreGroundPaint;
static unsigned char dvi_buffer[DVI_BUFFER_LEN];
static struct frame *current_frame;
#define DIR currinf.dir
/*
* Explanation of the following constant:
* offset_[xy] << 16: margin (defaults to one inch)
* shrink_factor << 16: one pixel page border
* shrink_factor << 15: rounding for pixel_conv
*/
#define OFFSET_X (offset_x << 16) + ((int)shrink_factor * 3 << 15)
#define OFFSET_Y (offset_y << 16) + ((int)shrink_factor * 3 << 15)
#ifndef BMLONG
#ifndef BMSHORT
BMUNIT bit_masks[9] = {
0x0, 0x1, 0x3, 0x7,
0xf, 0x1f, 0x3f, 0x7f,
0xff
};
#else /* BMSHORT */
BMUNIT bit_masks[17] = {
0x0, 0x1, 0x3, 0x7,
0xf, 0x1f, 0x3f, 0x7f,
0xff, 0x1ff, 0x3ff, 0x7ff,
0xfff, 0x1fff, 0x3fff, 0x7fff,
0xffff
};
#endif /* BMSHORT */
#else /* BMLONG */
BMUNIT bit_masks[33] = {
0x0, 0x1, 0x3, 0x7,
0xf, 0x1f, 0x3f, 0x7f,
0xff, 0x1ff, 0x3ff, 0x7ff,
0xfff, 0x1fff, 0x3fff, 0x7fff,
0xffff, 0x1ffff, 0x3ffff, 0x7ffff,
0xfffff, 0x1fffff, 0x3fffff, 0x7fffff,
0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff,
0xfffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
0xffffffff
};
#endif /* BMLONG */
#ifdef VMS
#define off_t int
#endif
extern off_t lseek();
#ifndef SEEK_SET /* if <unistd.h> is not provided (or for <X11R5) */
#define SEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif
static void draw_part(struct frame *, double);
static void put_border(int x, int y, unsigned int width, unsigned int height)
{
--width;
--height;
dcp->drawRect( x, y, width, height );
}
/*
* Byte reading routines for dvi file.
*/
#define xtell(pos) ((long) (lseek(fileno(dvi_file), 0L, SEEK_CUR) - \
(currinf.end - (pos))))
#define xtell(pos) ((long) (lseek(fileno(dvi_file), 0L, SEEK_CUR) - (currinf.end - (pos))))
static unsigned char xxone()
{
@ -209,18 +158,18 @@ static void xskip(long offset)
static NORETURN void tell_oops(_Xconst char *message, ...)
{
va_list args;
kdError() << prog << ": " << endl;
va_start(args, message);
(void) vfprintf(stderr, message, args);
va_end(args);
if (currinf._virtual)
kdError() << " in virtual font " << currinf._virtual->fontname << endl;
else
kdError() << ", offset " << xtell(currinf.pos - 1) << "d" << endl;
dvi_oops_msg = (message), longjmp(dvi_env, 1); /* dvi_oops */
exit(1);
/* @@@
kdError() << prog << ": " << endl;
va_start(args, message);
(void) vfprintf(stderr, message, args);
va_end(args);
if (currinf._virtual)
kdError() << " in virtual font " << currinf._virtual->fontname << endl;
else
kdError() << ", offset " << xtell(currinf.pos - 1) << "d" << endl;
*/
dvi_oops_msg = (message), longjmp(dvi_env, 1); /* dvi_oops */
exit(1);
}
@ -257,8 +206,10 @@ void set_char(unsigned int cmd, unsigned int ch)
long dvi_h_sav = DVI_H;
if (currinf.dir < 0)
DVI_H -= g->dvi_adv;
if (scan_frame == NULL)
dcp->drawPixmap(PXL_H - g->x2 - currwin.base_x, PXL_V - g->y2 - currwin.base_y, g->shrunkCharacter());
if (PostScriptOutPutFile == NULL)
foreGroundPaint.drawPixmap(PXL_H - g->x2 - currwin.base_x,
PXL_V - g->y2 - currwin.base_y,
g->shrunkCharacter());
if (cmd == PUT1)
DVI_H = dvi_h_sav;
else
@ -298,8 +249,7 @@ void set_vf_char(unsigned int cmd, unsigned int ch)
long dvi_h_sav;
if ((m = &currinf.fontp->macrotable[ch])->pos == NULL) {
if (!hush_chars)
kdError() << "Character " << ch << " not defined in font" << currinf.fontp->fontname << endl;
kdError() << "Character " << ch << " not defined in font" << currinf.fontp->fontname << endl;
m->pos = m->end = &c;
return;
}
@ -307,7 +257,7 @@ void set_vf_char(unsigned int cmd, unsigned int ch)
dvi_h_sav = DVI_H;
if (currinf.dir < 0)
DVI_H -= m->dvi_adv;
if (scan_frame == NULL) {
if (PostScriptOutPutFile == NULL) {
oldinfo = currinf;
WW = 0;
XX = 0;
@ -318,7 +268,7 @@ void set_vf_char(unsigned int cmd, unsigned int ch)
currinf.pos = m->pos;
currinf.end = m->end;
currinf._virtual = currinf.fontp;
draw_part(current_frame, currinf.fontp->dimconv);
//@@@ draw_part(current_frame, currinf.fontp->dimconv);
if (currinf.pos != currinf.end + 1)
tell_oops("virtual character macro does not end correctly");
currinf = oldinfo;
@ -352,9 +302,9 @@ static void set_no_char(unsigned int cmd, unsigned int ch)
static void set_rule(int h, int w)
{
dcp->fillRect( PXL_H - (currinf.dir < 0 ? w - 1 : 0)-currwin.base_x,
PXL_V - h + 1 -currwin.base_y,
w?w:1, h?h:1, Qt::black );
foreGroundPaint.fillRect( PXL_H - (currinf.dir < 0 ? w - 1 : 0)-currwin.base_x,
PXL_V - h + 1 -currwin.base_y,
w?w:1, h?h:1, Qt::black );
}
static void special(long nbytes)
@ -362,7 +312,7 @@ static void special(long nbytes)
static char *cmd = NULL;
static long cmdlen = -1;
char *p;
if (cmdlen < nbytes) {
if (cmd)
free(cmd);
@ -372,7 +322,7 @@ static void special(long nbytes)
p = cmd;
for (;;) {
int i = currinf.end - currinf.pos;
if (i > nbytes)
i = nbytes;
bcopy((char *) currinf.pos, p, i);
@ -389,19 +339,17 @@ static void special(long nbytes)
#define xspell_conv(n) spell_conv0(n, current_dimconv)
static void draw_part(struct frame *minframe, double current_dimconv)
void dviWindow::draw_part(struct frame *minframe, double current_dimconv)
{
kdDebug() << "draw_part" << endl;
unsigned char ch;
struct drawinf oldinfo;
off_t file_pos;
int refl_count;
currinf.fontp = NULL;
currinf.set_char_p = set_no_char;
currinf.dir = 1;
scan_frame = NULL; /* indicates we're not scanning */
currinf.fontp = NULL;
currinf.set_char_p = set_no_char;
currinf.dir = 1;
PostScriptOutPutFile = NULL; /* indicates we're not scanning */
for (;;) {
ch = xone();
@ -425,7 +373,7 @@ static void draw_part(struct frame *minframe, double current_dimconv)
SIGFPE here. */
a = xsfour();
b = xspell_conv(xsfour());
if (a > 0 && b > 0 && scan_frame == NULL)
if (a > 0 && b > 0 && PostScriptOutPutFile == NULL)
set_rule(pixel_round(xspell_conv(a)),
pixel_round(b));
DVI_H += DIR * b;
@ -434,7 +382,7 @@ static void draw_part(struct frame *minframe, double current_dimconv)
case PUTRULE:
a = xspell_conv(xsfour());
b = xspell_conv(xsfour());
if (a > 0 && b > 0 && scan_frame == NULL)
if (a > 0 && b > 0 && PostScriptOutPutFile == NULL)
set_rule(pixel_round(a), pixel_round(b));
break;
@ -443,8 +391,8 @@ static void draw_part(struct frame *minframe, double current_dimconv)
case BOP:
xskip((long) 11 * 4);
DVI_H = OFFSET_X;
DVI_V = OFFSET_Y;
DVI_H = basedpi << 16; // Reminder: DVI-coords. start at (1",1") from top of page
DVI_V = basedpi << 16;
PXL_V = pixel_conv(DVI_V);
WW = XX = YY = ZZ = 0;
break;
@ -473,64 +421,6 @@ static void draw_part(struct frame *minframe, double current_dimconv)
current_frame = current_frame->prev;
break;
case SREFL:
if (scan_frame == NULL) {
/* we're not scanning: save some info. */
oldinfo = currinf;
if (!currinf._virtual)
file_pos = xtell(currinf.pos);
scan_frame = current_frame; /* now we're scanning */
refl_count = 0;
break;
}
/* we are scanning */
if (current_frame == scan_frame)
++refl_count;
break;
case EREFL:
if (scan_frame != NULL) { /* if we're scanning */
if (current_frame == scan_frame && --refl_count < 0) {
/* we've hit the end of our scan */
scan_frame = NULL;
/* first: push */
if (current_frame->next == NULL) {
struct frame *newp = (struct frame *)xmalloc(sizeof(struct frame),"stack frame");
current_frame->next = newp;
newp->prev = current_frame;
newp->next = NULL;
}
current_frame = current_frame->next;
current_frame->data = currinf.data;
/* next: restore old file position, XX, etc. */
if (!currinf._virtual) {
off_t bgn_pos = xtell(dvi_buffer);
if (file_pos >= bgn_pos) {
oldinfo.pos = dvi_buffer + (file_pos - bgn_pos);
oldinfo.end = currinf.end;
} else {
(void) lseek(fileno(dvi_file), file_pos, SEEK_SET);
oldinfo.pos = oldinfo.end;
}
}
currinf = oldinfo;
/* and then: recover position info. */
DVI_H = current_frame->data.dvi_h;
DVI_V = current_frame->data.dvi_v;
PXL_V = current_frame->data.pxl_v;
/* and finally, reverse direction */
currinf.dir = -currinf.dir;
}
break;
}
/* we're not scanning, */
/* so just reverse direction and then pop */
currinf.dir = -currinf.dir;
currinf.data = current_frame->data;
current_frame = current_frame->prev;
break;
case RIGHT1:
case RIGHT2:
case RIGHT3:
@ -640,7 +530,7 @@ static void draw_part(struct frame *minframe, double current_dimconv)
int need_to_redraw;
void draw_page()
void dviWindow::draw_page(void)
{
kdDebug() <<"draw_page" << endl;
@ -650,10 +540,6 @@ void draw_page()
if (!check_dvi_file())
return;
put_border(-currwin.base_x, -currwin.base_y,
ROUNDUP(unshrunk_paper_w, shrink_factor) + 2,
ROUNDUP(unshrunk_paper_h, shrink_factor) + 2);
(void) lseek(fileno(dvi_file), page_offset[current_page], SEEK_SET);
bzero((char *) &currinf.data, sizeof(currinf.data));
@ -662,8 +548,71 @@ void draw_page()
currinf.end = dvi_buffer;
currinf.pos = dvi_buffer;
currinf._virtual = NULL;
draw_part(current_frame = &frame0, dimconv);
if (need_to_redraw != 0)
draw_page();
foreGroundPaint.drawRect(-currwin.base_x,
-currwin.base_y,
(int)(unshrunk_paper_w / shrink_factor + 0.5),
(int)(unshrunk_paper_h / shrink_factor + 0.5) );
#ifdef auskommentiert
// Now the PostScriptString contains the PostScript commands needed
// to run gs. So far, this is a dreadful hack.
// Step 0: Generate the PostScript commands
PostScriptString.truncate(0);
PostScriptOutPutFile = (FILE *)1;
draw_part(current_frame = &frame0, dimconv);
PostScriptOutPutFile = NULL;
// Step 1: Write the PostScriptString to a File
FILE *f = fopen("/tmp/t","w");
Fputs("(/usr/share/texmf/dvips/base/texc.pro) run\n",f);
Fputs("(/usr/share/texmf/dvips/base/special.pro) run\n",f);
Fputs("TeXDict begin",f);
Fputs(" 39158280",f); // HSize in (1/(65781.76*72))inch
// Fputs(" 55380996",f); // VSize in (1/(65781.76*72))inch
Fputs(" 51880996",f); // VSize in (1/(65781.76*72))inch
Fputs(" 1000",f); // Magnification
Fputs(" 300 300",f); // dpi and vdpi
Fputs("(test.dvi)",f); // Name
Fputs("@start end\n",f);
Fputs("TeXDict begin\n",f);
Fputs("1 0 bop 0 0 a \n",f);
// Fputs("@beginspecial 0 @llx 0 @lly 100 @urx 100 @ury @setspecial\n",f);
Fputs(PostScriptString.latin1(),f);
// Fputs("@endspecial\n",f);
Fputs("end\n",f);
Fputs("showpage \n",f);
Fclose(f);
// Step 2: Call GS with the File
KProcess proc;
proc << "gs";
proc << "-dNOPAUSE" << "-dBATCH" << "-sDEVICE=pnm" << "-sOutputFile=/tmp/s";
// Set page size in pixels
proc << QString("-g%1x%2").arg(page_w).arg(page_h);
// Resolution in dpi
proc << QString("-r%1").arg(300.0/currwin.shrinkfactor); //@@@
proc << "/tmp/t";
proc.start(KProcess::Block);
// Step 3: write the generated output to the pixmap
QPixmap tmp("/tmp/s");
foreGroundPaint.drawPixmap(0, 0, tmp);
// Step 4: Now really write the text
(void) lseek(fileno(dvi_file), page_offset[current_page], SEEK_SET);
bzero((char *) &currinf.data, sizeof(currinf.data));
currinf.fonttable = tn_table;
currinf.end = dvi_buffer;
currinf.pos = dvi_buffer;
currinf._virtual = NULL;
#endif
//Step 5: remove temp-files @@@
draw_part(current_frame = &frame0, dimconv);
}

View file

@ -124,8 +124,6 @@ unsigned char font::load_font(void)
int size_found;
int magic;
Boolean hushcs = hush_chk;
flags |= font::FONT_LOADED;
file = font_open(fontname, &font_found, (double)fsize, &size_found, &filename);
if (file == NULL) {
@ -137,7 +135,6 @@ unsigned char font::load_font(void)
kdError() << "Can't find font " << fontname << "; using " << font_found << " instead at " << dpi << " dpi." << endl;
free(fontname);
fontname = font_found;
hushcs = True;
}
else
if (!kpse_bitmap_tolerance ((double) size_found, fsize))
@ -148,13 +145,13 @@ unsigned char font::load_font(void)
magic = two(file);
if (magic == PK_MAGIC)
read_PK_index(WIDENINT hushcs);
read_PK_index();
else
if (magic == GF_MAGIC)
oops("The GF format for font file %s is no longer supported", filename);
else
if (magic == VF_MAGIC)
read_VF_index(WIDENINT hushcs);
read_VF_index();
else
oops("Cannot recognize format for font file %s", filename);

4
font.h
View file

@ -83,14 +83,14 @@ struct font {
FILE *font_open (char *font, char **font_ret, double dpi, int *dpi_ret, char **filename_ret);
// Functions related to virtual fonts
void read_VF_index(unsigned int hushcs);
void read_VF_index(void );
// Functions for pk fonts
int PK_get_nyb(FILE *fp);
int PK_packed_num(FILE *fp);
void PK_skip_specials(void);
void read_PK_char(unsigned int ch);
void read_PK_index(unsigned int hushcs);
void read_PK_index(void);
};

23
pk.cpp
View file

@ -60,6 +60,21 @@
#include "glyph.h"
#include "oconfig.h"
extern char *xmalloc (unsigned, _Xconst char *);
BMUNIT bit_masks[33] = {
0x0, 0x1, 0x3, 0x7,
0xf, 0x1f, 0x3f, 0x7f,
0xff, 0x1ff, 0x3ff, 0x7ff,
0xfff, 0x1fff, 0x3fff, 0x7fff,
0xffff, 0x1ffff, 0x3ffff, 0x7ffff,
0xfffff, 0x1fffff, 0x3fffff, 0x7fffff,
0xffffff, 0x1ffffff, 0x3ffffff, 0x7ffffff,
0xfffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
0xffffffff
};
/***
*** PK font reading routines.
*** Public routines are read_PK_index and read_PK_char.
@ -327,7 +342,7 @@ void font::read_PK_char(unsigned int ch)
}
}
void font::read_PK_index(unsigned int hushcs)
void font::read_PK_index(void)
{
kdDebug() << "Reading PK pixel file " << filename << endl;
@ -335,8 +350,10 @@ void font::read_PK_index(unsigned int hushcs)
(void) four(file); /* skip design size */
long file_checksum = four(file);
if (!hushcs && checksum && checksum && file_checksum != checksum)
kdError(1) << "Checksum mismatch (dvi = " << checksum << "pk = " << file_checksum << ") in font file " << filename << endl;
if (checksum && checksum && file_checksum != checksum)
kdError(1) << "Checksum mismatch (dvi = " << checksum << "pk = " << file_checksum <<
") in font file " << filename << endl;
int hppp = sfour(file);
int vppp = sfour(file);
if (hppp != vppp)

View file

@ -17,6 +17,7 @@
#include <qfile.h>
#include <kmessagebox.h>
#include <kdebug.h>
#include <kapp.h>
#include <kconfig.h>
#include <kdebug.h>
@ -270,7 +271,7 @@ void Print::okPressed()
cmd += " &";
kdDebug(4300) << "About to run: " << cmd.data() << endl;
kdError() << "About to run: " << cmd.data() << endl;
system( cmd );
accept();
}

View file

@ -79,14 +79,9 @@ extern "C" {
#define TWOPI (3.14159265359*2.0)
#define MAX_PEN_SIZE 7 /* Max pixels of pen width */
extern QString PostScriptString;
static int xx[MAXPOINTS], yy[MAXPOINTS]; /* Path in milli-inches */
static int path_len = 0; /* # points in current path */
static int pen_size = 1; /* Pixel width of lines drawn */
static Boolean whiten = False;
static Boolean shade = False;
static Boolean blacken = False;
GC ruleGC; // @@@ needs to be removed.
/* Unfortunately, these values also appear in dvisun.c */
@ -94,370 +89,6 @@ GC ruleGC; // @@@ needs to be removed.
#define yRESOLUTION (pixels_per_inch/shrink_factor)
/*
* Issue warning messages
*/
static void Warning(char *fmt, char *msg)
{
Fprintf(stderr, fmt, msg);
(void) fputc('\n', stderr);
}
/*
* X drawing routines
*/
#define toint(x) ((int) ((x) + 0.5))
#define xconv(x) (toint(tpic_conv*(x))/shrink_factor + PXL_H)
#define yconv(y) (toint(tpic_conv*(y))/shrink_factor + PXL_V)
/*
* Draw a line from (fx,fy) to (tx,ty).
* Right now, we ignore pen_size.
*/
static void line_btw(int fx, int fy, int tx, int ty)
{
register int fcx = xconv(fx),
tcx = xconv(tx),
fcy = yconv(fy),
tcy = yconv(ty);
if ((fcx < max_x || tcx < max_x) && (fcx >= min_x || tcx >= min_x) &&
(fcy < max_y || tcy < max_y) && (fcy >= min_y || tcy >= min_y))
XDrawLine(DISP, currwin.win, ruleGC,
fcx - currwin.base_x, fcy - currwin.base_y,
tcx - currwin.base_x, tcy - currwin.base_y);
}
/*
* Draw a dot at (x,y)
*/
static void dot_at(int x, int y)
{
register int cx = xconv(x),
cy = yconv(y);
if (cx < max_x && cx >= min_x && cy < max_y && cy >= min_y)
XDrawPoint(DISP, currwin.win, ruleGC,
cx - currwin.base_x, cy - currwin.base_y);
}
/*
* Apply the requested attributes to the last path (box) drawn.
* Attributes are reset.
* (Not currently implemented.)
*/
/* ARGSUSED */
static void do_attribute_path(int last_min_x, int last_max_x, int last_min_y, int last_max_y)
{
}
/*
* Set the size of the virtual pen used to draw in milli-inches
*/
/* ARGSUSED */
static void set_pen_size(char *cp)
{
int ps;
if (sscanf(cp, " %d ", &ps) != 1) {
Warning("illegal .ps command format: %s", cp);
return;
}
pen_size = (ps * (xRESOLUTION + yRESOLUTION) + 1000) / 2000;
if (pen_size < 1) pen_size = 1;
else if (pen_size > MAX_PEN_SIZE) pen_size = MAX_PEN_SIZE;
}
/*
* Print the line defined by previous path commands
*/
static void flush_path()
{
register int i;
int last_min_x, last_max_x, last_min_y, last_max_y;
last_min_x = 30000;
last_min_y = 30000;
last_max_x = -30000;
last_max_y = -30000;
for (i = 1; i < path_len; i++) {
if (xx[i] > last_max_x) last_max_x = xx[i];
if (xx[i] < last_min_x) last_min_x = xx[i];
if (yy[i] > last_max_y) last_max_y = yy[i];
if (yy[i] < last_min_y) last_min_y = yy[i];
line_btw(xx[i], yy[i], xx[i+1], yy[i+1]);
}
if (xx[path_len] > last_max_x) last_max_x = xx[path_len];
if (xx[path_len] < last_min_x) last_min_x = xx[path_len];
if (yy[path_len] > last_max_y) last_max_y = yy[path_len];
if (yy[path_len] < last_min_y) last_min_y = yy[path_len];
path_len = 0;
do_attribute_path(last_min_x, last_max_x, last_min_y, last_max_y);
}
/*
* Print a dashed line along the previously defined path, with
* the dashes/inch defined.
*/
static void flush_dashed(char *cp, Boolean dotted)
{
int i;
int numdots;
int lx0, ly0, lx1, ly1;
int cx0, cy0, cx1, cy1;
float inchesperdash;
double d, spacesize, a, b, dx, dy, milliperdash;
if (sscanf(cp, " %f ", &inchesperdash) != 1) {
Warning("illegal format for dotted/dashed line: %s", cp);
return;
}
if (path_len <= 1 || inchesperdash <= 0.0) {
Warning("illegal conditions for dotted/dashed line", "");
return;
}
milliperdash = inchesperdash * 1000.0;
lx0 = xx[1]; ly0 = yy[1];
lx1 = xx[2]; ly1 = yy[2];
dx = lx1 - lx0;
dy = ly1 - ly0;
if (dotted) {
numdots = sqrt(dx*dx + dy*dy) / milliperdash + 0.5;
if (numdots == 0) numdots = 1;
for (i = 0; i <= numdots; i++) {
a = (float) i / (float) numdots;
cx0 = lx0 + a * dx + 0.5;
cy0 = ly0 + a * dy + 0.5;
dot_at(cx0, cy0);
}
}
else {
d = sqrt(dx*dx + dy*dy);
numdots = d / (2.0 * milliperdash) + 1.0;
if (numdots <= 1)
line_btw(lx0, ly0, lx1, ly1);
else {
spacesize = (d - numdots * milliperdash) / (numdots - 1);
for (i = 0; i < numdots - 1; i++) {
a = i * (milliperdash + spacesize) / d;
b = a + milliperdash / d;
cx0 = lx0 + a * dx + 0.5;
cy0 = ly0 + a * dy + 0.5;
cx1 = lx0 + b * dx + 0.5;
cy1 = ly0 + b * dy + 0.5;
line_btw(cx0, cy0, cx1, cy1);
b += spacesize / d;
}
cx0 = lx0 + b * dx + 0.5;
cy0 = ly0 + b * dy + 0.5;
line_btw(cx0, cy0, lx1, ly1);
}
}
path_len = 0;
}
/*
* Add a point to the current path
*/
static void add_path(char *cp)
{
int pathx, pathy;
if (++path_len >= MAXPOINTS) oops("Too many points");
if (sscanf(cp, " %d %d ", &pathx, &pathy) != 2)
oops("Malformed path command");
xx[path_len] = pathx;
yy[path_len] = pathy;
}
/*
* Draw to a floating point position
*/
static void im_fdraw(double x, double y)
{
if (++path_len >= MAXPOINTS) oops("Too many arc points");
xx[path_len] = x + 0.5;
yy[path_len] = y + 0.5;
}
/*
* Draw an ellipse with the indicated center and radices.
*/
static void draw_ellipse(int xc, int yc, int xr, int yr)
{
double angle, theta;
int n;
int px0, py0, px1, py1;
angle = (xr + yr) / 2.0;
theta = sqrt(1.0 / angle);
n = TWOPI / theta + 0.5;
if (n < 12) n = 12;
else if (n > 80) n = 80;
n /= 2;
theta = TWOPI / n;
angle = 0.0;
px0 = xc + xr; /* cos(0) = 1 */
py0 = yc; /* sin(0) = 0 */
while ((angle += theta) <= TWOPI) {
px1 = xc + xr*cos(angle) + 0.5;
py1 = yc + yr*sin(angle) + 0.5;
line_btw(px0, py0, px1, py1);
px0 = px1;
py0 = py1;
}
line_btw(px0, py0, xc + xr, yc);
}
/*
* Draw an arc
*/
static void arc(char *cp, Boolean invis)
{
int xc, yc, xrad, yrad, n;
float start_angle, end_angle, angle, theta, r;
double xradius, yradius, xcenter, ycenter;
if (sscanf(cp, " %d %d %d %d %f %f ", &xc, &yc, &xrad, &yrad,
&start_angle, &end_angle) != 6) {
Warning("illegal arc specification: %s", cp);
return;
}
if (invis) return;
/* We have a specialized fast way to draw closed circles/ellipses */
if (start_angle <= 0.0 && end_angle >= 6.282) {
draw_ellipse(xc, yc, xrad, yrad);
return;
}
xcenter = xc;
ycenter = yc;
xradius = xrad;
yradius = yrad;
r = (xradius + yradius) / 2.0;
theta = sqrt(1.0 / r);
n = 0.3 * TWOPI / theta + 0.5;
if (n < 12) n = 12;
else if (n > 80) n = 80;
n /= 2;
theta = TWOPI / n;
flush_path();
im_fdraw(xcenter + xradius * cos(start_angle),
ycenter + yradius * sin(start_angle));
angle = start_angle + theta;
if (end_angle < start_angle) end_angle += TWOPI;
while (angle < end_angle) {
im_fdraw(xcenter + xradius * cos(angle),
ycenter + yradius * sin(angle));
angle += theta;
}
im_fdraw(xcenter + xradius * cos(end_angle),
ycenter + yradius * sin(end_angle));
flush_path();
}
/*
* APPROXIMATE integer distance between two points
*/
#define dist(x0, y0, x1, y1) (abs(x0 - x1) + abs(y0 - y1))
/*
* Draw a spline along the previously defined path
*/
static void flush_spline()
{
int xp, yp;
int N;
int lastx, lasty;
Boolean lastvalid = False;
int t1, t2, t3;
int steps;
int j;
register int i, w;
#ifdef lint
lastx = lasty = -1;
#endif
N = path_len + 1;
xx[0] = xx[1];
yy[0] = yy[1];
xx[N] = xx[N-1];
yy[N] = yy[N-1];
for (i = 0; i < N - 1; i++) { /* interval */
steps = (dist(xx[i], yy[i], xx[i+1], yy[i+1]) +
dist(xx[i+1], yy[i+1], xx[i+2], yy[i+2])) / 80;
for (j = 0; j < steps; j++) { /* points within */
w = (j * 1000 + 500) / steps;
t1 = w * w / 20;
w -= 500;
t2 = (750000 - w * w) / 10;
w -= 500;
t3 = w * w / 20;
xp = (t1*xx[i+2] + t2*xx[i+1] + t3*xx[i] + 50000) / 100000;
yp = (t1*yy[i+2] + t2*yy[i+1] + t3*yy[i] + 50000) / 100000;
if (lastvalid) line_btw(lastx, lasty, xp, yp);
lastx = xp;
lasty = yp;
lastvalid = True;
}
}
path_len = 0;
}
/*
* Shade the last box, circle, or ellipse
*/
static void shade_last()
{
blacken = whiten = False;
shade = True;
}
/*
* Make the last box, circle, or ellipse, white inside (shade with white)
*/
static void whiten_last()
{
whiten = True;
blacken = shade = False;
}
/*
* Make last box, etc, black inside
*/
static void blacken_last()
{
blacken = True;
whiten = shade = False;
}
/*
* Code for PostScript<tm> specials begins here.
@ -495,12 +126,14 @@ static int bbox_voffset;
void draw_bbox()
{
if (bbox_valid) {
put_border(PXL_H - currwin.base_x,
PXL_V - currwin.base_y - bbox_voffset,
bbox_width, bbox_height);
bbox_valid = False;
}
#ifdef auskommentiert
if (bbox_valid) {
put_border(PXL_H - currwin.base_x,
PXL_V - currwin.base_y - bbox_voffset,
bbox_width, bbox_height);
bbox_valid = False;
}
#endif
}
static void actual_startup()
@ -528,29 +161,23 @@ static void NullProc2(char *cp)
/* ARGSUSED */
void drawbegin_none(int xul, int yul, char *cp)
{
draw_bbox();
draw_bbox();
}
#ifdef auskommentiert
/* If FILENAME starts with a left quote, set *DECOMPRESS to 1 and return
the rest of FILENAME. Otherwise, look up FILENAME along the usual
path for figure files, set *DECOMPRESS to 0, and return the result
(NULL if can't find the file). */
static string find_fig_file (char *filename, int *decompress)
static string find_fig_file (char *filename)
{
char *name;
if (*filename == '`') {
name = filename + 1;
*decompress = 1;
} else {
name = kpse_find_pict (filename);
if (!name)
fprintf (stderr, "xdvi: %s: Cannot open PS file.\n", filename);
*decompress = 0;
}
name = kpse_find_pict (filename);
if (!name)
kdError() << "Cannot open PS file " << filename << endl;
return name;
}
@ -560,36 +187,16 @@ static string find_fig_file (char *filename, int *decompress)
DECOMPRESS is nonzero, open a pipe to it and pass the resulting
output to the drawraw proc (in chunks). */
static void draw_file (psprocs psp, char *name, int decompress)
static void draw_file (psprocs psp, char *name)
{
if (decompress) {
FILE *pipe;
if (_debug & DBG_PS)
printf ("%s: piping to PostScript\n", name);
pipe = popen (name, FOPEN_R_MODE);
if (pipe == NULL)
perror (name);
else
{
char *line;
int save_debug = _debug;
_debug = 0; /* don't print every line we send */
while ((line = read_line (pipe)) != NULL) {
psp.drawraw (line);
free (line);
}
pclose (pipe); /* Linux gives a spurious error, so don't check. */
_debug = save_debug;
}
} else { /* a regular file, not decompressing */
psp.drawfile (name);
}
kDebugInfo(DEBUG, 4300, "draw file %s",name);
psp.drawfile (name);
}
static void psfig_special(char *cp)
{
kDebugInfo("PSFig special: %s",cp);
char *filename;
int raww, rawh;
@ -611,11 +218,10 @@ static void psfig_special(char *cp)
for (filename = cp; !isspace(*cp); ++cp);
*cp = '\0';
{
int decompress;
char *name = find_fig_file (filename, &decompress);
char *name = find_fig_file (filename);
if (name && currwin.win == mane.win) {
draw_file(psp, name, decompress);
if (!decompress && name != filename)
draw_file(psp, name);
if (name != filename)
free (name);
}
}
@ -637,24 +243,26 @@ static void psfig_special(char *cp)
}
}
}
#endif
/* Keys for epsf specials */
static const char *keytab[] = {"clip",
"llx",
"lly",
"urx",
"ury",
"rwi",
"rhi",
"hsize",
"vsize",
"hoffset",
"voffset",
"hscale",
"vscale",
"angle"};
static const char *keytab[] = {
"clip",
"llx",
"lly",
"urx",
"ury",
"rwi",
"rhi",
"hsize",
"vsize",
"hoffset",
"voffset",
"hscale",
"vscale",
"angle"
};
#define KEY_LLX keyval[0]
#define KEY_LLY keyval[1]
@ -666,10 +274,101 @@ static const char *keytab[] = {"clip",
#define NKEYS (sizeof(keytab)/sizeof(*keytab))
#define N_ARGLESS_KEYS 1
static parse_special_argument(QString strg, char *argument_name, int *variable)
{
bool OK;
int index = strg.find(argument_name);
if (index >= 0) {
QString tmp = strg.mid(index + strlen(argument_name));
tmp.truncate(tmp.find(' '));
int tmp_int = tmp.toUInt(&OK);
if (OK)
*variable = tmp_int;
else
kdError() << "Malformed urx in special" << endl;
}
}
extern QPainter foreGroundPaint;
static void epsf_special(char *cp)
{
kdError() << "epsf-special: psf" << cp <<endl;
QString include_command_line(cp);
QString include_command = include_command_line.simplifyWhiteSpace();
// The line is supposed to start with "..ile=", and then comes the
// filename. Figure out what the filename is and stow it away
if (include_command.find("ile=") != 0) {
kdError() << "epsf special PSf" << cp << " is unknown" << endl;
return;
}
QString filename = include_command.mid(4);
filename.truncate(filename.find(' '));
char *name = kpse_find_pict(filename.local8Bit());
if (name != NULL) {
filename = name;
free(name);
} else
filename.truncate(0);
//
// Now parse the arguments.
//
int llx = 0;
int lly = 0;
int urx = 0;
int ury = 0;
int rwi = 0;
int rhi = 0;
int hoffset = 0;
// just to avoid ambiguities; the filename could contain keywords
include_command = include_command.mid(include_command.find(' '));
parse_special_argument(include_command, "llx=", &llx);
parse_special_argument(include_command, "lly=", &lly);
parse_special_argument(include_command, "urx=", &urx);
parse_special_argument(include_command, "ury=", &ury);
parse_special_argument(include_command, "rwi=", &rwi);
parse_special_argument(include_command, "rhi=", &rhi);
// calculate the size of the bounding box
double bbox_width = urx - llx;
double bbox_height = lly - ury;
if ((rwi != 0)&&(bbox_width != 0)) {
bbox_height = bbox_height*rwi/bbox_width;
bbox_width = rwi;
}
if ((rhi != 0)&&(bbox_height != 0)) {
bbox_height = rhi;
bbox_width = bbox_width*rhi/bbox_height;
}
bbox_width *= 0.1 * dimconv / shrink_factor;
bbox_height *= 0.1 * dimconv / shrink_factor;
// Now draw the bounding box
QRect bbox(PXL_H - currwin.base_x, PXL_V - currwin.base_y, (int)bbox_width, (int)bbox_height);
// foreGroundPaint.rotate(20);
foreGroundPaint.setBrush(Qt::lightGray);
foreGroundPaint.setPen (Qt::black);
foreGroundPaint.drawRoundRect(bbox, 1, 1);
foreGroundPaint.drawText (bbox, (int)(Qt::AlignCenter), filename, -1, &bbox);
PostScriptString.append( QString(" %1 %2 moveto\n").arg(PXL_H - currwin.base_x).arg(PXL_V - currwin.base_y) );
PostScriptString.append( "@beginspecial @setspecial \n" );
PostScriptString.append( QString(" (%1) run\n").arg(filename) );
PostScriptString.append( "@endspecial \n" );
return;
/*
char *filename, *name;
int decompress;
static char *buffer;
static unsigned int buflen = 0;
unsigned int len;
@ -683,6 +382,7 @@ static void epsf_special(char *cp)
return;
}
// find the filename
p = cp + 4;
filename = p;
if (*p == '\'' || *p == '"') {
@ -692,13 +392,17 @@ static void epsf_special(char *cp)
++filename;
}
else
while (*p != '\0' && *p != ' ' && *p != '\t')
while (*p != '\0' && *p != ' ' && *p != '\t') // Go to end of string or to next white space
++p;
if (*p != '\0')
*p++ = '\0';
name = find_fig_file (filename, &decompress);
name = find_fig_file (filename);
// Skip white space
while (*p == ' ' || *p == '\t')
++p;
len = strlen(p) + NKEYS + 30;
if (buflen < len) {
if (buflen != 0)
@ -716,7 +420,11 @@ static void epsf_special(char *cp)
++p1;
for (keyno = 0;; ++keyno) {
if (keyno >= NKEYS) {
<<<<<<< special.cpp
kDebugError(4300, 1, "The unknown keyword (%*s) in \\special will be ignored", (int)(p1 - p), p);
=======
kdError(4300) << "unknown keyword in \\special will be ignored" << endl;
>>>>>>> 1.6
break;
}
if (memcmp(p, keytab[keyno], p1 - p) == 0) {
@ -735,7 +443,7 @@ static void epsf_special(char *cp)
*q++ = '@';
Strcpy(q, keytab[keyno]);
q += strlen(q);
break;
break;
}
}
p = p1;
@ -749,109 +457,72 @@ static void epsf_special(char *cp)
bbox_valid = False;
if ((flags & 0x30) == 0x30 || ((flags & 0x30) && (flags & 0xf) == 0xf)){
bbox_valid = True;
bbox_width = 0.1 * ((flags & 0x10) ? KEY_RWI
: KEY_RHI * (KEY_URX - KEY_LLX) / (KEY_URY - KEY_LLY))
bbox_width = 0.1 * ((flags & 0x10) ? KEY_RWI : KEY_RHI * (KEY_URX - KEY_LLX) / (KEY_URY - KEY_LLY))
* dimconv / shrink_factor + 0.5;
bbox_voffset = bbox_height = 0.1 * ((flags & 0x20) ? KEY_RHI
: KEY_RWI * (KEY_URY - KEY_LLY) / (KEY_URX - KEY_LLX))
bbox_voffset =
bbox_height = 0.1 * ((flags & 0x20) ? KEY_RHI : KEY_RWI * (KEY_URY - KEY_LLY) / (KEY_URX - KEY_LLX))
* dimconv / shrink_factor + 0.5;
}
if (name && currwin.win == mane.win) {
psp.drawbegin(PXL_H - currwin.base_x, PXL_V - currwin.base_y, buffer);
draw_file(psp, name, decompress);
draw_file(psp, name);
psp.drawend(" @endspecial");
if (!decompress && name != filename)
if (name != filename)
free (name);
}
bbox_valid = False;
*/
}
/*
static void bang_special(char *cp)
{
<<<<<<< special.cpp
kDebugInfo(DEBUG, 4300, "bang %s", cp);
=======
>>>>>>> 1.6
bbox_valid = False;
if (currwin.win == mane.win) {
psp.drawbegin(PXL_H - currwin.base_x, PXL_V - currwin.base_y, "@defspecial ");
/* talk directly with the DPSHandler here */
psp.drawraw(cp);
psp.drawend(" @fedspecial");
}
}
*/
static void quote_special(char *cp)
static void quote_special(QString cp)
{
bbox_valid = False;
kdError() << "PostScript-quote " << cp.latin1() << endl;
if (currwin.win == mane.win) {
psp.drawbegin(PXL_H - currwin.base_x, PXL_V - currwin.base_y, "@beginspecial @setspecial ");
/* talk directly with the DPSHandler here */
psp.drawraw(cp);
psp.drawend(" @endspecial");
PostScriptString.append( QString(" %1 %2 moveto\n").arg(DVI_H/65536 - 300).arg(DVI_V/65536 - 300) );
/*
kDebugInfo("DVI_H/65536 %d",(int)(DVI_H/65536) );
kDebugInfo("DVI_V/65536 %d",(int)(DVI_V/65536) );
kDebugInfo("PXL_V %d",(int)(PXL_V) );
kDebugInfo("unshrunk page_h %d",unshrunk_page_h);
*/
PostScriptString.append( " @beginspecial @setspecial \n" );
PostScriptString.append( cp );
PostScriptString.append( " @endspecial \n" );
}
}
/*
* The following copyright message applies to the rest of this file. --PV
*/
/*
* This program is Copyright (C) 1987 by the Board of Trustees of the
* University of Illinois, and by the author Dirk Grunwald.
*
* This program may be freely copied, as long as this copyright
* message remaines affixed. It may not be sold, although it may
* be distributed with other software which is sold. If the
* software is distributed, the source code must be made available.
*
* No warranty, expressed or implied, is given with this software.
* It is presented in the hope that it will prove useful.
*
* Hacked in ignorance and desperation by jonah@db.toronto.edu
*/
/*
* The code to handle the \specials generated by tpic was modified
* by Dirk Grunwald using the code Tim Morgan at Univ. of Calif, Irvine
* wrote for TeXsun.
*/
#define COMLEN 3
void applicationDoSpecial(char *cp)
{
char command[COMLEN + 1];
char *q;
char *orig_cp;
orig_cp = cp;
while (ISSPACE(*cp)) ++cp;
q = command;
while (!ISSPACE(*cp) && *cp && q < command + COMLEN) *q++ = *cp++;
*q = '\0';
if (strcmp(command, "pn") == 0) set_pen_size(cp);
else if (strcmp(command, "fp") == 0) flush_path();
else if (strcmp(command, "da") == 0) flush_dashed(cp, False);
else if (strcmp(command, "dt") == 0) flush_dashed(cp, True);
else if (strcmp(command, "pa") == 0) add_path(cp);
else if (strcmp(command, "ar") == 0) arc(cp, False);
else if (strcmp(command, "ia") == 0) arc(cp, True);
else if (strcmp(command, "sp") == 0) flush_spline();
else if (strcmp(command, "sh") == 0) shade_last();
else if (strcmp(command, "wh") == 0) whiten_last();
else if (strcmp(command, "bk") == 0) blacken_last();
/* throw away the path -- jansteen */
else if (strcmp(command, "ip") == 0) path_len = 0;
else if (strcmp(command, "ps:") == 0) psfig_special(cp);
else if (strcmp(command, "PSf") == 0) epsf_special(cp);
else if (strcmp(command, "psf") == 0) epsf_special(cp);
else if (*orig_cp == '"') quote_special(orig_cp + 1);
else if (*orig_cp == '!') bang_special(orig_cp + 1);
else if (!hush_spec_now)
Fprintf(stderr, "%s: special \"%s\" not implemented\n", prog,
orig_cp);
QString special_command(cp);
if (special_command[0] == '"') {
quote_special(special_command.mid(1));
return;
}
kdError() << "special \"" << cp << "\" not implemented" << endl;
return;
}
void psp_destroy() { psp.destroy(); }

8
vf.cpp
View file

@ -61,7 +61,7 @@ extern font *define_font(FILE *file, unsigned int cmnd, font *vfparent, QIntDict
* The main routine
*/
void font::read_VF_index(unsigned int hushcs)
void font::read_VF_index(void)
{
kdDebug() << "read_VF_index" << endl;
@ -76,8 +76,10 @@ void font::read_VF_index(unsigned int hushcs)
// Read preamble.
Fseek(VF_file, (long) one(VF_file), 1); /* skip comment */
long file_checksum = four(VF_file);
if (!hushcs && file_checksum && checksum && file_checksum != checksum)
kdError() << "Checksum mismatch (dvi = " << checksum << "u, vf = " << file_checksum << "u) in font file " << filename << endl;
if (file_checksum && checksum && file_checksum != checksum)
kdError() << "Checksum mismatch (dvi = " << checksum << "u, vf = " << file_checksum <<
"u) in font file " << filename << endl;
(void) four(VF_file); /* skip design size */
// Read the fonts.

10
xdvi.h
View file

@ -218,10 +218,6 @@ extern unsigned int page_w, page_h;
*/
extern long *page_offset;
/*
* Mechanism for reducing repeated warning about specials, lost characters, etc.
*/
extern Boolean hush_spec_now;
extern QIntDict<struct font> tn_table;
@ -244,9 +240,6 @@ extern char *xoffset;
extern char *yoffset;
extern _Xconst char *_paper;
extern Boolean reverse;
extern Boolean _hush_spec;
extern Boolean _hush_chars;
extern Boolean _hush_chk;
extern char *fore_color;
extern char *back_color;
extern char *brdr_color;
@ -268,9 +261,6 @@ extern char *mg_arg[5];
#define density _density
#define pixels_per_inch _pixels_per_inch
#define hush_spec _hush_spec
#define hush_chars _hush_chars
#define hush_chk _hush_chk
extern Pixel brdr_Pixel;