summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorwl <wl>2006-02-23 20:00:46 +0000
committerwl <wl>2006-02-23 20:00:46 +0000
commita9494c447c55365041c9288b9977b41fecc4bc24 (patch)
treeda81ff2a9e417631d5f106a94453bd0cbaa6bb5a /src
parentb600b460cebebf32e2f1de09823ab94600e65d37 (diff)
downloadgroff-a9494c447c55365041c9288b9977b41fecc4bc24.tar.gz
Concretize the glyph datatype.
* src/include/font.h (struct glyph): Remove class. (struct glyph): Renamed from struct glyphinfo. (glyph_to_index): New inline function. (glyph_to_name): Make extern, not inline. (glyph_to_number): Update. (font): Use `glyph *' instead of `glyph'. * src/libs/libgroff/nametoindex.cpp (charinfo): Inherit from class `glyph'. Make `name' field public. (character_indexer, number_to_glyph, name_to_glyph): Use `glyph *' instead of `glyph'. (glyph_to_name): Renamed from `glyph::glyph_name'. * src/roff/troff/charinfo.h (charinfo): Inherit from class `glyph'. Use `glyph *' instead of `glyph'. * src/roff/troff/input.cpp (name_to_glyph, number_to_glyph): Use `glyph *' instead of `glyph'. (glyph_to_name): Renamed from `glyph::glyph_name'. * src/libs/libgroff/font.cpp: Use `glyph *' instead of `glyph', and `glyph_to_index' instead of `glyph::glyph_index'. * src/include/printer.h (printer): Use `glyph *' instead of `glyph'. * src/libs/libdriver/printer.cpp: Likewise. * src/devices/grodvi/dvi.cpp: Likewise. * src/devices/grohtml/post-html.cpp: Likewise. * src/devices/grolbp/lbp.cpp: Likewise. * src/devices/grolj4/lj4.cpp: Likewise. * src/devices/grops/ps.cpp: Likewise. * src/devices/grotty/tty.cpp: Likewise.
Diffstat (limited to 'src')
-rw-r--r--src/devices/grodvi/dvi.cpp4
-rw-r--r--src/devices/grohtml/post-html.cpp32
-rw-r--r--src/devices/grolbp/lbp.cpp4
-rw-r--r--src/devices/grolj4/lj4.cpp4
-rw-r--r--src/devices/grops/ps.cpp10
-rw-r--r--src/devices/grotty/tty.cpp4
-rw-r--r--src/include/font.h112
-rw-r--r--src/include/printer.h5
-rw-r--r--src/libs/libdriver/printer.cpp12
-rw-r--r--src/libs/libgroff/font.cpp82
-rw-r--r--src/libs/libgroff/nametoindex.cpp38
-rw-r--r--src/roff/troff/charinfo.h8
-rw-r--r--src/roff/troff/input.cpp8
13 files changed, 136 insertions, 187 deletions
diff --git a/src/devices/grodvi/dvi.cpp b/src/devices/grodvi/dvi.cpp
index 30a072a4..0e345c9f 100644
--- a/src/devices/grodvi/dvi.cpp
+++ b/src/devices/grodvi/dvi.cpp
@@ -175,7 +175,7 @@ public:
font *make_font(const char *);
void begin_page(int);
void end_page(int);
- void set_char(glyph, font *, const environment *, int, const char *);
+ void set_char(glyph *, font *, const environment *, int, const char *);
void special(char *, const environment *, char);
void end_of_line();
void draw(int, int *, int, const environment *);
@@ -340,7 +340,7 @@ void dvi_printer::set_color(color *col)
do_special(buf);
}
-void dvi_printer::set_char(glyph g, font *f, const environment *env,
+void dvi_printer::set_char(glyph *g, font *f, const environment *env,
int w, const char *)
{
if (*env->col != cur_color)
diff --git a/src/devices/grohtml/post-html.cpp b/src/devices/grohtml/post-html.cpp
index f2d21792..f427149a 100644
--- a/src/devices/grohtml/post-html.cpp
+++ b/src/devices/grohtml/post-html.cpp
@@ -1417,7 +1417,7 @@ void page::add_and_encode (style *s, const string &str,
if (html_glyph)
html_string += html_glyph;
else {
- glyph g = name_to_glyph((troff_charname + '\0').contents());
+ glyph *g = name_to_glyph((troff_charname + '\0').contents());
if (s->f->contains(g))
html_string += s->f->get_code(g);
}
@@ -1938,7 +1938,7 @@ class html_printer : public printer {
files file_list;
simple_output html;
int res;
- glyph space_glyph;
+ glyph *space_glyph;
int space_width;
int no_of_printed_pages;
int paper_length;
@@ -2009,9 +2009,9 @@ class html_printer : public printer {
void set_line_thickness (const environment *);
void terminate_current_font (void);
void flush_font (void);
- void add_to_sbuf (glyph g, const string &s);
+ void add_to_sbuf (glyph *g, const string &s);
void write_title (int in_head);
- int sbuf_continuation (glyph g, const char *name, const environment *env, int w);
+ int sbuf_continuation (glyph *g, const char *name, const environment *env, int w);
void flush_page (void);
void troff_tag (text_glob *g);
void flush_globs (void);
@@ -2062,7 +2062,7 @@ class html_printer : public printer {
void outstanding_eol (int n);
int is_bold (font *f);
font *make_bold (font *f);
- int overstrike (glyph g, const char *name, const environment *env, int w);
+ int overstrike (glyph *g, const char *name, const environment *env, int w);
void do_body (void);
int next_horiz_pos (text_glob *g, int nf);
void lookahead_for_tables (void);
@@ -2100,9 +2100,9 @@ class html_printer : public printer {
public:
html_printer ();
~html_printer ();
- void set_char (glyph g, font *f, const environment *env, int w, const char *name);
+ void set_char (glyph *g, font *f, const environment *env, int w, const char *name);
void set_numbered_char(int num, const environment *env, int *widthp);
- glyph set_char_and_width(const char *nm, const environment *env,
+ glyph *set_char_and_width(const char *nm, const environment *env,
int *widthp, font **f);
void draw (int code, int *p, int np, const environment *env);
void begin_page (int);
@@ -4234,7 +4234,7 @@ html_printer::html_printer()
* add_to_sbuf - adds character code or name to the sbuf.
*/
-void html_printer::add_to_sbuf (glyph g, const string &s)
+void html_printer::add_to_sbuf (glyph *g, const string &s)
{
if (sbuf_style.f == NULL)
return;
@@ -4260,7 +4260,7 @@ void html_printer::add_to_sbuf (glyph g, const string &s)
sbuf += html_glyph;
}
-int html_printer::sbuf_continuation (glyph g, const char *name,
+int html_printer::sbuf_continuation (glyph *g, const char *name,
const environment *env, int w)
{
/*
@@ -4302,7 +4302,7 @@ const char *get_html_translation (font *f, const string &name)
if ((f == 0) || name.empty())
return NULL;
else {
- glyph g = name_to_glyph((char *)(name + '\0').contents());
+ glyph *g = name_to_glyph((char *)(name + '\0').contents());
if (f->contains(g))
return get_html_entity(f->get_code(g));
else
@@ -4576,7 +4576,7 @@ static const char *get_html_entity (unsigned int code)
* is flushed.
*/
-int html_printer::overstrike(glyph g, const char *name, const environment *env, int w)
+int html_printer::overstrike(glyph *g, const char *name, const environment *env, int w)
{
if ((env->hpos < sbuf_end_hpos)
|| ((sbuf_kern != 0) && (sbuf_end_hpos - sbuf_kern < env->hpos))) {
@@ -4609,7 +4609,7 @@ int html_printer::overstrike(glyph g, const char *name, const environment *env,
* and add character anew.
*/
-void html_printer::set_char(glyph g, font *f, const environment *env,
+void html_printer::set_char(glyph *g, font *f, const environment *env,
int w, const char *name)
{
style sty(f, env->size, env->height, env->slant, env->fontno, *env->col);
@@ -4650,7 +4650,7 @@ void html_printer::set_numbered_char(int num, const environment *env,
nbsp_width = -num;
num = 160; // &nbsp;
}
- glyph g = number_to_glyph(num);
+ glyph *g = number_to_glyph(num);
int fn = env->fontno;
if (fn < 0 || fn >= nfonts) {
error("bad font position `%1'", fn);
@@ -4678,10 +4678,10 @@ void html_printer::set_numbered_char(int num, const environment *env,
set_char(g, f, env, w, 0);
}
-glyph html_printer::set_char_and_width(const char *nm, const environment *env,
- int *widthp, font **f)
+glyph *html_printer::set_char_and_width(const char *nm, const environment *env,
+ int *widthp, font **f)
{
- glyph g = name_to_glyph(nm);
+ glyph *g = name_to_glyph(nm);
int fn = env->fontno;
if (fn < 0 || fn >= nfonts) {
error("bad font position `%1'", fn);
diff --git a/src/devices/grolbp/lbp.cpp b/src/devices/grolbp/lbp.cpp
index 704f337e..292e91e1 100644
--- a/src/devices/grolbp/lbp.cpp
+++ b/src/devices/grolbp/lbp.cpp
@@ -63,7 +63,7 @@ class lbp_printer : public printer {
public:
lbp_printer(int, double, double);
~lbp_printer();
- void set_char(glyph, font *, const environment *, int, const char *name);
+ void set_char(glyph *, font *, const environment *, int, const char *name);
void draw(int code, int *p, int np, const environment *env);
void begin_page(int);
void end_page(int page_length);
@@ -277,7 +277,7 @@ char *lbp_printer::font_name(const lbp_font *f, const int siz)
return bfont_name;
}
-void lbp_printer::set_char(glyph g, font *f, const environment *env,
+void lbp_printer::set_char(glyph *g, font *f, const environment *env,
int w, const char *)
{
int code = f->get_code(g);
diff --git a/src/devices/grolj4/lj4.cpp b/src/devices/grolj4/lj4.cpp
index c48b8fad..04f52762 100644
--- a/src/devices/grolj4/lj4.cpp
+++ b/src/devices/grolj4/lj4.cpp
@@ -163,7 +163,7 @@ class lj4_printer : public printer {
public:
lj4_printer(int);
~lj4_printer();
- void set_char(glyph, font *, const environment *, int, const char *name);
+ void set_char(glyph *, font *, const environment *, int, const char *name);
void draw(int code, int *p, int np, const environment *env);
void begin_page(int);
void end_page(int page_length);
@@ -278,7 +278,7 @@ int is_unprintable(unsigned char c)
return c < 32 && (c == 0 || (7 <= c && c <= 15) || c == 27);
}
-void lj4_printer::set_char(glyph g, font *f, const environment *env,
+void lj4_printer::set_char(glyph *g, font *f, const environment *env,
int w, const char *)
{
int code = f->get_code(g);
diff --git a/src/devices/grops/ps.cpp b/src/devices/grops/ps.cpp
index f2ed3e63..8b33bf35 100644
--- a/src/devices/grops/ps.cpp
+++ b/src/devices/grops/ps.cpp
@@ -524,7 +524,7 @@ class ps_printer : public printer {
FILE *tempfp;
ps_output out;
int res;
- glyph space_glyph;
+ glyph *space_glyph;
int pages_output;
int paper_length;
int equalise_spaces;
@@ -563,7 +563,7 @@ class ps_printer : public printer {
void set_style(const style &);
void set_space_code(unsigned char);
int set_encoding_index(ps_font *);
- subencoding *set_subencoding(font *, glyph, unsigned char *);
+ subencoding *set_subencoding(font *, glyph *, unsigned char *);
char *get_subfont(subencoding *, const char *);
void do_exec(char *, const environment *);
void do_import(char *, const environment *);
@@ -588,7 +588,7 @@ class ps_printer : public printer {
public:
ps_printer(double);
~ps_printer();
- void set_char(glyph, font *, const environment *, int, const char *);
+ void set_char(glyph *, font *, const environment *, int, const char *);
void draw(int, int *, int, const environment *);
void begin_page(int);
void end_page(int);
@@ -656,7 +656,7 @@ int ps_printer::set_encoding_index(ps_font *f)
return f->encoding_index = next_encoding_index++;
}
-subencoding *ps_printer::set_subencoding(font *f, glyph g,
+subencoding *ps_printer::set_subencoding(font *f, glyph *g,
unsigned char *codep)
{
unsigned int idx = f->get_code(g);
@@ -686,7 +686,7 @@ char *ps_printer::get_subfont(subencoding *sub, const char *stem)
return sub->subfont;
}
-void ps_printer::set_char(glyph g, font *f, const environment *env, int w,
+void ps_printer::set_char(glyph *g, font *f, const environment *env, int w,
const char *)
{
if (g == space_glyph || invis_count > 0)
diff --git a/src/devices/grotty/tty.cpp b/src/devices/grotty/tty.cpp
index 622bd82d..3896ab4e 100644
--- a/src/devices/grotty/tty.cpp
+++ b/src/devices/grotty/tty.cpp
@@ -219,7 +219,7 @@ class tty_printer : public printer {
public:
tty_printer(const char *);
~tty_printer();
- void set_char(glyph, font *, const environment *, int, const char *);
+ void set_char(glyph *, font *, const environment *, int, const char *);
void draw(int, int *, int, const environment *);
void special(char *, const environment *, char);
void change_color(const environment * const);
@@ -364,7 +364,7 @@ schar tty_printer::color_to_idx(color *col)
return idx;
}
-void tty_printer::set_char(glyph g, font *f, const environment *env,
+void tty_printer::set_char(glyph *g, font *f, const environment *env,
int w, const char *)
{
if (w % font::hor != 0)
diff --git a/src/include/font.h b/src/include/font.h
index 3489b1ec..287d2006 100644
--- a/src/include/font.h
+++ b/src/include/font.h
@@ -26,8 +26,8 @@ typedef void (*FONT_COMMAND_HANDLER)(const char *, // command
const char *, // file
int); // lineno
-// A glyph is represented by a font-independent `glyph' object.
-// The functions name_to_glyph and number_to_glyph return such an object.
+// A glyph is represented by a font-independent `glyph *' pointer.
+// The functions name_to_glyph and number_to_glyph return such a pointer.
//
// There are two types of glyphs:
//
@@ -44,93 +44,45 @@ typedef void (*FONT_COMMAND_HANDLER)(const char *, // command
// `charinfo' exists in two versions: one in roff/troff/input.cpp for troff,
// and one in libs/libgroff/nametoindex.cpp for the preprocessors and the
// postprocessors.
-struct glyphinfo {
+struct glyph {
int index; // A font-independent integer value.
int number; // Glyph number or -1.
friend class character_indexer;
};
-struct glyph {
-private:
- glyphinfo *ptr; // Pointer to the complete information.
- friend class character_indexer;
- friend class charinfo;
- glyph(glyphinfo *); // Glyph with given complete information.
-public:
- glyph(); // Uninitialized glyph.
- static glyph undefined_glyph(); // Undefined glyph.
- int glyph_index();
- const char *glyph_name(); // Return the glyph name or NULL.
- int glyph_number(); // Return the glyph number or -1.
- int operator==(const glyph &) const;
- int operator!=(const glyph &) const;
-};
-
-inline glyph::glyph(glyphinfo *p)
-: ptr (p)
-{
-}
-
-inline glyph::glyph()
-: ptr ((glyphinfo *) 0xdeadbeef)
-{
-}
-
-inline glyph glyph::undefined_glyph()
-{
- return glyph(NULL);
-}
-#define UNDEFINED_GLYPH glyph::undefined_glyph()
-
-inline int glyph::glyph_index()
-{
- return ptr->index;
-}
-
-inline int glyph::glyph_number()
-{
- return ptr->number;
-}
-
-inline int glyph::operator==(const glyph &other) const
-{
- return ptr == other.ptr;
-}
-
-inline int glyph::operator!=(const glyph &other) const
-{
- return ptr != other.ptr;
-}
+#define UNDEFINED_GLYPH ((glyph *) NULL)
-// The next two functions and glyph::glyph_name() exist in two versions: one in
+// The next three functions exist in two versions: one in
// roff/troff/input.cpp for troff, and one in
// libs/libgroff/nametoindex.cpp for the preprocessors and the
// postprocessors.
-extern glyph name_to_glyph(const char *); // Convert the glyph with
+extern glyph *name_to_glyph(const char *); // Convert the glyph with
// the given name (arg1) to a `glyph' object. This
// has the same semantics as the groff escape sequence
// \C'name'. If such a `glyph' object does not yet
// exist, a new one is allocated.
-extern glyph number_to_glyph(int); // Convert the font-dependent glyph
+extern glyph *number_to_glyph(int); // Convert the font-dependent glyph
// with the given number (in the font) to a `glyph'
// object. This has the same semantics as the groff
// escape sequence \N'number'. If such a `glyph'
// object does not yet exist, a new one is allocated.
-inline const char *glyph_to_name(glyph); // Convert the given glyph
+extern const char *glyph_to_name(glyph *); // Convert the given glyph
// back to its name. Return NULL if the glyph
// doesn't have a name.
-inline int glyph_to_number(glyph); // Convert the given glyph back to
+inline int glyph_to_number(glyph *); // Convert the given glyph back to
// its number. Return -1 if it does not designate
// a numbered character.
+inline int glyph_to_index(glyph *); // Return the unique index that is
+ // associated with the given glyph. It is >= 0.
-inline const char *glyph_to_name(glyph g)
+inline int glyph_to_number(glyph *g)
{
- return g.glyph_name();
+ return g->number;
}
-inline int glyph_to_number(glyph g)
+inline int glyph_to_index(glyph *g)
{
- return g.glyph_number();
+ return g->index;
}
// Types used in non-public members of `class font'.
@@ -152,23 +104,23 @@ public:
};
virtual ~font(); // Destructor.
- int contains(glyph); // Return 1 if this font contains the given
+ int contains(glyph *); // Return 1 if this font contains the given
// glyph, 0 otherwise.
int is_special(); // Return 1 if this font is special, 0 otherwise.
// See section `Special Fonts' in the info file of
// groff. Used by make_glyph_node().
- int get_width(glyph, int); // A rectangle represents the shape of the
+ int get_width(glyph *, int); // A rectangle represents the shape of the
// given glyph (arg1) at the given point size
// (arg2). Return the horizontal dimension of this
// rectangle.
- int get_height(glyph, int); // A rectangle represents the shape of the
+ int get_height(glyph *, int); // A rectangle represents the shape of the
// given glyph (arg1) at the given point size
// (arg2). Return the distance between the base
// line and the top of this rectangle.
// This is often also called the `ascent' of the
// glyph. If the top is above the base line, this
// value is positive.
- int get_depth(glyph, int); // A rectangle represents the shape of the
+ int get_depth(glyph *, int); // A rectangle represents the shape of the
// given glyph (arg1) at the given point size
// (arg2). Return the distance between the base
// line and the bottom of this rectangle.
@@ -177,15 +129,15 @@ public:
// this value is positive.
int get_space_width(int); // Return the normal width of a space at the
// given point size.
- int get_character_type(glyph); // Return a bit mask describing the
+ int get_character_type(glyph *); // Return a bit mask describing the
// shape of the given glyph. Bit 0 is set if the
// character has a descender. Bit 1 is set if the
// character has a tall glyph. See groff manual,
// description of \w and the `ct' register.
- int get_kern(glyph, glyph, int); // Return the kerning between the
+ int get_kern(glyph *, glyph *, int); // Return the kerning between the
// given glyphs (arg1 and arg2), both at the given
// point size (arg3).
- int get_skew(glyph, int, int); // A rectangle represents the shape
+ int get_skew(glyph *, int, int); // A rectangle represents the shape
// of the given glyph (arg1) at the given point size
// (arg2). For slanted fonts like Times-Italic, the
// optical vertical axis is naturally slanted. The
@@ -208,27 +160,27 @@ public:
int has_ligature(int); // Return a non-zero value if this font has
// the given ligature type (one of LIG_ff, LIG_fi,
// etc.), 0 otherwise.
- int get_italic_correction(glyph, int); // If the given glyph (arg1)
+ int get_italic_correction(glyph *, int); // If the given glyph (arg1)
// at the given point size (arg2) is followed by an
// unslanted glyph, some horizontal white space may
// need to be inserted in between. See the groff
// manual, description of \/. Return the amount
// (width) of this white space.
- int get_left_italic_correction(glyph, int); // If the given glyph (arg1)
+ int get_left_italic_correction(glyph *, int); // If the given glyph (arg1)
// at the given point size (arg2) is preceded by an
// unslanted roman glyph, some horizontal white
// space may need to be inserted in between. See
// the groff manual, description of \,. Return the
// amount (width) of this white space.
- int get_subscript_correction(glyph, int); // If the given glyph (arg1)
+ int get_subscript_correction(glyph *, int); // If the given glyph (arg1)
// at the given point size (arg2)is followed by a
// subscript glyph, the horizontal position may need
// to be advanced by some (possibly negative)
// amount. See groff manual, description of \w and
// the `ssc' register. Return this amount.
- int get_code(glyph); // Return the code point in the physical
+ int get_code(glyph *); // Return the code point in the physical
// font of the given glyph.
- const char *get_special_device_encoding(glyph); // Return special
+ const char *get_special_device_encoding(glyph *); // Return special
// device dependent information about the given
// glyph. Return NULL if there is no special
// information.
@@ -340,18 +292,18 @@ private:
// pairs.
// These methods add new characters to the ch_index[] and ch[] arrays.
- void add_entry(glyph, // glyph
+ void add_entry(glyph *, // glyph
const font_char_metric &); // metric
- void copy_entry(glyph, // new_glyph
- glyph); // old_glyph
+ void copy_entry(glyph *, // new_glyph
+ glyph *); // old_glyph
void alloc_ch_index(int); // index
void extend_ch();
void compact();
- void add_kern(glyph, glyph, int); // Add to the kerning table a
+ void add_kern(glyph *, glyph *, int); // Add to the kerning table a
// kerning amount (arg3) between two given glyphs
// (arg1 and arg2).
- static int hash_kern(glyph, glyph); // Return a hash code for
+ static int hash_kern(glyph *, glyph *); // Return a hash code for
// the pair of glyphs (arg1 and arg2).
/* Returns w * pointsize / unitwidth, rounded to the nearest integer. */
diff --git a/src/include/printer.h b/src/include/printer.h
index a5fb5a55..b4106937 100644
--- a/src/include/printer.h
+++ b/src/include/printer.h
@@ -66,7 +66,8 @@ public:
void set_ascii_char(unsigned char, const environment *, int * = 0);
void set_special_char(const char *, const environment *, int * = 0);
virtual void set_numbered_char(int, const environment *, int * = 0);
- glyph set_char_and_width(const char *, const environment *, int *, font **);
+ glyph *set_char_and_width(const char *, const environment *,
+ int *, font **);
font *get_font_from_index(int);
virtual void draw(int, int *, int, const environment *);
// perform change of line color (text, outline) in the print-out
@@ -94,7 +95,7 @@ protected:
private:
font *find_font(const char *);
- virtual void set_char(glyph, font *, const environment *, int,
+ virtual void set_char(glyph *, font *, const environment *, int,
const char *) = 0;
};
diff --git a/src/libs/libdriver/printer.cpp b/src/libs/libdriver/printer.cpp
index 8549dc19..d464d2ba 100644
--- a/src/libs/libdriver/printer.cpp
+++ b/src/libs/libdriver/printer.cpp
@@ -182,7 +182,7 @@ void printer::set_ascii_char(unsigned char c, const environment *env,
buf[0] = c;
buf[1] = '\0';
- glyph g = set_char_and_width(buf, env, &w, &f);
+ glyph *g = set_char_and_width(buf, env, &w, &f);
set_char(g, f, env, w, 0);
if (widthp) {
*widthp = w;
@@ -194,7 +194,7 @@ void printer::set_special_char(const char *nm, const environment *env,
{
font *f;
int w;
- glyph g = set_char_and_width(nm, env, &w, &f);
+ glyph *g = set_char_and_width(nm, env, &w, &f);
if (g != UNDEFINED_GLYPH) {
set_char(g, f, env, w, nm);
if (widthp)
@@ -202,10 +202,10 @@ void printer::set_special_char(const char *nm, const environment *env,
}
}
-glyph printer::set_char_and_width(const char *nm, const environment *env,
- int *widthp, font **f)
+glyph *printer::set_char_and_width(const char *nm, const environment *env,
+ int *widthp, font **f)
{
- glyph g = name_to_glyph(nm);
+ glyph *g = name_to_glyph(nm);
int fn = env->fontno;
if (fn < 0 || fn >= nfonts) {
error("bad font position `%1'", fn);
@@ -235,7 +235,7 @@ glyph printer::set_char_and_width(const char *nm, const environment *env,
void printer::set_numbered_char(int num, const environment *env, int *widthp)
{
- glyph g = number_to_glyph(num);
+ glyph *g = number_to_glyph(num);
int fn = env->fontno;
if (fn < 0 || fn >= nfonts) {
error("bad font position `%1'", fn);
diff --git a/src/libs/libgroff/font.cpp b/src/libs/libgroff/font.cpp
index 846a5059..30fbff0e 100644
--- a/src/libs/libgroff/font.cpp
+++ b/src/libs/libgroff/font.cpp
@@ -47,12 +47,12 @@ struct font_char_metric {
};
struct font_kern_list {
- glyph glyph1;
- glyph glyph2;
+ glyph *glyph1;
+ glyph *glyph2;
int amount;
font_kern_list *next;
- font_kern_list(glyph, glyph, int, font_kern_list * = 0);
+ font_kern_list(glyph *, glyph *, int, font_kern_list * = 0);
};
struct font_widths_cache {
@@ -239,15 +239,15 @@ int font::unit_scale(double *value, char unit)
return 0;
}
-int font::get_skew(glyph g, int point_size, int sl)
+int font::get_skew(glyph *g, int point_size, int sl)
{
int h = get_height(g, point_size);
return int(h * tan((slant + sl) * PI / 180.0) + .5);
}
-int font::contains(glyph g)
+int font::contains(glyph *g)
{
- int idx = g.glyph_index();
+ int idx = glyph_to_index(g);
assert(idx >= 0);
return idx < nindices && ch_index[idx] >= 0;
}
@@ -271,9 +271,9 @@ font_widths_cache::~font_widths_cache()
a_delete width;
}
-int font::get_width(glyph g, int point_size)
+int font::get_width(glyph *g, int point_size)
{
- int idx = g.glyph_index();
+ int idx = glyph_to_index(g);
assert(idx >= 0 && idx < nindices);
int i = ch_index[idx];
assert(i >= 0);
@@ -303,37 +303,37 @@ int font::get_width(glyph g, int point_size)
return w;
}
-int font::get_height(glyph g, int point_size)
+int font::get_height(glyph *g, int point_size)
{
- int idx = g.glyph_index();
+ int idx = glyph_to_index(g);
assert(idx >= 0 && idx < nindices && ch_index[idx] >= 0);
return scale(ch[ch_index[idx]].height, point_size);
}
-int font::get_depth(glyph g, int point_size)
+int font::get_depth(glyph *g, int point_size)
{
- int idx = g.glyph_index();
+ int idx = glyph_to_index(g);
assert(idx >= 0 && idx < nindices && ch_index[idx] >= 0);
return scale(ch[ch_index[idx]].depth, point_size);
}
-int font::get_italic_correction(glyph g, int point_size)
+int font::get_italic_correction(glyph *g, int point_size)
{
- int idx = g.glyph_index();
+ int idx = glyph_to_index(g);
assert(idx >= 0 && idx < nindices && ch_index[idx] >= 0);
return scale(ch[ch_index[idx]].italic_correction, point_size);
}
-int font::get_left_italic_correction(glyph g, int point_size)
+int font::get_left_italic_correction(glyph *g, int point_size)
{
- int idx = g.glyph_index();
+ int idx = glyph_to_index(g);
assert(idx >= 0 && idx < nindices && ch_index[idx] >= 0);
return scale(ch[ch_index[idx]].pre_math_space, point_size);
}
-int font::get_subscript_correction(glyph g, int point_size)
+int font::get_subscript_correction(glyph *g, int point_size)
{
- int idx = g.glyph_index();
+ int idx = glyph_to_index(g);
assert(idx >= 0 && idx < nindices && ch_index[idx] >= 0);
return scale(ch[ch_index[idx]].subscript_correction, point_size);
}
@@ -343,19 +343,19 @@ int font::get_space_width(int point_size)
return scale(space_width, point_size);
}
-font_kern_list::font_kern_list(glyph g1, glyph g2, int n, font_kern_list *p)
+font_kern_list::font_kern_list(glyph *g1, glyph *g2, int n, font_kern_list *p)
: glyph1(g1), glyph2(g2), amount(n), next(p)
{
}
-inline int font::hash_kern(glyph g1, glyph g2)
+inline int font::hash_kern(glyph *g1, glyph *g2)
{
- int n = ((g1.glyph_index() << 10) + g2.glyph_index())
+ int n = ((glyph_to_index(g1) << 10) + glyph_to_index(g2))
% KERN_HASH_TABLE_SIZE;
return n < 0 ? -n : n;
}
-void font::add_kern(glyph g1, glyph g2, int amount)
+void font::add_kern(glyph *g1, glyph *g2, int amount)
{
if (!kern_hash_table) {
kern_hash_table = new font_kern_list *[int(KERN_HASH_TABLE_SIZE)];
@@ -366,7 +366,7 @@ void font::add_kern(glyph g1, glyph g2, int amount)
*p = new font_kern_list(g1, g2, amount, *p);
}
-int font::get_kern(glyph g1, glyph g2, int point_size)
+int font::get_kern(glyph *g1, glyph *g2, int point_size)
{
if (kern_hash_table) {
for (font_kern_list *p = kern_hash_table[hash_kern(g1, g2)]; p;
@@ -382,16 +382,16 @@ int font::has_ligature(int mask)
return mask & ligatures;
}
-int font::get_character_type(glyph g)
+int font::get_character_type(glyph *g)
{
- int idx = g.glyph_index();
+ int idx = glyph_to_index(g);
assert(idx >= 0 && idx < nindices && ch_index[idx] >= 0);
return ch[ch_index[idx]].type;
}
-int font::get_code(glyph g)
+int font::get_code(glyph *g)
{
- int idx = g.glyph_index();
+ int idx = glyph_to_index(g);
assert(idx >= 0 && idx < nindices && ch_index[idx] >= 0);
return ch[ch_index[idx]].code;
}
@@ -406,9 +406,9 @@ const char *font::get_internal_name()
return internalname;
}
-const char *font::get_special_device_encoding(glyph g)
+const char *font::get_special_device_encoding(glyph *g)
{
- int idx = g.glyph_index();
+ int idx = glyph_to_index(g);
assert(idx >= 0 && idx < nindices && ch_index[idx] >= 0);
return ch[ch_index[idx]].special_device_coding;
}
@@ -479,9 +479,9 @@ void font::compact()
}
}
-void font::add_entry(glyph g, const font_char_metric &metric)
+void font::add_entry(glyph *g, const font_char_metric &metric)
{
- int idx = g.glyph_index();
+ int idx = glyph_to_index(g);
assert(idx >= 0);
if (idx >= nindices)
alloc_ch_index(idx);
@@ -493,10 +493,10 @@ void font::add_entry(glyph g, const font_char_metric &metric)
ch[ch_used++] = metric;
}
-void font::copy_entry(glyph new_glyph, glyph old_glyph)
+void font::copy_entry(glyph *new_glyph, glyph *old_glyph)
{
- int new_index = new_glyph.glyph_index();
- int old_index = old_glyph.glyph_index();
+ int new_index = glyph_to_index(new_glyph);
+ int old_index = glyph_to_index(old_glyph);
assert(new_index >= 0 && old_index >= 0 && old_index < nindices);
if (new_index >= nindices)
alloc_ch_index(new_index);
@@ -693,15 +693,14 @@ int font::load(int *not_found, int head_only)
t.error("bad kern amount `%1'", p);
return 0;
}
- glyph g1 = name_to_glyph(c1);
- glyph g2 = name_to_glyph(c2);
+ glyph *g1 = name_to_glyph(c1);
+ glyph *g2 = name_to_glyph(c2);
add_kern(g1, g2, n);
}
}
else if (strcmp(command, "charset") == 0) {
had_charset = 1;
- glyph last_glyph;
- int got_last_glyph = 0;
+ glyph *last_glyph = NULL;
for (;;) {
if (!t.next()) {
command = 0;
@@ -716,7 +715,7 @@ int font::load(int *not_found, int head_only)
break;
}
if (p[0] == '"') {
- if (!got_last_glyph) {
+ if (last_glyph == NULL) {
t.error("first charset entry is duplicate");
return 0;
}
@@ -724,7 +723,7 @@ int font::load(int *not_found, int head_only)
t.error("unnamed character cannot be duplicate");
return 0;
}
- glyph g = name_to_glyph(nm);
+ glyph *g = name_to_glyph(nm);
copy_entry(g, last_glyph);
}
else {
@@ -787,10 +786,9 @@ int font::load(int *not_found, int head_only)
add_entry(last_glyph, metric);
copy_entry(number_to_glyph(metric.code), last_glyph);
}
- got_last_glyph = 1;
}
}
- if (!got_last_glyph) {
+ if (last_glyph == NULL) {
t.error("I didn't seem to find any characters");
return 0;
}
diff --git a/src/libs/libgroff/nametoindex.cpp b/src/libs/libgroff/nametoindex.cpp
index 65362475..2dfe079d 100644
--- a/src/libs/libgroff/nametoindex.cpp
+++ b/src/libs/libgroff/nametoindex.cpp
@@ -31,12 +31,10 @@ Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
#include "itable.h"
// Every glyphinfo is actually a charinfo.
-class charinfo : glyphinfo {
-private:
- const char *name; // The glyph name, or NULL.
+class charinfo : glyph {
public:
+ const char *name; // The glyph name, or NULL.
friend class character_indexer;
- friend class glyph;
};
// PTABLE(charinfo) is a hash table mapping `const char *' to `charinfo *'.
@@ -54,17 +52,17 @@ public:
character_indexer();
~character_indexer();
// --------------------- Lookup or creation of a glyph.
- glyph ascii_char_glyph(unsigned char);
- glyph named_char_glyph(const char *);
- glyph numbered_char_glyph(int);
+ glyph *ascii_char_glyph(unsigned char);
+ glyph *named_char_glyph(const char *);
+ glyph *numbered_char_glyph(int);
private:
int next_index; // Number of glyphs already allocated.
PTABLE(charinfo) table; // Table mapping name to glyph.
- glyph ascii_glyph[256]; // Shorthand table for looking up "charNNN"
+ glyph *ascii_glyph[256]; // Shorthand table for looking up "charNNN"
// glyphs.
ITABLE(charinfo) ntable; // Table mapping number to glyph.
enum { NSMALL = 256 };
- glyph small_number_glyph[NSMALL]; // Shorthand table for looking up
+ glyph *small_number_glyph[NSMALL]; // Shorthand table for looking up
// numbered glyphs with small numbers.
};
@@ -82,7 +80,7 @@ character_indexer::~character_indexer()
{
}
-glyph character_indexer::ascii_char_glyph(unsigned char c)
+glyph *character_indexer::ascii_char_glyph(unsigned char c)
{
if (ascii_glyph[c] == UNDEFINED_GLYPH) {
char buf[4+3+1];
@@ -92,12 +90,12 @@ glyph character_indexer::ascii_char_glyph(unsigned char c)
ci->index = next_index++;
ci->number = -1;
ci->name = strsave(buf);
- ascii_glyph[c] = glyph(ci);
+ ascii_glyph[c] = ci;
}
return ascii_glyph[c];
}
-inline glyph character_indexer::named_char_glyph(const char *s)
+inline glyph *character_indexer::named_char_glyph(const char *s)
{
// Glyphs with name `charNNN' are only stored in ascii_glyph[], not
// in the table. Therefore treat them specially here.
@@ -114,10 +112,10 @@ inline glyph character_indexer::named_char_glyph(const char *s)
ci->number = -1;
ci->name = table.define(s, ci);
}
- return glyph(ci);
+ return ci;
}
-inline glyph character_indexer::numbered_char_glyph(int n)
+inline glyph *character_indexer::numbered_char_glyph(int n)
{
if (n >= 0 && n < NSMALL) {
if (small_number_glyph[n] == UNDEFINED_GLYPH) {
@@ -125,7 +123,7 @@ inline glyph character_indexer::numbered_char_glyph(int n)
ci->index = next_index++;
ci->number = n;
ci->name = NULL;
- small_number_glyph[n] = glyph(ci);
+ small_number_glyph[n] = ci;
}
return small_number_glyph[n];
}
@@ -137,17 +135,17 @@ inline glyph character_indexer::numbered_char_glyph(int n)
ci->name = NULL;
ntable.define(n, ci);
}
- return glyph(ci);
+ return ci;
}
static character_indexer indexer;
-glyph number_to_glyph(int n)
+glyph *number_to_glyph(int n)
{
return indexer.numbered_char_glyph(n);
}
-glyph name_to_glyph(const char *s)
+glyph *name_to_glyph(const char *s)
{
assert(s != 0 && s[0] != '\0' && s[0] != ' ');
if (s[1] == '\0')
@@ -156,8 +154,8 @@ glyph name_to_glyph(const char *s)
return indexer.named_char_glyph(s);
}
-const char *glyph::glyph_name()
+const char *glyph_to_name(glyph *g)
{
- charinfo *ci = (charinfo *)ptr; // Every glyphinfo is actually a charinfo.
+ charinfo *ci = (charinfo *)g; // Every glyph is actually a charinfo.
return ci->name;
}
diff --git a/src/roff/troff/charinfo.h b/src/roff/troff/charinfo.h
index 5c66f68e..2d270699 100644
--- a/src/roff/troff/charinfo.h
+++ b/src/roff/troff/charinfo.h
@@ -21,7 +21,7 @@ Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
class macro;
-class charinfo : glyphinfo {
+class charinfo : glyph {
static int next_index;
charinfo *translation;
macro *mac;
@@ -55,7 +55,7 @@ public:
};
symbol nm;
charinfo(symbol s);
- glyph as_glyph();
+ glyph *as_glyph();
int ends_sentence();
int overlaps_vertically();
int overlaps_horizontally();
@@ -169,9 +169,9 @@ inline void charinfo::set_flags(unsigned char c)
flags = c;
}
-inline glyph charinfo::as_glyph()
+inline glyph *charinfo::as_glyph()
{
- return glyph(this);
+ return this;
}
inline void charinfo::set_translation_input()
diff --git a/src/roff/troff/input.cpp b/src/roff/troff/input.cpp
index 14fa6ca6..f7c01c98 100644
--- a/src/roff/troff/input.cpp
+++ b/src/roff/troff/input.cpp
@@ -8195,7 +8195,7 @@ charinfo *get_charinfo_by_number(int n)
}
}
-glyph name_to_glyph(const char *nm)
+glyph *name_to_glyph(const char *nm)
{
charinfo *ci;
if (nm[1] == 0)
@@ -8207,13 +8207,13 @@ glyph name_to_glyph(const char *nm)
return ci->as_glyph();
}
-glyph number_to_glyph(int n)
+glyph *number_to_glyph(int n)
{
return get_charinfo_by_number(n)->as_glyph();
}
-const char *glyph::glyph_name()
+const char *glyph_to_name(glyph *g)
{
- charinfo *ci = (charinfo *)ptr; // Every glyphinfo is actually a charinfo.
+ charinfo *ci = (charinfo *)g; // Every glyph is actually a charinfo.
return (ci->nm != UNNAMED_SYMBOL ? ci->nm.contents() : NULL);
}