2
/******************************************************************************
3
* MODULE : bitmap_font.hpp
4
* DESCRIPTION: bitmap fonts
5
* COPYRIGHT : (C) 1999 Joris van der Hoeven
6
*******************************************************************************
7
* This software falls under the GNU general public license version 3 or later.
8
* It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
9
* in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
10
******************************************************************************/
14
#include "resource.hpp"
16
RESOURCE(font_metric);
17
RESOURCE(font_glyphs);
20
typedef unsigned char QN;
22
struct metric_struct {
29
typedef metric_struct metric[1];
31
/******************************************************************************
33
******************************************************************************/
35
struct glyph_rep: concrete_struct {
36
short depth; // number of bits per pixel >= depth
37
short width, height; // width and height in pixels
38
short xoff, yoff; // offset of origin
39
short lwidth; // logical width of character
40
short status; // status for extensible characters
41
QN* raster; // character definition
43
glyph_rep (int w, int h, int xoff, int yoff, int depth, int status=0);
45
inline int get_1 (int i, int j);
46
inline void set_1 (int i, int j, int with);
47
int get_x (int i, int j);
48
void set_x (int i, int j, int with);
49
int get (int i, int j);
50
void set (int i, int j, int with);
57
glyph (int w2, int h2, int xoff2, int yoff2, int depth2=1, int status2= 0);
59
CONCRETE_NULL_CODE(glyph);
62
glyph_rep::get_1 (int i, int j) {
64
return (raster[bit>>3] >> (bit&7)) & 1;
68
glyph_rep::set_1 (int i, int j, int with) {
70
if (with==0) raster[bit>>3] &= ~(1 << (bit&7));
71
else raster[bit>>3] |= (1 << (bit&7));
74
ostream& operator << (ostream& out, glyph gl);
76
glyph shrink (glyph gl, int xf, int yf, SI& xo, SI& yo);
77
glyph join (glyph gl1, glyph gl2);
78
glyph glue (glyph gl1, glyph gl2);
79
glyph add (glyph gl1, glyph gl2);
80
glyph move (glyph gl, SI x, SI y);
81
glyph clip (glyph gl, SI x1, SI y1, SI x2, SI y3);
82
glyph hor_flip (glyph gl);
83
glyph ver_flip (glyph gl);
84
glyph pos_rotate (glyph gl);
85
glyph hor_extend (glyph gl, int pos, int by);
86
glyph ver_extend (glyph gl, int pos, int by);
88
/******************************************************************************
89
* Abstract bitmap fonts and font metrics
90
******************************************************************************/
92
struct font_metric_rep: rep<font_metric> {
93
bool bad_font_metric; // when font metric could not be loaded
94
font_metric_rep (string name);
95
virtual ~font_metric_rep ();
96
virtual metric& get (int char_code) = 0;
99
struct font_glyphs_rep: rep<font_glyphs> {
100
bool bad_font_glyphs; // when font glyphs could not be loaded
101
font_glyphs_rep (string name);
102
virtual ~font_glyphs_rep ();
103
virtual glyph& get (int char_code) = 0;
106
font_metric std_font_metric (string s, metric* fnm, int bc, int ec);
107
font_glyphs std_font_glyphs (string name, glyph* fng, int bc, int ec);
109
#endif // defined BITMAP_FONT_H