aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
blob: e643477a7f10a3e81c32523990af94a0a1038f3d (plain) (blame)
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
#include "libskrift.h"

#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <alloca.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <poll.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#include <schrift.h>
#include <grapheme.h>

#define MIN(A, B) ((A) < (B) ? (A) : (B))
#define MAX(A, B) ((A) > (B) ? (A) : (B))

#define ELEMSOF(ARR) (sizeof(ARR) / sizeof(*(ARR)))

#define FLEXSTRUCTSIZE(STRUCT, FLEXARRAY, FLEXARRAY_LENGTH)\
	(offsetof(STRUCT, FLEXARRAY) + (FLEXARRAY_LENGTH) * sizeof(*((STRUCT *)NULL)->FLEXARRAY))

enum font_type {
	FONT_TYPE_SCHRIFT /* using libschrift backend */
};

struct libskrift_font {
	enum font_type    font_type;
	union {
		void         *any;
		SFT_Font     *schrift;
	}                 font;
	void             *memory_free;
	void             *memory_unmap;
	size_t            memory_size;
	size_t            refcount;
};

struct libskrift_context {
	struct libskrift_rendering rendering;
	struct SFT                 schrift_ctx;
	char                       subpixel_horizontally;
	char                       subpixel_vertically;
	char                       subpixel_bgr;
	double                     char_x_advancement;
	double                     char_y_advancement;
	double                     text_x_advancement;
	double                     text_y_advancement;
	double                     transformation[6];
	size_t                     nfonts;
	LIBSKRIFT_FONT            *fonts[];
};

struct format_settings {
	int    float_type;
	int8_t apos;
	int8_t rpos;
	int8_t gpos;
	int8_t bpos;
	size_t spsize;
};

extern const struct format_settings libskrift_format_settings[LIBSKRIFT_RGBA_LONG_DOUBLE + 1];

int libskrift_open_font___(LIBSKRIFT_FONT **fontp, const void *mem_static, void *mem_free, void *mem_unmap, size_t size);