summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/rufl.h36
-rw-r--r--src/rufl_decompose.c2
-rw-r--r--src/rufl_init.c4
-rw-r--r--src/rufl_metrics.c16
-rw-r--r--src/rufl_paint.c48
-rw-r--r--test/rufl_chars.c2
-rw-r--r--test/rufl_test.c16
7 files changed, 66 insertions, 58 deletions
diff --git a/include/rufl.h b/include/rufl.h
index 15e889e..bb44e49 100644
--- a/include/rufl.h
+++ b/include/rufl.h
@@ -8,6 +8,7 @@
#ifndef RUFL_H
#define RUFL_H
+#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include "oslib/os.h"
@@ -53,7 +54,7 @@ extern os_error *rufl_fm_error;
/** List of available font families. */
extern const char **rufl_family_list;
/** Number of entries in rufl_family_list. */
-extern unsigned int rufl_family_list_entries;
+extern size_t rufl_family_list_entries;
/** Menu of font families. */
extern void *rufl_family_menu;
@@ -85,7 +86,7 @@ rufl_code rufl_init(void);
rufl_code rufl_paint(const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string, size_t length,
+ const uint8_t *string, size_t length,
int x, int y, unsigned int flags);
@@ -95,7 +96,7 @@ rufl_code rufl_paint(const char *font_family, rufl_style font_style,
rufl_code rufl_width(const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string, size_t length,
+ const uint8_t *string, size_t length,
int *width);
@@ -105,7 +106,7 @@ rufl_code rufl_width(const char *font_family, rufl_style font_style,
rufl_code rufl_x_to_offset(const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string, size_t length,
+ const uint8_t *string, size_t length,
int click_x,
size_t *char_offset, int *actual_x);
@@ -116,7 +117,7 @@ rufl_code rufl_x_to_offset(const char *font_family, rufl_style font_style,
rufl_code rufl_split(const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string, size_t length,
+ const uint8_t *string, size_t length,
int width,
size_t *char_offset, int *actual_x);
@@ -124,7 +125,7 @@ rufl_code rufl_split(const char *font_family, rufl_style font_style,
/** Type of callback function for rufl_paint_callback(). */
typedef void (*rufl_callback_t)(void *context,
const char *font_name, unsigned int font_size,
- const char *s8, unsigned int *s32, unsigned int n,
+ const uint8_t *s8, const uint32_t *s32, unsigned int n,
int x, int y);
@@ -134,7 +135,7 @@ typedef void (*rufl_callback_t)(void *context,
rufl_code rufl_paint_callback(const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string, size_t length,
+ const uint8_t *string, size_t length,
int x, int y,
rufl_callback_t callback, void *context);
@@ -145,7 +146,7 @@ rufl_code rufl_paint_callback(const char *font_family, rufl_style font_style,
rufl_code rufl_decompose_glyph(const char *font_family,
rufl_style font_style, unsigned int font_size,
- const char *string, size_t length,
+ const uint8_t *string, size_t length,
struct rufl_decomp_funcs *funcs, void *user);
@@ -154,10 +155,10 @@ rufl_code rufl_decompose_glyph(const char *font_family,
*/
rufl_code rufl_font_metrics(const char *font_family, rufl_style font_style,
- os_box *bbox, int *xkern, int *ykern, int *italic,
- int *ascent, int *descent,
- int *xheight, int *cap_height,
- signed char *uline_position, unsigned char *uline_thickness);
+ os_box *bbox, int32_t *xkern, int32_t *ykern, int32_t *italic,
+ int32_t *ascent, int32_t *descent,
+ int32_t *xheight, int32_t *cap_height,
+ int8_t *uline_position, uint8_t *uline_thickness);
/**
@@ -166,10 +167,10 @@ rufl_code rufl_font_metrics(const char *font_family, rufl_style font_style,
rufl_code rufl_glyph_metrics(const char *font_family,
rufl_style font_style, unsigned int font_size,
- const char *string, size_t length,
- int *x_bearing, int *y_bearing,
- int *width, int *height,
- int *x_advance, int *y_advance);
+ const uint8_t *string, size_t length,
+ int32_t *x_bearing, int32_t *y_bearing,
+ int32_t *width, int32_t *height,
+ int32_t *x_advance, int32_t *y_advance);
/**
@@ -177,8 +178,7 @@ rufl_code rufl_glyph_metrics(const char *font_family,
*/
rufl_code rufl_font_bbox(const char *font_family, rufl_style font_style,
- unsigned int font_size,
- int *bbox);
+ unsigned int font_size, os_box *bbox);
/**
diff --git a/src/rufl_decompose.c b/src/rufl_decompose.c
index 2085e8f..0e9f6ea 100644
--- a/src/rufl_decompose.c
+++ b/src/rufl_decompose.c
@@ -67,7 +67,7 @@ static int *process_path(int *path, struct rufl_decomp_funcs *funcs,
rufl_code rufl_decompose_glyph(const char *font_family,
rufl_style font_style, unsigned int font_size,
- const char *string, size_t len,
+ const uint8_t *string, size_t len,
struct rufl_decomp_funcs *funcs, void *user)
{
int *buf, *p, *ep;
diff --git a/src/rufl_init.c b/src/rufl_init.c
index 6cf0be6..e5ce5e5 100644
--- a/src/rufl_init.c
+++ b/src/rufl_init.c
@@ -29,7 +29,7 @@
struct rufl_font_list_entry *rufl_font_list = 0;
size_t rufl_font_list_entries = 0;
const char **rufl_family_list = 0;
-unsigned int rufl_family_list_entries = 0;
+size_t rufl_family_list_entries = 0;
struct rufl_family_map_entry *rufl_family_map = 0;
os_error *rufl_fm_error = 0;
void *rufl_family_menu = 0;
@@ -180,7 +180,7 @@ rufl_code rufl_init(void)
xhourglass_off();
return code;
}
- LOG("%zu faces, %u families", rufl_font_list_entries,
+ LOG("%zu faces, %zu families", rufl_font_list_entries,
rufl_family_list_entries);
code = rufl_load_cache();
diff --git a/src/rufl_metrics.c b/src/rufl_metrics.c
index 0637ddb..876ac53 100644
--- a/src/rufl_metrics.c
+++ b/src/rufl_metrics.c
@@ -19,10 +19,10 @@ static int rufl_unicode_map_search_cmp(const void *keyval, const void *datum);
* Read a font's metrics (sized for a 1pt font)
*/
rufl_code rufl_font_metrics(const char *font_family, rufl_style font_style,
- os_box *bbox, int *xkern, int *ykern, int *italic,
- int *ascent, int *descent,
- int *xheight, int *cap_height,
- signed char *uline_position, unsigned char *uline_thickness)
+ os_box *bbox, int32_t *xkern, int32_t *ykern, int32_t *italic,
+ int32_t *ascent, int32_t *descent,
+ int32_t *xheight, int32_t *cap_height,
+ int8_t *uline_position, uint8_t *uline_thickness)
{
unsigned int font;
font_f f;
@@ -114,10 +114,10 @@ rufl_code rufl_font_metrics(const char *font_family, rufl_style font_style,
*/
rufl_code rufl_glyph_metrics(const char *font_family,
rufl_style font_style, unsigned int font_size,
- const char *string, size_t length,
- int *x_bearing, int *y_bearing,
- int *width, int *height,
- int *x_advance, int *y_advance)
+ const uint8_t *string, size_t length,
+ int32_t *x_bearing, int32_t *y_bearing,
+ int32_t *width, int32_t *height,
+ int32_t *x_advance, int32_t *y_advance)
{
const char *font_encoding = NULL;
unsigned int font, font1, u;
diff --git a/src/rufl_paint.c b/src/rufl_paint.c
index 360baec..06ed509 100644
--- a/src/rufl_paint.c
+++ b/src/rufl_paint.c
@@ -27,7 +27,7 @@ static const os_trfm trfm_oblique =
static rufl_code rufl_process(rufl_action action,
const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string0, size_t length,
+ const uint8_t *string0, size_t length,
int x, int y, unsigned int flags,
int *width, int click_x, size_t *char_offset, int *actual_x,
rufl_callback_t callback, void *context);
@@ -58,7 +58,7 @@ static rufl_code rufl_process_not_available(rufl_action action,
rufl_code rufl_paint(const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string, size_t length,
+ const uint8_t *string, size_t length,
int x, int y, unsigned int flags)
{
return rufl_process(rufl_PAINT,
@@ -73,7 +73,7 @@ rufl_code rufl_paint(const char *font_family, rufl_style font_style,
rufl_code rufl_width(const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string, size_t length,
+ const uint8_t *string, size_t length,
int *width)
{
return rufl_process(rufl_WIDTH,
@@ -89,7 +89,7 @@ rufl_code rufl_width(const char *font_family, rufl_style font_style,
rufl_code rufl_x_to_offset(const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string, size_t length,
+ const uint8_t *string, size_t length,
int click_x,
size_t *char_offset, int *actual_x)
{
@@ -106,7 +106,7 @@ rufl_code rufl_x_to_offset(const char *font_family, rufl_style font_style,
rufl_code rufl_split(const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string, size_t length,
+ const uint8_t *string, size_t length,
int width,
size_t *char_offset, int *actual_x)
{
@@ -123,7 +123,7 @@ rufl_code rufl_split(const char *font_family, rufl_style font_style,
rufl_code rufl_paint_callback(const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string, size_t length,
+ const uint8_t *string, size_t length,
int x, int y,
rufl_callback_t callback, void *context)
{
@@ -139,11 +139,11 @@ rufl_code rufl_paint_callback(const char *font_family, rufl_style font_style,
rufl_code rufl_font_bbox(const char *font_family, rufl_style font_style,
unsigned int font_size,
- int *bbox)
+ os_box *bbox)
{
return rufl_process(rufl_FONT_BBOX,
font_family, font_style, font_size, 0,
- 0, 0, 0, 0, bbox, 0, 0, 0, 0, 0);
+ 0, 0, 0, 0, (int *) bbox, 0, 0, 0, 0, 0);
}
@@ -154,7 +154,7 @@ rufl_code rufl_font_bbox(const char *font_family, rufl_style font_style,
rufl_code rufl_process(rufl_action action,
const char *font_family, rufl_style font_style,
unsigned int font_size,
- const char *string0, size_t length,
+ const uint8_t *string0, size_t length,
int x, int y, unsigned int flags,
int *width, int click_x, size_t *char_offset, int *actual_x,
rufl_callback_t callback, void *context)
@@ -168,7 +168,7 @@ rufl_code rufl_process(rufl_action action,
size_t offset_u;
size_t offset_map[rufl_PROCESS_CHUNK];
unsigned int slant;
- const char *string = string0;
+ const uint8_t *string = string0;
struct rufl_character_set *charset;
rufl_code code;
@@ -310,7 +310,9 @@ rufl_code rufl_process_span(rufl_action action,
return code;
if (action == rufl_FONT_BBOX) {
- rufl_fm_error = xfont_read_info(f, &x[0], &x[1], &x[2], &x[3]);
+ os_box *bbox = (os_box *) x;
+ rufl_fm_error = xfont_read_info(f, &bbox->x0, &bbox->y0,
+ &bbox->x1, &bbox->y1);
if (rufl_fm_error)
return rufl_FONT_MANAGER_ERROR;
return rufl_OK;
@@ -385,7 +387,7 @@ rufl_code rufl_process_span_old(rufl_action action,
int click_x, size_t *offset,
rufl_callback_t callback, void *context)
{
- char s2[rufl_PROCESS_CHUNK];
+ uint8_t s2[rufl_PROCESS_CHUNK];
char *split_point;
int x_out, y_out;
unsigned int i;
@@ -394,12 +396,15 @@ rufl_code rufl_process_span_old(rufl_action action,
rufl_code code;
if (action == rufl_FONT_BBOX) {
+ os_box *bbox = (os_box *) x;
+
/* Don't need encoding for bounding box */
code = rufl_find_font(font, font_size, NULL, &f);
if (code != rufl_OK)
return code;
- rufl_fm_error = xfont_read_info(f, &x[0], &x[1], &x[2], &x[3]);
+ rufl_fm_error = xfont_read_info(f, &bbox->x0, &bbox->y0,
+ &bbox->x1, &bbox->y1);
if (rufl_fm_error) {
LOG("xfont_read_info: 0x%x: %s",
rufl_fm_error->errnum,
@@ -462,7 +467,8 @@ rufl_code rufl_process_span_old(rufl_action action,
return rufl_FONT_MANAGER_ERROR;
}
- rufl_fm_error = xfont_paint(f, s2, font_OS_UNITS |
+ rufl_fm_error = xfont_paint(f, (char *) s2,
+ font_OS_UNITS |
(oblique ? font_GIVEN_TRFM : 0) |
font_GIVEN_LENGTH | font_GIVEN_FONT |
font_KERN |
@@ -492,7 +498,7 @@ rufl_code rufl_process_span_old(rufl_action action,
/* increment x by width of span */
if (action == rufl_X_TO_OFFSET || action == rufl_SPLIT) {
- rufl_fm_error = xfont_scan_string(f, s2,
+ rufl_fm_error = xfont_scan_string(f, (char *) s2,
font_GIVEN_LENGTH | font_GIVEN_FONT |
font_KERN |
((action == rufl_X_TO_OFFSET) ?
@@ -500,9 +506,9 @@ rufl_code rufl_process_span_old(rufl_action action,
(click_x - *x) * 400, 0x7fffffff,
0, 0, i,
&split_point, &x_out, &y_out, 0);
- *offset += split_point - s2;
+ *offset += split_point - (char *) s2;
} else {
- rufl_fm_error = xfont_scan_string(f, s2,
+ rufl_fm_error = xfont_scan_string(f, (char *) s2,
font_GIVEN_LENGTH | font_GIVEN_FONT |
font_KERN,
0x7fffffff, 0x7fffffff, 0, 0, i,
@@ -548,7 +554,7 @@ rufl_code rufl_process_not_available(rufl_action action,
int click_x, size_t *offset,
rufl_callback_t callback, void *context)
{
- char missing[] = "000000";
+ uint8_t missing[] = "000000";
const int dx = 7 * font_size / 64;
const int dx3 = 10.5 * font_size / 64;
int top_y = y + 5 * font_size / 64;
@@ -589,7 +595,8 @@ rufl_code rufl_process_not_available(rufl_action action,
/* first two characters in top row */
if (action == rufl_PAINT) {
- rufl_fm_error = xfont_paint(f, missing + offset,
+ rufl_fm_error = xfont_paint(f,
+ (char *) (missing + offset),
font_OS_UNITS | font_GIVEN_LENGTH |
font_GIVEN_FONT | font_KERN |
((flags & rufl_BLEND_FONT) ?
@@ -605,7 +612,8 @@ rufl_code rufl_process_not_available(rufl_action action,
/* last two characters underneath */
if (action == rufl_PAINT) {
- rufl_fm_error = xfont_paint(f, missing + offset + step,
+ rufl_fm_error = xfont_paint(f,
+ (char *) (missing + offset + step),
font_OS_UNITS |
font_GIVEN_LENGTH | font_GIVEN_FONT |
font_KERN |
diff --git a/test/rufl_chars.c b/test/rufl_chars.c
index 1df86e3..fd0365c 100644
--- a/test/rufl_chars.c
+++ b/test/rufl_chars.c
@@ -262,7 +262,7 @@ int main(void)
rufl_code redraw(int x, int y, int y0, int y1)
{
- char s[10];
+ uint8_t s[10];
unsigned int l;
unsigned int u;
rufl_code code;
diff --git a/test/rufl_test.c b/test/rufl_test.c
index 5b76f81..3edbcf1 100644
--- a/test/rufl_test.c
+++ b/test/rufl_test.c
@@ -18,13 +18,13 @@ static int cubic_to(os_coord *control1, os_coord *control2, os_coord *to,
void *user);
static void callback(void *context,
const char *font_name, unsigned int font_size,
- const char *s8, unsigned int *s32, unsigned int n,
+ const uint8_t *s8, const uint32_t *s32, unsigned int n,
int x, int y);
int main(void)
{
- char utf8_test[] = "Hello, world! ὕαλον "
+ const uint8_t utf8_test[] = "Hello, world! ὕαλον "
"Uherské Hradiště. 𐀀"
"\xf0\xa0\x80\xa1";
int width;
@@ -32,7 +32,7 @@ int main(void)
int x;
int actual_x;
struct rufl_decomp_funcs funcs = { move_to, line_to, cubic_to };
- int bbox[4];
+ os_box bbox;
try(rufl_init(), "rufl_init");
rufl_dump_state(false);
@@ -58,14 +58,14 @@ int main(void)
char_offset, utf8_test + char_offset);
}
try(rufl_decompose_glyph("Homerton", rufl_WEIGHT_400, 1280,
- "A", 1, &funcs, 0),
+ (const uint8_t *) "A", 1, &funcs, 0),
"rufl_decompose_glyph");
try(rufl_paint_callback("NewHall", rufl_WEIGHT_400, 240,
utf8_test, sizeof utf8_test - 1,
1200, 1000, callback, 0), "rufl_paint_callback");
- try(rufl_font_bbox("NewHall", rufl_WEIGHT_400, 240, bbox),
+ try(rufl_font_bbox("NewHall", rufl_WEIGHT_400, 240, &bbox),
"rufl_font_bbox");
- printf("bbox: %i %i %i %i\n", bbox[0], bbox[1], bbox[2], bbox[3]);
+ printf("bbox: %i %i %i %i\n", bbox.x0, bbox.y0, bbox.x1, bbox.y1);
rufl_quit();
return 0;
@@ -132,7 +132,7 @@ int cubic_to(os_coord *control1, os_coord *control2, os_coord *to,
void callback(void *context,
const char *font_name, unsigned int font_size,
- const char *s8, unsigned int *s32, unsigned int n,
+ const uint8_t *s8, const uint32_t *s32, unsigned int n,
int x, int y)
{
(void) context;
@@ -141,7 +141,7 @@ void callback(void *context,
if (s8)
printf("s8 \"%.*s\" ", n, s8);
else {
- printf("s16 \"");
+ printf("s32 \"");
for (unsigned int i = 0; i != n; i++)
printf("%x ", (unsigned int) s32[i]);
printf("\" ");