~registry/texmacs/trunk

« back to all changes in this revision

Viewing changes to src/src/Graphics/Bitmap_fonts/bitmap_font.hpp

  • Committer: mgubi
  • Date: 2009-06-04 15:13:41 UTC
  • Revision ID: svn-v4:64cb5145-927a-446d-8aed-2fb7b4773692:trunk:2717
Support for X11 TeXmacs.app on Mac

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
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
 
******************************************************************************/
11
 
 
12
 
#ifndef BITMAP_FONT_H
13
 
#define BITMAP_FONT_H
14
 
#include "resource.hpp"
15
 
 
16
 
RESOURCE(font_metric);
17
 
RESOURCE(font_glyphs);
18
 
 
19
 
typedef int SI;
20
 
typedef unsigned char QN;
21
 
 
22
 
struct metric_struct {
23
 
  SI x1, y1;
24
 
  SI x2, y2;
25
 
  SI x3, y3;
26
 
  SI x4, y4;
27
 
};
28
 
 
29
 
typedef metric_struct metric[1];
30
 
 
31
 
/******************************************************************************
32
 
* The glyph structure
33
 
******************************************************************************/
34
 
 
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
42
 
 
43
 
  glyph_rep (int w, int h, int xoff, int yoff, int depth, int status=0);
44
 
  ~glyph_rep ();
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);
51
 
  void adjust_bot ();
52
 
  void adjust_top ();
53
 
};
54
 
 
55
 
struct glyph {
56
 
  CONCRETE_NULL(glyph);
57
 
  glyph (int w2, int h2, int xoff2, int yoff2, int depth2=1, int status2= 0);
58
 
};
59
 
CONCRETE_NULL_CODE(glyph);
60
 
 
61
 
inline int
62
 
glyph_rep::get_1 (int i, int j) {
63
 
  int bit= j*width+i;
64
 
  return (raster[bit>>3] >> (bit&7)) & 1;
65
 
}
66
 
 
67
 
inline void
68
 
glyph_rep::set_1 (int i, int j, int with) {
69
 
  int bit= j*width+i;
70
 
  if (with==0) raster[bit>>3] &= ~(1 << (bit&7));
71
 
  else raster[bit>>3] |= (1 << (bit&7));
72
 
}
73
 
 
74
 
ostream& operator << (ostream& out, glyph gl);
75
 
 
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);
87
 
 
88
 
/******************************************************************************
89
 
* Abstract bitmap fonts and font metrics
90
 
******************************************************************************/
91
 
 
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;
97
 
};
98
 
 
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;
104
 
};
105
 
 
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);
108
 
 
109
 
#endif // defined BITMAP_FONT_H