-
Notifications
You must be signed in to change notification settings - Fork 0
/
fasttext.h
122 lines (92 loc) · 2.96 KB
/
fasttext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include "fcgi_stdio.h"
//#include <stdio.h>
#include <string.h>
#include <math.h>
#include <time.h>
#include <sys/dir.h>
#include <sys/param.h>
#include <sys/errno.h>
#include <cairo.h>
#include <cairo-ft.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include "qs_parse/qs_parse.h"
#include "simplehash/hash.h"
#ifndef __TEXTRENDER_H_
#define __TEXTRENDER_H_
#define MAX_TEXT_LEN 255
#define MAX_FONT_NAME_LEN 255
#define MAX_HELP_LEN 511
#define MAX_FONT_SIZE 1440.0 /* in points; 2 inches */
#define MAX_WIDTH 2000
#define MAX_HEIGHT 2000
// the following are "parameter" defaults. Some are sentinels
// that trigger dynamically generated default values
#define _DEFAULT_FONT "__tuffy"
#define _DEFAULT_FONT_SIZE 12.0
#define _DEFAULT_THETA 0.0
#define _DEFAULT_WIDTH 0 /* sentinel */
#define _DEFAULT_HEIGHT 0 /* sentinel */
#define _DEFAULT_X 0.0
#define _DEFAULT_Y 9876.1234 /* sentinel */
// default text == opaque black
#define _DEFAULT_R 0
#define _DEFAULT_G 0
#define _DEFAULT_B 0
#define _DEFAULT_A 1.0
// default text == transparent black
#define _DEFAULT_BGR 0.0
#define _DEFAULT_BGG 0.0
#define _DEFAULT_BGB 0.0
#define _DEFAULT_BGA 0.0
// lots of systems define ABS/MIN/MAX/CLAMP, so they get wrapped in ifdefs
#ifndef ABS
#define ABS(a) (((a) < 0) ? -(a) : (a))
#endif
#ifndef MIN
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef MAX
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef CLAMP
#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
#endif
typedef struct
{
char * text;
char * font;
char * help;
char * fmt;
double size;
double th; // theta, angle of rotation
int w, h;
double x, y;
double r, g, b, a;
double bgr, bgg, bgb, bga;
} tr_params;
typedef struct
{
FT_Face * ftface;
cairo_font_face_t * cface;
} fontface;
char usage[] = "Usage:\n\nYou must use parameters";
char font_example[] = "1234567890. The Quick Brown Fox Jumped Over The Lazy Dog.";
unsigned char nullpng[] = {0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a,
0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x01, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1f, 0x15, 0xc4,
0x89, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9c, 0x63,
0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x01, 0x0d, 0x0a, 0x2d, 0xb4, 0x00,
0x00, 0x00, 0x00, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82};
int draw(tr_params * render);
int calc_canvas_size(tr_params * render, int * w, int * h);
static cairo_status_t FCGI_cairo_write_stream (void * in_closure, const unsigned char *data, unsigned int length);
inline double qs2d(char * qs, double def);
inline long qs2l(char * qs, long def);
int relative_dir(struct direct *e);
int scanfont(char * font_dir, char ** files);
int addfont(char * filepath, char * key);
void show_fonts(hash_entry h[]);
int get_params(char * qs, tr_params * render);
char * help_text(tr_params * render);
#endif // __TEXTRENDER_H_