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
|
/*
* This file is part of RUfl
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license
* Copyright 2005 James Bursa <james@semichrome.net>
*/
#include <stdbool.h>
#include <stdlib.h>
#include "oslib/os.h"
/** Return code for RUfl functions. */
typedef enum {
/** Success. */
rufl_OK,
/** Failure: memory was exhausted. */
rufl_OUT_OF_MEMORY,
/** Failure: Font Manager error; details in rufl_fm_error. */
rufl_FONT_MANAGER_ERROR,
/** Failure: no font with this name exists. */
rufl_FONT_NOT_FOUND,
/** Failure: file input / output error: details in errno. */
rufl_IO_ERROR,
/** Failure: file input unexpected eof. */
rufl_IO_EOF,
} rufl_code;
typedef enum {
rufl_REGULAR,
rufl_SLANTED,
rufl_BOLD,
rufl_BOLD_SLANTED,
} rufl_style;
/** Last Font Manager error. */
extern os_error *rufl_fm_error;
/** List of available font families. */
extern char **rufl_family_list;
/** Number of entries in rufl_family_list. */
extern unsigned int rufl_family_list_entries;
/**
* Initialise RUfl.
*
* All available fonts are scanned. May take some time.
*/
rufl_code rufl_init(void);
/**
* Render Unicode text.
*/
rufl_code rufl_paint(const char *font_family, rufl_style font_style,
unsigned int font_size,
const char *string, size_t length,
int x, int y);
/**
* Measure the width of Unicode text.
*/
rufl_code rufl_width(const char *font_family, rufl_style font_style,
unsigned int font_size,
const char *string, size_t length,
int *width);
/**
* Find where in a string a x coordinate falls.
*/
rufl_code rufl_x_to_offset(const char *font_family, rufl_style font_style,
unsigned int font_size,
const char *string, size_t length,
int click_x,
size_t *char_offset, int *actual_x);
/**
* Dump the internal library state to stdout.
*/
void rufl_dump_state(void);
/**
* Free all resources used by the library.
*/
void rufl_quit(void);
|