From 08d37ab642e8cb80774a87270fd6a3f9fab783fb Mon Sep 17 00:00:00 2001 From: Soeren Sandmann Date: Wed, 22 Dec 2004 16:04:45 +0000 Subject: Auto*ify dvi and dvi/dvilib Tue Dec 21 21:45:43 2004 Soeren Sandmann * Makefile.am: * dvi/dvilib/Makefile.am: * dvi/Makefile.am: * configure.ac: Auto*ify dvi and dvi/dvilib * dvi/Makefile: Remove from CVS * dvi/dvilib/dl-pkfont.cc (unpack_bitmap): Fix uchar/uint confusion. * dvi/dvilib/dl-fontdefinition.{cc,hh}: New DviFontMap class * dvi/dvilib/dl-vffont.{cc,hh}: Many bugfixes to VF code. --- diff --git a/ChangeLog b/ChangeLog index 432ad41..f241e06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Tue Dec 21 21:45:43 2004 Soeren Sandmann + + * Makefile.am: + * dvi/dvilib/Makefile.am: + * dvi/Makefile.am: + * configure.ac: Auto*ify dvi and dvi/dvilib + + * dvi/Makefile: Remove from CVS + + * dvi/dvilib/dl-pkfont.cc (unpack_bitmap): Fix uchar/uint + confusion. + + * dvi/dvilib/dl-fontdefinition.{cc,hh}: New DviFontMap class + + * dvi/dvilib/dl-vffont.{cc,hh}: Many bugfixes to VF code. + 2004-12-22 Marco Pesenti Gritti * ps/Makefile.am: diff --git a/Makefile.am b/Makefile.am index a0cddce..bc064af 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = cut-n-paste data backend po pdf ps shell +SUBDIRS = cut-n-paste data backend po pdf dvi ps shell intltool_extra = intltool-extract.in intltool-merge.in intltool-update.in diff --git a/configure.ac b/configure.ac index ab87408..bce7729 100644 --- a/configure.ac +++ b/configure.ac @@ -32,6 +32,7 @@ AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package.]) PKG_CHECK_MODULES(LIBEVPRIVATE, gtk+-2.0 >= 2.4.0) PKG_CHECK_MODULES(RECENT_FILES, gtk+-2.0 >= 2.4.0 libgnomeui-2.0 >= 2.4.0) PKG_CHECK_MODULES(SHELL, gtk+-2.0 >= 2.5.0 libgnomeui-2.0 gnome-vfs-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libglade-2.0) +PKG_CHECK_MODULES(DVI, gtk+-2.0 >= 2.6.0) PKG_CHECK_MODULES(GTK, gtk+-2.0 >= 2.6.0) PKG_CHECK_MODULES(PS, gtk+-2.0 >= 2.6.0 gnome-vfs-2.0 libgnomeui-2.0) @@ -373,4 +374,6 @@ ps/Makefile po/Makefile.in backend/Makefile shell/Makefile +dvi/Makefile +dvi/dvilib/Makefile ]) diff --git a/dvi/Makefile b/dvi/Makefile deleted file mode 100644 index 3ba3611..0000000 --- a/dvi/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -binary = dviviewer - -sources = \ - main.cc \ - \ - painter.cc \ - font.cc \ - view.cc \ - model.cc \ - \ - dvilib/dl-dvi-file.cc \ - dvilib/dl-dvi-fontdefinition.cc \ - dvilib/dl-dvi-parser.cc \ - dvilib/dl-dvi-program.cc \ - dvilib/dl-dvi-runtime.cc \ - dvilib/dl-loader.cc \ - dvilib/dl-pkfont.cc \ - dvilib/dl-vffont.cc - -headers = \ - painter.hh \ - font.hh \ - view.hh \ - model.hh \ - \ - dvilib/dl-dvi-file.hh \ - dvilib/dl-dvi-fontdefinition.hh \ - dvilib/dl-dvi-parser.hh \ - dvilib/dl-dvi-runtime.hh \ - dvilib/dl-font.hh \ - dvilib/dl-loader.hh \ - dvilib/dl-pkfont.hh \ - dvilib/dl-vffont.hh - -CFLAGS = -Idvilib -Wall -W -ansi -pedantic -g -O0 `pkg-config --cflags gtk+-2.0` - -$(binary): $(sources) $(headers) - c++ $(CFLAGS) $(sources) -o$(binary) -lfl `pkg-config --libs gtk+-2.0` diff --git a/dvi/dvilib/TODO b/dvi/dvilib/TODO index fb58cb3..dc86f1d 100644 --- a/dvi/dvilib/TODO +++ b/dvi/dvilib/TODO @@ -1,2 +1,8 @@ - Add a cache so we don't call kpsewhich for each font - possibly make cache persistent so we don't have to call kpsewhich on startup +- Why doesn't '6' get rendered in fest.dvi +- Get rid of exceptions +- Get rid of "blah (blah)" initializations +- Get rid of references +- Audit for memory leaks +- Move stuff out of header files diff --git a/dvi/dvilib/dl-dvi-file.cc b/dvi/dvilib/dl-dvi-file.cc index 1739be9..46a206e 100755 --- a/dvi/dvilib/dl-dvi-file.cc +++ b/dvi/dvilib/dl-dvi-file.cc @@ -43,7 +43,7 @@ DviFile::get_page (uint n) loader.goto_from_start (header->address + 45); program = parser.parse_program (); - page = new DviPage (*header, *program); + page = new DviPage (*program, header->count, postamble->fontmap); } return page; diff --git a/dvi/dvilib/dl-dvi-file.hh b/dvi/dvilib/dl-dvi-file.hh index d6c0201..bcc90aa 100755 --- a/dvi/dvilib/dl-dvi-file.hh +++ b/dvi/dvilib/dl-dvi-file.hh @@ -8,44 +8,50 @@ #include "dl-dvi-fontdefinition.hh" #include "dl-loader.hh" -namespace DviLib { +namespace DviLib +{ const uint N_PAGE_COUNTERS = 10; // \count0 ... \count9 - class DviPageHeader : public RefCounted { + class DviPageHeader : public RefCounted + { public: int count[N_PAGE_COUNTERS]; uint address; // address of this page, not the preceding }; - class DviPage : public AbstractDviProgram { + class DviPage : public AbstractDviProgram + { DviProgram& program; + DviFontMap *fontmap; int count[N_PAGE_COUNTERS]; // \count0 ... \count9 public: - DviPage (DviProgram& p, int c[N_PAGE_COUNTERS]) : + DviPage (DviProgram& p, int c[N_PAGE_COUNTERS], DviFontMap *fontmap) : program (p) { - for (uint i=0; ifontmap = fontmap; + this->fontmap->ref(); + for (uint i = 0; i < N_PAGE_COUNTERS; ++i) count[i] = c[i]; } - DviPage (DviPageHeader& h, DviProgram& p) : - program (p) - { - for (uint i=0; i fontdefinitions; + + DviFontMap *fontmap; }; - class DviFile : public RefCounted { + class DviFile : public RefCounted + { AbstractLoader &loader; DviFilePreamble *preamble; @@ -87,7 +96,7 @@ namespace DviLib { uint get_n_pages () { return n_pages; } DviFontdefinition *get_fontdefinition (uint n) { - return postamble->fontdefinitions[n]; + return postamble->fontmap->get_fontdefinition (n); } uint get_numerator () { return postamble->numerator; } uint get_denominator () { return postamble->denominator; } diff --git a/dvi/dvilib/dl-dvi-fontdefinition.cc b/dvi/dvilib/dl-dvi-fontdefinition.cc index 553ea28..6a4979b 100755 --- a/dvi/dvilib/dl-dvi-fontdefinition.cc +++ b/dvi/dvilib/dl-dvi-fontdefinition.cc @@ -1,3 +1,40 @@ #include "dl-dvi-fontdefinition.hh" +#include + using namespace DviLib; + +DviFontdefinition * +DviFontMap::get_fontdefinition (int fontnum) +{ + cout << "getting fontnum " << fontnum << endl; + return fontmap[fontnum]; +} + +void +DviFontMap::set_fontdefinition (int fontnum, + DviFontdefinition *fd) +{ + fd->ref(); + + + cout << "froot " << fontnum << (int)this << endl; + + if (fontmap[fontnum]) + { + cout << "blah" << endl; + fontmap[fontnum]->unref(); + } + + fontmap[fontnum] = fd; +} + +DviFontMap::~DviFontMap () +{ + typedef map ::iterator It; + + for (It i = fontmap.begin(); i != fontmap.end(); ++i) + { + (*i).second->unref(); + } +} diff --git a/dvi/dvilib/dl-dvi-fontdefinition.hh b/dvi/dvilib/dl-dvi-fontdefinition.hh index e6bb0d6..cc6bfd2 100755 --- a/dvi/dvilib/dl-dvi-fontdefinition.hh +++ b/dvi/dvilib/dl-dvi-fontdefinition.hh @@ -2,12 +2,14 @@ #define DL_FONT_DEFINITION_HH__ #include +#include #include "dl-refcounted.hh" namespace DviLib { - - class DviFontdefinition : public RefCounted { + + class DviFontdefinition : public RefCounted + { public: uint fontnum; uint checksum; @@ -18,5 +20,13 @@ namespace DviLib { string name; }; + class DviFontMap : public RefCounted + { + public: + std::map fontmap; + DviFontdefinition *get_fontdefinition (int fontnum); + void set_fontdefinition (int fontnum, DviFontdefinition *fd); + DviFontMap::~DviFontMap (); + }; } #endif // DL_FONT_DEFINITION_HH__ diff --git a/dvi/dvilib/dl-dvi-parser.cc b/dvi/dvilib/dl-dvi-parser.cc index 7caac02..e437261 100755 --- a/dvi/dvilib/dl-dvi-parser.cc +++ b/dvi/dvilib/dl-dvi-parser.cc @@ -358,7 +358,9 @@ DviParser::parse_program (uint n_bytes) cmd = parse_command (loader, &count, &opcode); if (cmd) { +#if 0 cout << opcode << endl; +#endif program->add_command (cmd); cmd->unref(); } @@ -420,12 +422,14 @@ DviParser::parse_fontdefinition (void) fontdef->directory = ""; fontdef->name = ""; - for (uint i=0; idirectory += loader.get_uint8(); - for (uint i=0; iname += loader.get_uint8(); +#if 0 cout << "parsed fd: " << fontdef->name << " " << fontdef->fontnum << endl; +#endif return fontdef; } @@ -462,6 +466,8 @@ DviFilePostamble * DviParser::parse_postamble (void) { DviFilePostamble *postamble = new DviFilePostamble; + + postamble->fontmap = new DviFontMap; loader.goto_from_end (-5); @@ -497,9 +503,9 @@ DviParser::parse_postamble (void) loader.goto_from_current (-1); DviFontdefinition *fd = parse_fontdefinition (); - postamble->fontdefinitions[fd->fontnum] = fd; + postamble->fontmap->set_fontdefinition (fd->fontnum, fd); cout << fd->name << endl; - cout << postamble->fontdefinitions[fd->fontnum]->name; + cout << postamble->fontmap->get_fontdefinition(fd->fontnum)->name; } else { @@ -515,6 +521,8 @@ DviParser::parse_vf_font_preamble (void) { DviOpcode c; VfFontPreamble *preamble = new VfFontPreamble; + + preamble->fontmap = new DviFontMap; c = (DviOpcode)loader.get_uint8 (); if (c != DVI_PRE) @@ -527,6 +535,7 @@ DviParser::parse_vf_font_preamble (void) preamble->checksum = loader.get_uint32 (); preamble->design_size = loader.get_uint32 (); + int i = 0; while (true) { DviOpcode c = (DviOpcode)loader.get_uint8 (); @@ -536,7 +545,7 @@ DviParser::parse_vf_font_preamble (void) loader.goto_from_current (-1); DviFontdefinition *fd = parse_fontdefinition (); - preamble->fontdefinitions.push_back (fd); + preamble->fontmap->set_fontdefinition (i++, fd); } else { diff --git a/dvi/dvilib/dl-dvi-program.hh b/dvi/dvilib/dl-dvi-program.hh index afe5fdb..1424b0a 100755 --- a/dvi/dvilib/dl-dvi-program.hh +++ b/dvi/dvilib/dl-dvi-program.hh @@ -77,7 +77,9 @@ namespace DviLib public: DviRuleCommand (int h_arg, int w_arg) : h(h_arg), w(w_arg) { +#if 0 std::cout << "rule cmd " << h << " " << w << std::endl; +#endif } int get_h (void) const { return h; } int get_w (void) const { return w; } diff --git a/dvi/dvilib/dl-dvi-runtime.hh b/dvi/dvilib/dl-dvi-runtime.hh index abb8c71..ff9df5e 100755 --- a/dvi/dvilib/dl-dvi-runtime.hh +++ b/dvi/dvilib/dl-dvi-runtime.hh @@ -28,7 +28,7 @@ namespace DviLib { virtual void y_rep () = 0; // move down y virtual void z (int len) = 0; // move down len, set z = len virtual void z_rep () = 0; // move down z - virtual void push_fontmap (std::map fontmap) = 0; + virtual void fontmap (DviFontMap *fontmap) = 0; // set fontmap virtual void font_num (int num) = 0; // f = num virtual void special (std::string spc) = 0; // do something special diff --git a/dvi/dvilib/dl-pkfont.cc b/dvi/dvilib/dl-pkfont.cc index 2544e35..409d531 100755 --- a/dvi/dvilib/dl-pkfont.cc +++ b/dvi/dvilib/dl-pkfont.cc @@ -189,21 +189,31 @@ PkChar::unpack_bitmap (void) { uint i, weight; - uchar *bitmap - = new uchar [4 * width * height]; - fill (bitmap, bitmap + 4 * width * height, 0xFF); + uint *bitmap + = new uint [width * height]; + fill (bitmap, bitmap + width * height, 0x00000000); weight = 128; - for (i=0; i < height * width; i+=4) + for (i=0; i < height * width; i++) { if ((*data.packed & weight) != 0) - bitmap[i] = bitmap[i+1] = - bitmap[i+2] = bitmap[i+3] = 0x00; - weight = (weight == 1)? - (data.packed++, 128) : weight >> 1; + { + bitmap[i] = 0xff000000; + } + + if (weight == 1) + { + weight = 128; + data.packed++; + } + else + { + weight >>= 1; + } } - data.bitmap = bitmap; + + data.bitmap = (uchar *)bitmap; } void @@ -213,7 +223,9 @@ PkChar::unpack (void) return; if (dyn_f == 14) + { unpack_bitmap(); + } else { Bitmap bitmap (width, height); @@ -222,9 +234,17 @@ PkChar::unpack (void) first_is_black? BLACK : WHITE, bitmap); unpack_rle (nr); - unpacked = true; data.bitmap = bitmap.steal_pixels (); + +#if 0 + if (character_code == '6') + cout << "HERER" << endl; + else + cout << '[' << character_code << " not " << (int)'6' << ']' << endl; +#endif } + + unpacked = true; } PkChar::PkChar (AbstractLoader &loader) @@ -257,9 +277,13 @@ PkChar::PkChar (AbstractLoader &loader) case 4: case 5: case 6: /* extended short preamble */ length = loader.get_uint16 () + ((flag_byte & 3) << 16) - 13; +#if 0 cout << length; +#endif character_code = loader.get_uint8 (); +#if 0 cout << ',' << character_code; +#endif tfm_width = loader.get_uint24 (); dx = loader.get_uint16 () << 16; dy = 0; diff --git a/dvi/dvilib/dl-pkfont.hh b/dvi/dvilib/dl-pkfont.hh index 66cd69b..ec09148 100755 --- a/dvi/dvilib/dl-pkfont.hh +++ b/dvi/dvilib/dl-pkfont.hh @@ -17,7 +17,8 @@ namespace DviLib { REPEAT_COUNT }; - class PkChar : public AbstractCharacter { + class PkChar : public AbstractCharacter + { uint dyn_f; bool first_is_black; // if first run count is black or white int character_code; @@ -39,6 +40,7 @@ namespace DviLib { void unpack_rle (RleContext& nr); void unpack_bitmap (void); void unpack (void); + public: PkChar (AbstractLoader &l); virtual void paint (DviRuntime &runtime); diff --git a/dvi/dvilib/dl-vffont.cc b/dvi/dvilib/dl-vffont.cc index 91109d8..36d570f 100755 --- a/dvi/dvilib/dl-vffont.cc +++ b/dvi/dvilib/dl-vffont.cc @@ -3,14 +3,39 @@ using namespace DviLib; -VfFont::VfFont (AbstractLoader &l, int at_size_arg) : - at_size (at_size_arg) +void +VfFont::fixup_fontmap (DviFontMap *fontmap) { - DviParser parser (l); - preamble = parser.parse_vf_font_preamble (); + typedef std::map::iterator It; + for (It i = fontmap->fontmap.begin(); i != fontmap->fontmap.end(); ++i) + { + (*i).second->at_size = ((*i).second->at_size / 1048576.0) * preamble->design_size; +#if 0 + (*i).second->design_size = 1048576; +#endif + } +} +VfFont::VfFont (AbstractLoader &l, + int at_size_arg) +{ + at_size = at_size_arg; + DviParser parser (l); + preamble = parser.parse_vf_font_preamble(); + VfChar *ch; - while ((ch = parser.parse_vf_char ()) != NULL) + while ((ch = parser.parse_vf_char()) != NULL) + { chars[ch->character_code] = ch; + ch->fontmap = preamble->fontmap; + } + + /* fixup fontmap + * + * FIXME: I don't think this is correct, but vftovp.web isn't + * totally clear on the issue + */ + + fixup_fontmap (preamble->fontmap); } diff --git a/dvi/dvilib/dl-vffont.hh b/dvi/dvilib/dl-vffont.hh index 185e4a9..fff490b 100755 --- a/dvi/dvilib/dl-vffont.hh +++ b/dvi/dvilib/dl-vffont.hh @@ -7,33 +7,41 @@ namespace DviLib { - class VfChar : public AbstractCharacter { + class VfChar : public AbstractCharacter + { public: int tfm_width; DviProgram *program; + DviFontMap *fontmap; int character_code; virtual void paint (DviRuntime& runtime) { runtime.push(); + runtime.fontmap (fontmap); + runtime.font_num (0); + cout << "vfchar (" << (int)fontmap << ')' << " " << character_code << endl; program->execute (runtime); // FIXME push, pop, etc. runtime.pop(); } virtual int get_tfm_width () { return tfm_width; } }; - class VfFontPreamble : public RefCounted { + class VfFontPreamble : public RefCounted + { public: string comment; uint checksum; uint design_size; - vector fontdefinitions; + DviFontMap *fontmap; }; - class VfFont : public AbstractFont { + class VfFont : public AbstractFont + { VfFontPreamble *preamble; map chars; int at_size; + void fixup_fontmap (DviFontMap *fontmap); public: VfFont (AbstractLoader& l, int at_size); virtual VfChar *get_char (int ccode) @@ -46,7 +54,6 @@ namespace DviLib { } virtual int get_at_size () { - /* FIXME (what is the correct thing to do here?) */ return at_size; } virtual ~VfFont () {} diff --git a/dvi/fest.tex b/dvi/fest.tex index 1ae5083..92d41bd 100644 --- a/dvi/fest.tex +++ b/dvi/fest.tex @@ -1,10 +1,13 @@ \documentclass[a4paper, danish]{article} -\usepackage{times} -\usepackage[T1]{fontenc} +\usepackage{charter} +%\usepackage[T1]{fontenc} \usepackage{babel} \begin{document} +Hej verden + +%\end{document} \section{Title} @@ -14,7 +17,12 @@ \subsection {Subtitle} -Math: $\sum_{i=0}^\infty \frac{1}{i^2} = \frac{\pi^2}{6}$ +Math: $6\sum_{i=0}^\infty \frac{1}{i^2} = \frac{\pi^2}{666i}$ + +abcdefghijklmnopqrstuvwxyz + +ABCDEFGHIJKLMNOPQRSTUVWXYZ + {\large\bf Big, bold\par} diff --git a/dvi/font.cc b/dvi/font.cc index 512370e..4494b52 100755 --- a/dvi/font.cc +++ b/dvi/font.cc @@ -120,6 +120,8 @@ run_mktexpk (int dpi, string name) char *namestr = g_strdup (name.c_str()); char *result; + cout << "mktexpk " << bdpistr << " " << dpistr << " " << " " << namestr << " " << endl; + result = run_program ("mktexpk", NULL, bdpistr, dpistr, namestr, NULL); if (result) g_free (result); @@ -136,6 +138,8 @@ FontFactory::create_font (std::string name, { char *filename; + cout << "at size: " << at_size << endl; + /* Find VF */ filename = run_kpsewhich (dpi, "vf", name); diff --git a/dvi/painter.cc b/dvi/painter.cc index a1bb758..2dc57e2 100755 --- a/dvi/painter.cc +++ b/dvi/painter.cc @@ -2,6 +2,7 @@ #include "dl-dvi-fontdefinition.hh" using DviLib::DviFontdefinition; +using DviLib::DviFontMap; using DviLib::AbstractCharacter; // paint a bitmap @@ -41,13 +42,11 @@ DviPainter::paint_bitmap (const unsigned char *data, void DviPainter::set_char (int ch) { - g_assert (current_font); - - AbstractCharacter *character = current_font->get_char (ch); + AbstractCharacter *character = current_frame->font->get_char (ch); character->paint (* this); int tfm_width = character->get_tfm_width (); - int at_size = current_font->get_at_size (); + int at_size = current_frame->font->get_at_size (); int dvi_width = tfm_to_dvi (tfm_width, at_size); current_frame->h += dvi_width; @@ -57,7 +56,7 @@ DviPainter::set_char (int ch) void DviPainter::put_char (int ch) { - AbstractCharacter *character = current_font->get_char (ch); + AbstractCharacter *character = current_frame->font->get_char (ch); character->paint (* this); } @@ -71,7 +70,9 @@ DviPainter::set_rule (int height, int x = dvi_to_pixels (current_frame->h); int y = dvi_to_pixels (current_frame->v); +#if 0 cout << "BIRNAN\n" << endl; +#endif gdk_draw_rectangle (pixmap, gc, TRUE, x, y, @@ -108,22 +109,40 @@ DviFrame::copy (void) { DviFrame *frame = new DviFrame (); + frame->fontmap = this->fontmap; + if (frame->fontmap) + frame->fontmap->ref(); frame->h = this->h; frame->v = this->v; frame->w = this->w; frame->x = this->x; frame->y = this->y; frame->z = this->z; - + frame->font = this->font; + if (frame->font) + frame->font->ref(); + return frame; } +DviFrame::~DviFrame() +{ + if (this->fontmap) + this->fontmap->unref(); + if (this->font) + this->font->unref(); +} + void DviPainter::push (void) { DviFrame *new_frame = current_frame->copy(); new_frame->next = current_frame; current_frame = new_frame; + if (current_frame->font) + cout << "push: there is a font" << endl; + else + cout << "push: there is not a font" << endl; } // pop ccontext @@ -132,8 +151,18 @@ DviPainter::pop (void) { DviFrame *old_frame = current_frame; + // FIXME: dvi assumes that fonts survive pops + // FIXME: however, do they also survive the final pop of a vfchar? + current_frame = current_frame->next; + if (current_frame && current_frame->font) + cout << "pop: there is a font" << endl; + else if (current_frame) + cout << "pop: there is not font" << endl; + else + cout << "no current" << endl; + old_frame->unref(); } @@ -215,9 +244,8 @@ DviPainter::z_rep () void DviPainter::font_num (int font_num) { - cout << "get fno " << font_num << endl; - DviFontdefinition *fd = dvi_file->get_fontdefinition (font_num); - + DviFontdefinition *fd = current_frame->fontmap->get_fontdefinition (font_num); + g_assert (fd); if (fd) { @@ -225,10 +253,18 @@ DviPainter::font_num (int font_num) int dpi = (int)floor( 0.5 + 1.0 * base_dpi * dvi_file->get_magnification() * fd->at_size / ( 1000.0 * fd->design_size)); - cout << "fno: " << fd->fontnum << endl; - cout << fd->name << endl; - current_font = + + cout << fd->name << " design size: " << fd->design_size << " at size " << fd->at_size << endl; + + if (current_frame->font) + current_frame->font->unref(); + + current_frame->font = font_factory->create_font (fd->name, dpi, fd->at_size); + + g_assert (current_frame->font); + cout << "there is now a font"<< endl; + } } @@ -302,8 +338,6 @@ DviPainter::DviPainter (GdkPixmap *pixmap_arg, dvi_file->ref(); font_factory->ref(); - current_font = 0; - current_frame = new DviFrame; current_frame->h = 0; current_frame->v = 0; @@ -311,6 +345,8 @@ DviPainter::DviPainter (GdkPixmap *pixmap_arg, current_frame->x = 0; current_frame->y = 0; current_frame->z = 0; + current_frame->fontmap = NULL; + current_frame->font = NULL; // from gtkdvi: scale = dvi_file->get_numerator() / 254000.0; @@ -329,6 +365,12 @@ DviPainter::~DviPainter () } void -DviPainter::push_fontmap (std::map fontmap) +DviPainter::fontmap (DviFontMap *fontmap) { + fontmap->ref(); + + if (current_frame->fontmap) + current_frame->fontmap->unref(); + + current_frame->fontmap = fontmap; } diff --git a/dvi/painter.hh b/dvi/painter.hh index cbb968b..4d6fdda 100755 --- a/dvi/painter.hh +++ b/dvi/painter.hh @@ -23,9 +23,12 @@ public: class DviFrame : public DviLib::RefCounted { public: + DviLib::DviFontMap *fontmap; int h, v, w, x, y, z; // in dvi units DviFrame *next; DviFrame *copy (); + DviLib::AbstractFont *font; + ~DviFrame(); }; class DviPainter : public AbstractDviPainter @@ -49,7 +52,7 @@ public: virtual void y_rep (); // move down y virtual void z (int len); // move down len, set z = len virtual void z_rep (); // move down z - virtual void push_fontmap (std::map fontmap); + virtual void fontmap (DviLib::DviFontMap *fontmap); // set fontmap virtual void font_num (int font_num); // current_font = fd virtual void special (string spc); // do something special virtual void paint_bitmap (const unsigned char *data, @@ -65,7 +68,6 @@ private: AbstractFontFactory *font_factory; // runtime - DviLib::AbstractFont *current_font; DviFrame *current_frame; // stack of DVI frames double scale; // convert dvi units to pixels -- cgit v0.9.1