pdf: add splines
[neatpost.git] / post.h
blob0f30569ccf2fe4c9765ef53b84c4df52f3e8815a
1 /* predefined array limits */
2 #define PATHLEN 1024 /* path length */
3 #define NFONTS 1024 /* number of fonts */
4 #define FNLEN 64 /* font name length */
5 #define GNLEN 32 /* glyph name length */
6 #define GNFMT "%31s" /* glyph name scanf format */
7 #define ILNLEN 1000 /* line limit of input files */
9 #define MIN(a, b) ((a) < (b) ? (a) : (b))
10 #define MAX(a, b) ((a) < (b) ? (b) : (a))
11 #define LEN(a) (sizeof(a) / sizeof((a)[0]))
13 /* device related variables */
14 extern int dev_res;
15 extern int dev_uwid;
16 extern int dev_hor;
17 extern int dev_ver;
19 struct glyph {
20 char id[GNLEN]; /* device-dependent glyph identifier */
21 char name[GNLEN]; /* the first character mapped to this glyph */
22 struct font *font; /* glyph font */
23 int wid; /* character width */
24 int type; /* character type; ascender/descender */
25 int pos; /* glyph code */
28 /* output device functions */
29 int dev_open(char *dir, char *dev);
30 void dev_close(void);
31 int dev_mnt(int pos, char *id, char *name);
32 struct font *dev_font(int fn);
33 int dev_fontid(struct font *fn);
34 struct glyph *dev_glyph(char *c, int fn);
35 struct font *dev_fontopen(char *name);
37 /* font-related functions */
38 struct font *font_open(char *path);
39 void font_close(struct font *fn);
40 struct glyph *font_glyph(struct font *fn, char *id);
41 struct glyph *font_find(struct font *fn, char *name);
42 int font_wid(struct font *fn, int sz, int w);
43 int font_swid(struct font *fn, int sz);
44 char *font_name(struct font *fn);
45 char *font_path(struct font *fn);
46 int font_glnum(struct font *fn, struct glyph *g);
47 struct glyph *font_glget(struct font *fn, int id);
48 char *font_desc(struct font *fn);
50 /* output functions */
51 void out(char *s, ...);
52 void outc(char *s);
53 void outh(int h);
54 void outv(int v);
55 void outrel(int h, int v);
56 void outfont(int f);
57 void outsize(int s);
58 void outcolor(int c);
59 void outrotate(int deg);
60 void outeps(char *eps, int hwid, int vwid);
61 void outpdf(char *pdf, int hwid, int vwid);
62 void outlink(char *dst, int hwid, int vwid);
63 void outmark(int n, char (*desc)[256], int *page, int *off, int *level);
64 void outname(int n, char (*desc)[64], int *page, int *off);
65 void outinfo(char *kwd, char *val);
66 void outset(char *var, char *val);
67 void outpage(void);
68 void outmnt(int f);
69 void outgname(int g);
71 void drawbeg(void);
72 void drawend(int close, int fill);
73 void drawmbeg(char *s);
74 void drawmend(char *s);
75 void drawl(int h, int v);
76 void drawc(int c);
77 void drawe(int h, int v);
78 void drawa(int h1, int v1, int h2, int v2);
79 void draws(int h1, int v1, int h2, int v2);
81 void docheader(char *title, int pagewidth, int pageheight, int linewidth);
82 void doctrailer(int pages);
83 void docpagebeg(int n);
84 void docpageend(int n);
86 /* colors */
87 #define CLR_R(c) (((c) >> 16) & 0xff)
88 #define CLR_G(c) (((c) >> 8) & 0xff)
89 #define CLR_B(c) ((c) & 0xff)
90 #define CLR_RGB(r, g, b) (((r) << 16) | ((g) << 8) | (b))
92 char *clr_str(int c);
93 int clr_get(char *s);
95 /* mapping integers to sets */
96 struct iset *iset_make(void);
97 void iset_free(struct iset *iset);
98 int *iset_get(struct iset *iset, int key);
99 void iset_put(struct iset *iset, int key, int ent);
100 int iset_len(struct iset *iset, int key);
102 /* mapping strings to longs */
103 struct dict *dict_make(int notfound, int dupkeys, int hashlen);
104 void dict_free(struct dict *d);
105 void dict_put(struct dict *d, char *key, int val);
106 int dict_get(struct dict *d, char *key);
107 int dict_idx(struct dict *d, char *key);
108 char *dict_key(struct dict *d, int idx);
109 int dict_val(struct dict *d, int idx);
110 int dict_prefix(struct dict *d, char *key, int *idx);
112 /* memory allocation */
113 void *mextend(void *old, long oldsz, long newsz, int memsz);
114 /* helper functions */
115 char *pdftext_static(char *s);
117 /* string buffers */
118 struct sbuf *sbuf_make(void);
119 char *sbuf_buf(struct sbuf *sb);
120 char *sbuf_done(struct sbuf *sb);
121 void sbuf_free(struct sbuf *sb);
122 int sbuf_len(struct sbuf *sbuf);
123 void sbuf_str(struct sbuf *sbuf, char *s);
124 void sbuf_printf(struct sbuf *sbuf, char *s, ...);
125 void sbuf_chr(struct sbuf *sbuf, int c);
126 void sbuf_mem(struct sbuf *sbuf, char *s, int len);
127 void sbuf_cut(struct sbuf *sb, int len);
129 /* reading PDF files */
130 int pdf_ws(char *pdf, int len, int pos);
131 int pdf_len(char *pdf, int len, int pos);
132 int pdf_type(char *pdf, int len, int pos);
133 int pdf_dval(char *pdf, int len, int pos, char *key);
134 int pdf_dkey(char *pdf, int len, int pos, int key);
135 int pdf_lval(char *pdf, int len, int pos, int idx);
136 int pdf_trailer(char *pdf, int len);
137 int pdf_obj(char *pdf, int len, int pos, int *obj, int *rev);
138 int pdf_find(char *pdf, int len, int obj, int rev);
139 int pdf_ref(char *pdf, int len, int pos);
140 int pdf_dval_val(char *pdf, int len, int pos, char *key);
141 int pdf_dval_obj(char *pdf, int len, int pos, char *key);