ps: put the findfont call near scalefont and setfont calls
[neatpost.git] / post.h
blob680f38baee3ea2c723349230e043986e91471305
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 NLIGS 32 /* number of font ligatures */
6 #define NKERNS 512 /* number of font pairwise kerning pairs */
7 #define FNLEN 64 /* font name length */
8 #define GNLEN 32 /* glyph name length */
9 #define ILNLEN 1000 /* line limit of input files */
10 #define LNLEN 4000 /* line buffer length (ren.c/out.c) */
11 #define LIGLEN 4 /* length of ligatures */
13 #define MIN(a, b) ((a) < (b) ? (a) : (b))
14 #define MAX(a, b) ((a) < (b) ? (b) : (a))
15 #define LEN(a) (sizeof(a) / sizeof((a)[0]))
17 /* device related variables */
18 extern int dev_res;
19 extern int dev_uwid;
20 extern int dev_hor;
21 extern int dev_ver;
23 struct glyph {
24 char name[GNLEN]; /* name of the glyph */
25 char id[GNLEN]; /* device-dependent glyph identifier */
26 struct font *font; /* glyph font */
27 int wid; /* character width */
28 int type; /* character type; ascender/descender */
31 struct font {
32 char name[FNLEN];
33 char fontname[FNLEN];
34 struct glyph glyphs[NGLYPHS];
35 int nglyphs;
36 int spacewid;
37 int special;
38 char c[NGLYPHS][FNLEN]; /* character names in charset */
39 struct glyph *g[NGLYPHS]; /* character glyphs in charset */
40 int n; /* number of characters in charset */
41 /* font ligatures */
42 char lig[NLIGS][LIGLEN * GNLEN];
43 int nlig;
44 /* glyph list based on the first character of glyph names */
45 int head[256]; /* glyph list head */
46 int next[NGLYPHS]; /* next item in glyph list */
47 /* kerning pair list per glyph */
48 int knhead[NGLYPHS]; /* kerning pairs of glyphs[] */
49 int knnext[NKERNS]; /* next item in knhead[] list */
50 int knpair[NKERNS]; /* kerning pair 2nd glyphs */
51 int knval[NKERNS]; /* font pairwise kerning value */
52 int knn; /* number of kerning pairs */
55 /* output device functions */
56 int dev_open(char *path);
57 void dev_close(void);
58 int dev_mnt(int pos, char *id, char *name);
59 struct font *dev_font(int fn);
60 int dev_fontid(struct font *fn);
61 int charwid(int wid, int sz);
62 struct glyph *dev_glyph(char *c, int fn);
63 struct glyph *dev_glyph_byid(char *id, int fn);
65 /* font-related functions */
66 struct font *font_open(char *path);
67 void font_close(struct font *fn);
68 struct glyph *font_glyph(struct font *fn, char *id);
69 struct glyph *font_find(struct font *fn, char *name);
70 int font_lig(struct font *fn, char **c, int n);
71 int font_kern(struct font *fn, char *c1, char *c2);
73 /* output functions */
74 void out(char *s, ...);
75 void outc(char *s);
76 void outh(int h);
77 void outv(int v);
78 void outrel(int h, int v);
79 void outfont(int f);
80 void outsize(int s);
81 void outcolor(int c);
82 void outpage(void);
83 void outmnt(int f);
84 extern char o_fonts[];
86 void drawbeg(char *s);
87 void drawend(char *s);
88 void drawl(int h, int v);
89 void drawc(int c);
90 void drawe(int h, int v);
91 void drawa(int h1, int v1, int h2, int v2);
92 void draws(int h1, int v1, int h2, int v2);
94 /* postscript functions */
95 void ps_header(void);
96 void ps_trailer(int pages, char *fonts);
97 void ps_pagebeg(int n);
98 void ps_pageend(int n);
100 /* colors */
101 #define CLR_R(c) (((c) >> 16) & 0xff)
102 #define CLR_G(c) (((c) >> 8) & 0xff)
103 #define CLR_B(c) ((c) & 0xff)
104 #define CLR_RGB(r, g, b) (((r) << 16) | ((g) << 8) | (b))
106 char *clr_str(int c);
107 int clr_get(char *s);