font: font_glyphput() can be static
[neatpost.git] / post.h
blob2bfc2567184f51588db3486a795548cdee2d47e2
1 /* predefined array limits */
2 #define PATHLEN 1024 /* path length */
3 #define NFONTS 32 /* number of fonts */
4 #define NGLYPHS 1024 /* glyphs in fonts */
5 #define FNLEN 64 /* font name length */
6 #define GNLEN 32 /* glyph name length */
7 #define ILNLEN 1000 /* line limit of input files */
8 #define LNLEN 4000 /* line buffer length (ren.c/out.c) */
10 #define MIN(a, b) ((a) < (b) ? (a) : (b))
11 #define MAX(a, b) ((a) < (b) ? (b) : (a))
12 #define LEN(a) (sizeof(a) / sizeof((a)[0]))
14 /* device related variables */
15 extern int dev_res;
16 extern int dev_uwid;
17 extern int dev_hor;
18 extern int dev_ver;
20 struct glyph {
21 char id[GNLEN]; /* device-dependent glyph identifier */
22 char name[GNLEN]; /* the first character mapped to this glyph */
23 struct font *font; /* glyph font */
24 int wid; /* character width */
25 int type; /* character type; ascender/descender */
26 int pos; /* glyph code */
29 struct font {
30 char name[FNLEN];
31 char fontname[FNLEN];
32 struct glyph glyphs[NGLYPHS];
33 int nglyphs;
34 int spacewid;
35 int special;
36 int cs, bd; /* for .cs and .bd requests */
37 /* glyph list based on the first character of their id fields in glyphs[] */
38 int ghead[256]; /* glyph list head */
39 int gnext[NGLYPHS]; /* next item in glyph list */
40 /* charset section characters */
41 char c[NGLYPHS][GNLEN]; /* character names in charset */
42 struct glyph *g[NGLYPHS]; /* character glyphs in charset */
43 int n; /* number of characters in charset */
44 /* glyph list based on the first character of glyph names in c[] */
45 int chead[256]; /* glyph list head */
46 int cnext[NGLYPHS]; /* next item in glyph list */
49 /* output device functions */
50 int dev_open(char *dir, char *dev);
51 void dev_close(void);
52 int dev_mnt(int pos, char *id, char *name);
53 struct font *dev_font(int fn);
54 int dev_fontid(struct font *fn);
55 int charwid(int wid, int sz);
56 struct glyph *dev_glyph(char *c, int fn);
58 /* font-related functions */
59 struct font *font_open(char *path);
60 void font_close(struct font *fn);
61 struct glyph *font_glyph(struct font *fn, char *id);
62 struct glyph *font_find(struct font *fn, char *name);
64 /* output functions */
65 void out(char *s, ...);
66 void outc(char *s);
67 void outh(int h);
68 void outv(int v);
69 void outrel(int h, int v);
70 void outfont(int f);
71 void outsize(int s);
72 void outcolor(int c);
73 void outpage(void);
74 void outmnt(int f);
75 extern char o_fonts[];
77 void drawbeg(void);
78 void drawend(int close, int fill);
79 void drawmbeg(char *s);
80 void drawmend(char *s);
81 void drawl(int h, int v);
82 void drawc(int c);
83 void drawe(int h, int v);
84 void drawa(int h1, int v1, int h2, int v2);
85 void draws(int h1, int v1, int h2, int v2);
87 /* postscript functions */
88 void ps_header(void);
89 void ps_trailer(int pages, char *fonts);
90 void ps_pagebeg(int n);
91 void ps_pageend(int n);
93 /* colors */
94 #define CLR_R(c) (((c) >> 16) & 0xff)
95 #define CLR_G(c) (((c) >> 8) & 0xff)
96 #define CLR_B(c) ((c) & 0xff)
97 #define CLR_RGB(r, g, b) (((r) << 16) | ((g) << 8) | (b))
99 char *clr_str(int c);
100 int clr_get(char *s);