diff options
author | wl <wl> | 2006-02-23 20:00:46 +0000 |
---|---|---|
committer | wl <wl> | 2006-02-23 20:00:46 +0000 |
commit | a9494c447c55365041c9288b9977b41fecc4bc24 (patch) | |
tree | da81ff2a9e417631d5f106a94453bd0cbaa6bb5a /src/include | |
parent | b600b460cebebf32e2f1de09823ab94600e65d37 (diff) | |
download | groff-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/include')
-rw-r--r-- | src/include/font.h | 112 | ||||
-rw-r--r-- | src/include/printer.h | 5 |
2 files changed, 35 insertions, 82 deletions
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; }; |