Tue Dec 21 21:45:43 2004 Soeren Sandmann <sandmann@redhat.com>
* 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.
20 files changed:
+Tue Dec 21 21:45:43 2004 Soeren Sandmann <sandmann@redhat.com>
+
+ * 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 <marco@gnome.org>
* ps/Makefile.am:
2004-12-22 Marco Pesenti Gritti <marco@gnome.org>
* ps/Makefile.am:
-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
intltool_extra = intltool-extract.in intltool-merge.in intltool-update.in
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(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)
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)
po/Makefile.in
backend/Makefile
shell/Makefile
po/Makefile.in
backend/Makefile
shell/Makefile
+dvi/Makefile
+dvi/dvilib/Makefile
+++ /dev/null
-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`
- 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
- 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
loader.goto_from_start (header->address + 45);
program = parser.parse_program ();
loader.goto_from_start (header->address + 45);
program = parser.parse_program ();
- page = new DviPage (*header, *program);
+ page = new DviPage (*program, header->count, postamble->fontmap);
#include "dl-dvi-fontdefinition.hh"
#include "dl-loader.hh"
#include "dl-dvi-fontdefinition.hh"
#include "dl-loader.hh"
const uint N_PAGE_COUNTERS = 10; // \count0 ... \count9
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
};
public:
int count[N_PAGE_COUNTERS];
uint address; // address of this page, not the preceding
};
- class DviPage : public AbstractDviProgram {
+ class DviPage : public AbstractDviProgram
+ {
int count[N_PAGE_COUNTERS]; // \count0 ... \count9
public:
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) :
- for (uint i=0; i<N_PAGE_COUNTERS; ++i)
+ this->fontmap = fontmap;
+ this->fontmap->ref();
+ for (uint i = 0; i < N_PAGE_COUNTERS; ++i)
- DviPage (DviPageHeader& h, DviProgram& p) :
- program (p)
- {
- for (uint i=0; i<N_PAGE_COUNTERS; ++i)
- count[i] = h.count[i];
- }
virtual void execute (DviRuntime& runtime)
{
virtual void execute (DviRuntime& runtime)
{
+ runtime.push();
+ runtime.fontmap (fontmap);
+ cout << "page " << (int)fontmap << endl;
program.execute (runtime);
program.execute (runtime);
}
int get_page_count (int i) { return count[i]; }
};
}
int get_page_count (int i) { return count[i]; }
};
NORMAL_DVI = 2, // FIXME: this should be 2
TEX_XET_DVI = 2 // FIXME: is this correct?
};
NORMAL_DVI = 2, // FIXME: this should be 2
TEX_XET_DVI = 2 // FIXME: is this correct?
};
- class DviFilePreamble : public RefCounted {
+ class DviFilePreamble : public RefCounted
+ {
public:
// preamble
DviType type;
public:
// preamble
DviType type;
- class DviFilePostamble : public RefCounted {
+ class DviFilePostamble : public RefCounted
+ {
public:
// postamble
DviType type;
public:
// postamble
DviType type;
uint max_height;
uint max_width;
uint stack_height;
uint max_height;
uint max_width;
uint stack_height;
- map <uint, DviFontdefinition *> fontdefinitions;
- class DviFile : public RefCounted {
+ class DviFile : public RefCounted
+ {
AbstractLoader &loader;
DviFilePreamble *preamble;
AbstractLoader &loader;
DviFilePreamble *preamble;
uint get_n_pages () { return n_pages; }
DviFontdefinition *get_fontdefinition (uint n)
{
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; }
}
uint get_numerator () { return postamble->numerator; }
uint get_denominator () { return postamble->denominator; }
#include "dl-dvi-fontdefinition.hh"
#include "dl-dvi-fontdefinition.hh"
+
+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 <int, DviFontdefinition *>::iterator It;
+
+ for (It i = fontmap.begin(); i != fontmap.end(); ++i)
+ {
+ (*i).second->unref();
+ }
+}
#define DL_FONT_DEFINITION_HH__
#include <string>
#define DL_FONT_DEFINITION_HH__
#include <string>
#include "dl-refcounted.hh"
namespace DviLib {
#include "dl-refcounted.hh"
namespace DviLib {
-
- class DviFontdefinition : public RefCounted {
+
+ class DviFontdefinition : public RefCounted
+ {
public:
uint fontnum;
uint checksum;
public:
uint fontnum;
uint checksum;
+ class DviFontMap : public RefCounted
+ {
+ public:
+ std::map <int, DviFontdefinition *> fontmap;
+ DviFontdefinition *get_fontdefinition (int fontnum);
+ void set_fontdefinition (int fontnum, DviFontdefinition *fd);
+ DviFontMap::~DviFontMap ();
+ };
}
#endif // DL_FONT_DEFINITION_HH__
}
#endif // DL_FONT_DEFINITION_HH__
cmd = parse_command (loader, &count, &opcode);
if (cmd)
{
cmd = parse_command (loader, &count, &opcode);
if (cmd)
{
program->add_command (cmd);
cmd->unref();
}
program->add_command (cmd);
cmd->unref();
}
fontdef->directory = "";
fontdef->name = "";
fontdef->directory = "";
fontdef->name = "";
- for (uint i=0; i<dirlength; ++i)
+ for (uint i=0; i < dirlength; ++i)
fontdef->directory += loader.get_uint8();
fontdef->directory += loader.get_uint8();
- for (uint i=0; i<namelength; ++i)
+ for (uint i=0; i < namelength; ++i)
fontdef->name += loader.get_uint8();
fontdef->name += loader.get_uint8();
cout << "parsed fd: " << fontdef->name << " " << fontdef->fontnum << endl;
cout << "parsed fd: " << fontdef->name << " " << fontdef->fontnum << endl;
DviParser::parse_postamble (void)
{
DviFilePostamble *postamble = new DviFilePostamble;
DviParser::parse_postamble (void)
{
DviFilePostamble *postamble = new DviFilePostamble;
+
+ postamble->fontmap = new DviFontMap;
loader.goto_from_end (-5);
loader.goto_from_end (-5);
loader.goto_from_current (-1);
DviFontdefinition *fd = parse_fontdefinition ();
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 << fd->name << endl;
- cout << postamble->fontdefinitions[fd->fontnum]->name;
+ cout << postamble->fontmap->get_fontdefinition(fd->fontnum)->name;
{
DviOpcode c;
VfFontPreamble *preamble = new VfFontPreamble;
{
DviOpcode c;
VfFontPreamble *preamble = new VfFontPreamble;
+
+ preamble->fontmap = new DviFontMap;
c = (DviOpcode)loader.get_uint8 ();
if (c != DVI_PRE)
c = (DviOpcode)loader.get_uint8 ();
if (c != DVI_PRE)
preamble->checksum = loader.get_uint32 ();
preamble->design_size = loader.get_uint32 ();
preamble->checksum = loader.get_uint32 ();
preamble->design_size = loader.get_uint32 ();
while (true)
{
DviOpcode c = (DviOpcode)loader.get_uint8 ();
while (true)
{
DviOpcode c = (DviOpcode)loader.get_uint8 ();
loader.goto_from_current (-1);
DviFontdefinition *fd = parse_fontdefinition ();
loader.goto_from_current (-1);
DviFontdefinition *fd = parse_fontdefinition ();
- preamble->fontdefinitions.push_back (fd);
+ preamble->fontmap->set_fontdefinition (i++, fd);
public:
DviRuleCommand (int h_arg, int w_arg) : h(h_arg), w(w_arg)
{
public:
DviRuleCommand (int h_arg, int w_arg) : h(h_arg), w(w_arg)
{
std::cout << "rule cmd " << h << " " << w << std::endl;
std::cout << "rule cmd " << h << " " << w << std::endl;
}
int get_h (void) const { return h; }
int get_w (void) const { return w; }
}
int get_h (void) const { return h; }
int get_w (void) const { return w; }
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 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<int, DviFontdefinition *> 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
virtual void font_num (int num) = 0; // f = num
virtual void special (std::string spc) = 0; // do something special
- 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);
- for (i=0; i < height * width; i+=4)
+ for (i=0; i < height * width; i++)
{
if ((*data.packed & weight) != 0)
{
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 = (uchar *)bitmap;
else
{
Bitmap bitmap (width, height);
else
{
Bitmap bitmap (width, height);
first_is_black? BLACK : WHITE,
bitmap);
unpack_rle (nr);
first_is_black? BLACK : WHITE,
bitmap);
unpack_rle (nr);
data.bitmap = bitmap.steal_pixels ();
data.bitmap = bitmap.steal_pixels ();
+
+#if 0
+ if (character_code == '6')
+ cout << "HERER" << endl;
+ else
+ cout << '[' << character_code << " not " << (int)'6' << ']' << endl;
+#endif
}
PkChar::PkChar (AbstractLoader &loader)
}
PkChar::PkChar (AbstractLoader &loader)
case 4: case 5: case 6:
/* extended short preamble */
length = loader.get_uint16 () + ((flag_byte & 3) << 16) - 13;
case 4: case 5: case 6:
/* extended short preamble */
length = loader.get_uint16 () + ((flag_byte & 3) << 16) - 13;
character_code = loader.get_uint8 ();
character_code = loader.get_uint8 ();
cout << ',' << character_code;
cout << ',' << character_code;
tfm_width = loader.get_uint24 ();
dx = loader.get_uint16 () << 16;
dy = 0;
tfm_width = loader.get_uint24 ();
dx = loader.get_uint16 () << 16;
dy = 0;
- 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;
uint dyn_f;
bool first_is_black; // if first run count is black or white
int character_code;
void unpack_rle (RleContext& nr);
void unpack_bitmap (void);
void unpack (void);
void unpack_rle (RleContext& nr);
void unpack_bitmap (void);
void unpack (void);
public:
PkChar (AbstractLoader &l);
virtual void paint (DviRuntime &runtime);
public:
PkChar (AbstractLoader &l);
virtual void paint (DviRuntime &runtime);
-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<int, DviFontdefinition *>::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();
+
- while ((ch = parser.parse_vf_char ()) != NULL)
+ while ((ch = parser.parse_vf_char()) != NULL)
+ {
chars[ch->character_code] = ch;
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);
- class VfChar : public AbstractCharacter {
+ class VfChar : public AbstractCharacter
+ {
public:
int tfm_width;
DviProgram *program;
public:
int tfm_width;
DviProgram *program;
int character_code;
virtual void paint (DviRuntime& runtime)
{
runtime.push();
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; }
};
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;
public:
string comment;
uint checksum;
uint design_size;
- vector <DviFontdefinition *> fontdefinitions;
- class VfFont : public AbstractFont {
+ class VfFont : public AbstractFont
+ {
VfFontPreamble *preamble;
map <int, VfChar *> chars;
int at_size;
VfFontPreamble *preamble;
map <int, VfChar *> chars;
int at_size;
+ void fixup_fontmap (DviFontMap *fontmap);
public:
VfFont (AbstractLoader& l, int at_size);
virtual VfChar *get_char (int ccode)
public:
VfFont (AbstractLoader& l, int at_size);
virtual VfChar *get_char (int ccode)
}
virtual int get_at_size ()
{
}
virtual int get_at_size ()
{
- /* FIXME (what is the correct thing to do here?) */
return at_size;
}
virtual ~VfFont () {}
return at_size;
}
virtual ~VfFont () {}
\documentclass[a4paper, danish]{article}
\documentclass[a4paper, danish]{article}
-\usepackage{times}
-\usepackage[T1]{fontenc}
+\usepackage{charter}
+%\usepackage[T1]{fontenc}
\usepackage{babel}
\begin{document}
\usepackage{babel}
\begin{document}
+Hej verden
+
+%\end{document}
-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}
{\large\bf Big, bold\par}
char *namestr = g_strdup (name.c_str());
char *result;
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);
result = run_program ("mktexpk", NULL, bdpistr, dpistr, namestr, NULL);
if (result)
g_free (result);
+ cout << "at size: " << at_size << endl;
+
/* Find VF */
filename = run_kpsewhich (dpi, "vf", name);
/* Find VF */
filename = run_kpsewhich (dpi, "vf", name);
#include "dl-dvi-fontdefinition.hh"
using DviLib::DviFontdefinition;
#include "dl-dvi-fontdefinition.hh"
using DviLib::DviFontdefinition;
+using DviLib::DviFontMap;
using DviLib::AbstractCharacter;
// paint a bitmap
using DviLib::AbstractCharacter;
// paint a bitmap
void
DviPainter::set_char (int ch)
{
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 ();
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;
int dvi_width = tfm_to_dvi (tfm_width, at_size);
current_frame->h += dvi_width;
void
DviPainter::put_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);
}
character->paint (* this);
}
int x = dvi_to_pixels (current_frame->h);
int y = dvi_to_pixels (current_frame->v);
int x = dvi_to_pixels (current_frame->h);
int y = dvi_to_pixels (current_frame->v);
cout << "BIRNAN\n" << endl;
cout << "BIRNAN\n" << endl;
gdk_draw_rectangle (pixmap, gc, TRUE,
x, y,
gdk_draw_rectangle (pixmap, gc, TRUE,
x, y,
{
DviFrame *frame = new DviFrame ();
{
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->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();
+
+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;
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;
{
DviFrame *old_frame = current_frame;
{
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;
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;
+
void
DviPainter::font_num (int font_num)
{
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);
+
int dpi = (int)floor( 0.5 + 1.0 * base_dpi *
dvi_file->get_magnification() * fd->at_size /
( 1000.0 * fd->design_size));
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);
font_factory->create_font (fd->name, dpi, fd->at_size);
+
+ g_assert (current_frame->font);
+ cout << "there is now a font"<< endl;
+
dvi_file->ref();
font_factory->ref();
dvi_file->ref();
font_factory->ref();
current_frame = new DviFrame;
current_frame->h = 0;
current_frame->v = 0;
current_frame = new DviFrame;
current_frame->h = 0;
current_frame->v = 0;
current_frame->x = 0;
current_frame->y = 0;
current_frame->z = 0;
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;
// from gtkdvi:
scale = dvi_file->get_numerator() / 254000.0;
-DviPainter::push_fontmap (std::map<int, DviFontdefinition *> fontmap)
+DviPainter::fontmap (DviFontMap *fontmap)
+ fontmap->ref();
+
+ if (current_frame->fontmap)
+ current_frame->fontmap->unref();
+
+ current_frame->fontmap = fontmap;
class DviFrame : public DviLib::RefCounted
{
public:
class DviFrame : public DviLib::RefCounted
{
public:
+ DviLib::DviFontMap *fontmap;
int h, v, w, x, y, z; // in dvi units
DviFrame *next;
DviFrame *copy ();
int h, v, w, x, y, z; // in dvi units
DviFrame *next;
DviFrame *copy ();
+ DviLib::AbstractFont *font;
+ ~DviFrame();
};
class DviPainter : public AbstractDviPainter
};
class DviPainter : public AbstractDviPainter
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 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<int, DviLib::DviFontdefinition *> 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,
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,
AbstractFontFactory *font_factory;
// runtime
AbstractFontFactory *font_factory;
// runtime
- DviLib::AbstractFont *current_font;
DviFrame *current_frame; // stack of DVI frames
double scale; // convert dvi units to pixels
DviFrame *current_frame; // stack of DVI frames
double scale; // convert dvi units to pixels