diff --git a/TODO b/TODO index 0c9f19995..6200b4869 100644 --- a/TODO +++ b/TODO @@ -4,7 +4,6 @@ URGENT / URGENT BUGFIXING o add tip: kdvi can load compressed files! o get rid of useless README.kdvi -o "neue datei laden" geht nicht mehr o Proper handling of the base-url o add "tt.dvi.gz" to the list of recent files, not "/tmp/kviews....." @@ -17,7 +16,7 @@ o Support for colored font specials o Support papersize information given by the dvi-file on a page-by-page basis. -o Extra enlargement of characters for improved readability should be switchable. +o asynchronous rendering of pages, so that browsing with pg up/down looks faster NOT SO URGENT diff --git a/dvi_init.h b/dvi_init.h index 09ecc2663..542638b4c 100644 --- a/dvi_init.h +++ b/dvi_init.h @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "bigEndianByteReader.h" @@ -26,7 +27,7 @@ class dvifile : public bigEndianByteReader Q_UINT8 * dvi_Data; QIODevice::Offset size_of_file; QString errorMsg; - + /** This flag is set to "true" during the construction of the dvifile, and is never changed afterwards by the dvifile class. It is used in kdvi in conjuction with source-specials: @@ -34,7 +35,8 @@ class dvifile : public bigEndianByteReader shows an info dialog, and the flag is set to false. That way KDVI ensures that the user is only informed once. */ bool sourceSpecialMarker; - + + QIntDict tn_table; double cmPerDVIunit; diff --git a/dviwin.cpp b/dviwin.cpp index e4e551061..a511abe97 100644 --- a/dviwin.cpp +++ b/dviwin.cpp @@ -59,8 +59,6 @@ struct WindowRec currwin = {(Window) 0, 3, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0}; extern struct WindowRec alt; struct drawinf currinf; -QIntDict tn_table; - // The following are really used unsigned int page_w; unsigned int page_h; @@ -523,7 +521,7 @@ bool dviWindow::setFile(QString fname, QString ref, bool sourceMarker) command_pointer = end_pointer = 0; memset((char *) &currinf.data, 0, sizeof(currinf.data)); - currinf.fonttable = tn_table; + currinf.fonttable = dviFile->tn_table; currinf._virtual = NULL; draw_part(65536.0*fontPixelPerDVIunit(), false); diff --git a/dviwin_draw.cpp b/dviwin_draw.cpp index 214fd623a..39a2dfa7d 100644 --- a/dviwin_draw.cpp +++ b/dviwin_draw.cpp @@ -270,7 +270,7 @@ static void set_rule(int h, int w) } -#define xspell_conv(n) spell_conv0(n, current_dimconv) +#define xspell_conv(n) ((long) (n * current_dimconv)) void dviWindow::draw_part(double current_dimconv, bool is_vfmacro) { @@ -316,7 +316,7 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro) b = readUINT32(); b = xspell_conv(b); if (a > 0 && b > 0 && PostScriptOutPutString == NULL) - set_rule(pixel_round(xspell_conv(a)), pixel_round(b)); + set_rule( ((int) ROUNDUP(xspell_conv(a), shrink_factor * 65536)), ((int) ROUNDUP(b, shrink_factor * 65536)) ); DVI_H += b; break; @@ -330,7 +330,7 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro) a = xspell_conv(a); b = xspell_conv(b); if (a > 0 && b > 0 && PostScriptOutPutString == NULL) - set_rule(pixel_round(a), pixel_round(b)); + set_rule(((int) ROUNDUP(a, shrink_factor * 65536)), ((int) ROUNDUP(b, shrink_factor * 65536))); break; case NOP: @@ -594,7 +594,7 @@ void dviWindow::draw_page(void) command_pointer = end_pointer = 0; memset((char *) &currinf.data, 0, sizeof(currinf.data)); - currinf.fonttable = tn_table; + currinf.fonttable = dviFile->tn_table; currinf._virtual = 0; draw_part(65536.0*fontPixelPerDVIunit(), false); if (HTML_href != 0) { diff --git a/fontpool.cpp b/fontpool.cpp index b221f1511..883fe90dd 100644 --- a/fontpool.cpp +++ b/fontpool.cpp @@ -111,10 +111,10 @@ void fontPool::setEnlargeFonts( bool flag ) } -class font *fontPool::appendx(const char *fontname, long checksum, Q_INT32 scale, double enlargement, double cmPerDVIunit) +class font *fontPool::appendx(const char *fontname, Q_UINT32 checksum, Q_UINT32 scale, double enlargement, double cmPerDVIunit) { double fsize = enlargement * MFResolutions[getMetafontMode()]; - + // Reuse font if possible: check if a font with that name and // natural resolution is already in the fontpool, and use that, if // possible. @@ -128,12 +128,12 @@ class font *fontPool::appendx(const char *fontname, long checksum, Q_INT32 scale } fontp=fontList.next(); } - + // If font doesn't exist yet, we have to generate a new font. - + // Calculate the number of pixel per DVI unit double pixelPerDVIunit = cmPerDVIunit * MFResolutions[getMetafontMode()] / 2.54; - + fontp = new font(fontname, fsize, checksum, scale, pixelPerDVIunit, this, (enlargeFonts == true) ? shrinkFactor/1.1 : shrinkFactor, enlargement, cmPerDVIunit); if (fontp == 0) { @@ -141,7 +141,7 @@ class font *fontPool::appendx(const char *fontname, long checksum, Q_INT32 scale exit(0); } fontList.append(fontp); - + // Now start kpsewhich/MetaFont, etc. if necessary return fontp; } diff --git a/fontpool.h b/fontpool.h index 910d61304..8c3e843c0 100644 --- a/fontpool.h +++ b/fontpool.h @@ -85,7 +85,7 @@ Q_OBJECT will be called. Since this is done using a concurrently running process, there is no guarantee that the loading is already performed when the method returns. */ - class font *appendx(const char *fontname, long checksum, Q_INT32 scale, double enlargement, double cmPerDVIunit); + class font *appendx(const char *fontname, Q_UINT32 checksum, Q_UINT32 scale, double enlargement, double cmPerDVIunit); /** Prints very basic debugging information about the fonts in the pool to the kdDebug output stream. */ diff --git a/tips b/tips index b395e6e6b..399d4427a 100644 --- a/tips +++ b/tips @@ -1,3 +1,9 @@ + + +

...that KDVI can also load compressed DVI-files? + + +

...that you can mark text with the right mouse button and paste it diff --git a/vf.cpp b/vf.cpp index 7ff38f49c..af6be2176 100644 --- a/vf.cpp +++ b/vf.cpp @@ -89,26 +89,25 @@ void font::read_VF_index(void) first_font = NULL; while ((cmnd = one(VF_file)) >= FNTDEF1 && cmnd <= FNTDEF4) { int TeXnumber = num(VF_file, (int) cmnd - FNTDEF1 + 1); - long checksum = four(VF_file); - int scale = four(VF_file); - int design = four(VF_file); - int len = one(VF_file) + one(VF_file); /* sequence point in the middle */ - char *fontname = new char[(unsigned) len + 1]; + Q_UINT32 checksum = four(VF_file); + Q_UINT32 scale = four(VF_file); + Q_UINT32 design = four(VF_file); + Q_UINT16 len = one(VF_file) + one(VF_file); /* sequence point in the middle */ + char *fontname = new char[len + 1]; fread(fontname, sizeof(char), len, VF_file); fontname[len] = '\0'; - + #ifdef DEBUG_FONTS kdDebug() << "Virtual font defines subfont \"" << fontname << "\" scale=" << scale << " design=" << design << endl; #endif - // The scaled size is given in units of vfparent->scale * 2 ** -20 - // SPELL units, so we convert it into SPELL units by multiplying - // by vfparent->dimconv. The design size is given in units of 2 - // -20 pt, so we convert into SPELL units by multiplying by - // (pixels_per_inch * 2**16) / (72.27 * 2**20). - // @@@@@@@@@@@@@@ CHECK THAT @@@@@@@@@@@@@@@@@@@@@@@ THIS CALL OF appendx PROBABLY HAS A WRONG enlargement. ORIGINAL CODE WAS: - // struct font *newfontp = font_pool->appendx(fontname, checksum, scale, (72.27 * (1<<4)) * dimconv * scale / design, dimconv); - struct font *newfontp = font_pool->appendx(fontname, checksum, scale, enlargement, cmPerDVIunit); + // According to Knuth's documentation found in the web source code + // of the "vftovp" program (which seems to be the standard + // definition of virtual fonts), the "scale" is a fixed point + // number which describes extra enlargement that the virtual font + // imposes. One obtains the enlargement by dividing 2^20. + double enlargement_factor = double(scale)/(1<<20) * enlargement; + struct font *newfontp = font_pool->appendx(fontname, checksum, scale, enlargement_factor, cmPerDVIunit); // Insert font in dictionary and make sure the dictionary is big // enough. diff --git a/xdvi.h b/xdvi.h index a6041b1ba..235505a45 100644 --- a/xdvi.h +++ b/xdvi.h @@ -13,31 +13,11 @@ * PAGE_OFFSET in dvi_draw.c. */ -#define pixel_conv(x) ((int) ((x) / (shrink_factor * 65536))) -#define pixel_round(x) ((int) ROUNDUP(x, shrink_factor * 65536)) -#define spell_conv0(n, f) ((long) (n * f)) - -#ifdef BMBYTE -#define BMUNIT unsigned char -#define BITS_PER_BMUNIT 8 -#define BYTES_PER_BMUNIT 1 -#else /* !BMBYTE */ -#ifdef BMSHORT -#define BMUNIT unsigned short -#define BITS_PER_BMUNIT 16 -#define BYTES_PER_BMUNIT 2 -#else /* !BMSHORT */ -#define BMLONG -#ifdef __alpha -#define BMUNIT unsigned int -#else -#define BMUNIT unsigned long -#endif /* if __alpha */ +#define BMUNIT Q_UINT32 #define BITS_PER_BMUNIT 32 #define BYTES_PER_BMUNIT 4 -#endif /* !BMSHORT */ -#endif /* !BMBYTE */ + #define ADD(a, b) ((BMUNIT *) (((char *) a) + b)) #define SUB(a, b) ((BMUNIT *) (((char *) a) - b)) @@ -51,7 +31,7 @@ extern struct drawinf currinf; scaled pixel units */ #define DVI_H currinf.data.dvi_h -#define PXL_H pixel_conv(currinf.data.dvi_h) +#define PXL_H ((int) ((currinf.data.dvi_h) / (shrink_factor * 65536))) #define DVI_V currinf.data.dvi_v #define PXL_V currinf.data.pxl_v #define WW currinf.data.w @@ -60,13 +40,6 @@ extern struct drawinf currinf; #define ZZ currinf.data.z #define ROUNDUP(x,y) (((x)+(y)-1)/(y)) -extern QIntDict tn_table; - - -/* - * Command line flags. - */ - extern unsigned long num (FILE *, int); extern long snum(FILE *, int); extern struct WindowRec mane, currwin;