Gitweb links:
...log
http://git.netsurf-browser.org/librufl.git/shortlog/769b9ee5c1a1a70a0a75a78269ccabb2b7591832
...commit
http://git.netsurf-browser.org/librufl.git/commit/769b9ee5c1a1a70a0a75a78269ccabb2b7591832
...tree
http://git.netsurf-browser.org/librufl.git/tree/769b9ee5c1a1a70a0a75a78269ccabb2b7591832
The branch, jmb/ac has been updated
via 769b9ee5c1a1a70a0a75a78269ccabb2b7591832 (commit)
via 7f5504490fb8fb7ba3916bef7882bd8860a5c0a5 (commit)
from 7324abb6b05b6f6703667b39f736d6d958cb9460 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff
http://git.netsurf-browser.org/librufl.git/commit/?id=769b9ee5c1a1a70a0a75a78269ccabb2b7591832
commit 769b9ee5c1a1a70a0a75a78269ccabb2b7591832
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
Fix error conditions in broken FEC case
diff --git a/src/rufl_init.c b/src/rufl_init.c
index de3463a..6c06a8f 100644
--- a/src/rufl_init.c
+++ b/src/rufl_init.c
@@ -571,10 +571,14 @@ static rufl_code rufl_init_enumerate_characters(const
char *font_name,
rufl_fm_error->errmess);
return rufl_FONT_MANAGER_ERROR;
}
+ if (first == (unsigned int) -1) {
+ /* Font has no defined characters */
+ return rufl_OK;
+ }
/* Search the entire space up to the first codepoint it
* reported. */
- for (u = 1; u != (unsigned int) -1 && u != first; u++) {
+ for (u = 1; u != first; u++) {
rufl_fm_error = xfont_enumerate_characters(font, u,
(int *) &next, (int *) &internal);
if (rufl_fm_error) {
@@ -583,8 +587,7 @@ static rufl_code rufl_init_enumerate_characters(const char
*font_name,
font_name, u,
rufl_fm_error->errnum,
rufl_fm_error->errmess);
- result = rufl_FONT_MANAGER_ERROR;
- break;
+ return rufl_FONT_MANAGER_ERROR;
}
/* Skip unmapped characters */
@@ -594,7 +597,7 @@ static rufl_code rufl_init_enumerate_characters(const char
*font_name,
/* Character is mapped, emit it */
result = callback(pw, internal, u);
if (result != rufl_OK)
- break;
+ return result;
}
/* Now fall through to the normal path */
commitdiff
http://git.netsurf-browser.org/librufl.git/commit/?id=7f5504490fb8fb7ba3916bef7882bd8860a5c0a5
commit 7f5504490fb8fb7ba3916bef7882bd8860a5c0a5
Author: John-Mark Bell <[email protected]>
Commit: John-Mark Bell <[email protected]>
Partially revert public API type changes
a4c41198 made a variety of consistency changes to the public API,
including changing the type of the "string" parameter passed to
many entry points from const char * to const uint8_t *, as that
better reflects the data. However, this then forces the user of
the API to explicitly cast when passing string constants, or
other strings (which, would be passed to standard library APIs
as const char *, even if UTF-8 encoded).
Revert this part of the change so the type of "string" is once
more const char * and cast to the type we actually want internally.
diff --git a/include/rufl.h b/include/rufl.h
index bb44e49..e7d0987 100644
--- a/include/rufl.h
+++ b/include/rufl.h
@@ -86,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int x, int y, unsigned int flags);
@@ -96,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int *width);
@@ -106,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int click_x,
size_t *char_offset, int *actual_x);
@@ -117,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int width,
size_t *char_offset, int *actual_x);
@@ -135,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int x, int y,
rufl_callback_t callback, void *context);
@@ -146,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
struct rufl_decomp_funcs *funcs, void *user);
@@ -167,7 +167,7 @@ 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 uint8_t *string, size_t length,
+ const char *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);
diff --git a/src/rufl_decompose.c b/src/rufl_decompose.c
index 0e9f6ea..2085e8f 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 uint8_t *string, size_t len,
+ const char *string, size_t len,
struct rufl_decomp_funcs *funcs, void *user)
{
int *buf, *p, *ep;
diff --git a/src/rufl_metrics.c b/src/rufl_metrics.c
index 876ac53..bbfd6bb 100644
--- a/src/rufl_metrics.c
+++ b/src/rufl_metrics.c
@@ -114,11 +114,12 @@ 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 uint8_t *string, size_t length,
+ const char *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 uint8_t *ustring = (const uint8_t *) string;
const char *font_encoding = NULL;
unsigned int font, font1, u;
uint32_t u1[2];
@@ -136,7 +137,7 @@ rufl_code rufl_glyph_metrics(const char *font_family,
if (code != rufl_OK)
return code;
- rufl_utf8_read(string, length, u);
+ rufl_utf8_read(ustring, length, u);
if (charset && rufl_character_set_test(charset, u))
font1 = font;
else {
diff --git a/src/rufl_paint.c b/src/rufl_paint.c
index 06ed509..9dc0e3f 100644
--- a/src/rufl_paint.c
+++ b/src/rufl_paint.c
@@ -58,12 +58,13 @@ 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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int x, int y, unsigned int flags)
{
return rufl_process(rufl_PAINT,
- font_family, font_style, font_size, string,
- length, x, y, flags, 0, 0, 0, 0, 0, 0);
+ font_family, font_style, font_size,
+ (const uint8_t *) string, length,
+ x, y, flags, 0, 0, 0, 0, 0, 0);
}
@@ -73,12 +74,13 @@ 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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int *width)
{
return rufl_process(rufl_WIDTH,
- font_family, font_style, font_size, string,
- length, 0, 0, 0, width, 0, 0, 0, 0, 0);
+ font_family, font_style, font_size,
+ (const uint8_t *) string, length,
+ 0, 0, 0, width, 0, 0, 0, 0, 0);
}
@@ -89,14 +91,14 @@ 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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int click_x,
size_t *char_offset, int *actual_x)
{
return rufl_process(rufl_X_TO_OFFSET,
- font_family, font_style, font_size, string,
- length, 0, 0, 0, 0,
- click_x, char_offset, actual_x, 0, 0);
+ font_family, font_style, font_size,
+ (const uint8_t *) string, length,
+ 0, 0, 0, 0, click_x, char_offset, actual_x, 0, 0);
}
@@ -106,14 +108,14 @@ 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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int width,
size_t *char_offset, int *actual_x)
{
return rufl_process(rufl_SPLIT,
- font_family, font_style, font_size, string,
- length, 0, 0, 0, 0,
- width, char_offset, actual_x, 0, 0);
+ font_family, font_style, font_size,
+ (const uint8_t *) string, length,
+ 0, 0, 0, 0, width, char_offset, actual_x, 0, 0);
}
@@ -123,13 +125,14 @@ 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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int x, int y,
rufl_callback_t callback, void *context)
{
return rufl_process(rufl_PAINT_CALLBACK,
- font_family, font_style, font_size, string,
- length, x, y, 0, 0, 0, 0, 0, callback, context);
+ font_family, font_style, font_size,
+ (const uint8_t *) string, length,
+ x, y, 0, 0, 0, 0, 0, callback, context);
}
diff --git a/test/oldfminit.c b/test/oldfminit.c
index b545e9a..c554499 100644
--- a/test/oldfminit.c
+++ b/test/oldfminit.c
@@ -287,13 +287,12 @@ int main(int argc, const char **argv)
assert(0 == uline_thickness);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, &width));
+ "!\xc2\xa0", 3, &width));
assert(50 == width);
/* Place caret after first character */
assert(rufl_OK == rufl_x_to_offset("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(1 == offset);
assert(25 == x);
@@ -301,17 +300,16 @@ int main(int argc, const char **argv)
* coincident with the start of the second character, however,
* the split point is placed after it. */
assert(rufl_OK == rufl_split("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(3 == offset);
assert(50 == x);
/* Compute width of replacement character */
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xef\xbf\xbd", 3, &width));
+ "\xef\xbf\xbd", 3, &width));
assert(17 == width);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xf0\xa0\x80\xa5", 4, &width));
+ "\xf0\xa0\x80\xa5", 4, &width));
assert(26 == width);
/* Measure font bounding box */
@@ -324,13 +322,13 @@ int main(int argc, const char **argv)
/* Trivial render */
assert(rufl_OK == rufl_paint("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 0, 0, 0));
+ "!\xc2\xa0", 3, 0, 0, 0));
rufl_dump_state(true);
/* Obtain metrics for a glyph */
assert(rufl_OK == rufl_glyph_metrics("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!", 1, &x_bearing, &y_bearing,
+ "!", 1, &x_bearing, &y_bearing,
&mwidth, &mheight, &x_advance, &y_advance));
assert(0 == x_bearing);
assert(10000 == y_bearing);
diff --git a/test/olducsinit.c b/test/olducsinit.c
index 208484e..ed3d846 100644
--- a/test/olducsinit.c
+++ b/test/olducsinit.c
@@ -74,13 +74,12 @@ int main(int argc, const char **argv)
assert(0 == uline_thickness);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, &width));
+ "!\xc2\xa0", 3, &width));
assert(50 == width);
/* Place caret after first character */
assert(rufl_OK == rufl_x_to_offset("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(1 == offset);
assert(25 == x);
@@ -88,17 +87,16 @@ int main(int argc, const char **argv)
* coincident with the start of the second character, however,
* the split point is placed after it. */
assert(rufl_OK == rufl_split("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(3 == offset);
assert(50 == x);
/* Compute width of replacement character */
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xef\xbf\xbd", 3, &width));
+ "\xef\xbf\xbd", 3, &width));
assert(17 == width);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xf0\xa0\x80\xa5", 4, &width));
+ "\xf0\xa0\x80\xa5", 4, &width));
assert(26 == width);
/* Measure font bounding box */
@@ -111,11 +109,11 @@ int main(int argc, const char **argv)
/* Trivial render */
assert(rufl_OK == rufl_paint("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 0, 0, 0));
+ "!\xc2\xa0", 3, 0, 0, 0));
/* Obtain metrics for a glyph */
assert(rufl_OK == rufl_glyph_metrics("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!", 1, &x_bearing, &y_bearing,
+ "!", 1, &x_bearing, &y_bearing,
&mwidth, &mheight, &x_advance, &y_advance));
assert(0 == x_bearing);
assert(10000 == y_bearing);
diff --git a/test/rufl_chars.c b/test/rufl_chars.c
index 0559d4e..64831ad 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)
{
- uint8_t s[10];
+ char s[10];
unsigned int l;
unsigned int u;
rufl_code code;
diff --git a/test/rufl_test.c b/test/rufl_test.c
index 3edbcf1..bc644f5 100644
--- a/test/rufl_test.c
+++ b/test/rufl_test.c
@@ -24,7 +24,7 @@ static void callback(void *context,
int main(void)
{
- const uint8_t utf8_test[] = "Hello, world! ὕαλον "
+ const char utf8_test[] = "Hello, world! ὕαλον "
"Uherské Hradiště. 𐀀"
"\xf0\xa0\x80\xa1";
int width;
@@ -58,7 +58,7 @@ int main(void)
char_offset, utf8_test + char_offset);
}
try(rufl_decompose_glyph("Homerton", rufl_WEIGHT_400, 1280,
- (const uint8_t *) "A", 1, &funcs, 0),
+ "A", 1, &funcs, 0),
"rufl_decompose_glyph");
try(rufl_paint_callback("NewHall", rufl_WEIGHT_400, 240,
utf8_test, sizeof utf8_test - 1,
diff --git a/test/ucsinit.c b/test/ucsinit.c
index 45197a0..25aea60 100644
--- a/test/ucsinit.c
+++ b/test/ucsinit.c
@@ -74,13 +74,12 @@ int main(int argc, const char **argv)
assert(0 == uline_thickness);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, &width));
+ "!\xc2\xa0", 3, &width));
assert(50 == width);
/* Place caret after first character */
assert(rufl_OK == rufl_x_to_offset("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(1 == offset);
assert(25 == x);
@@ -88,17 +87,16 @@ int main(int argc, const char **argv)
* coincident with the start of the second character, however,
* the split point is placed after it. */
assert(rufl_OK == rufl_split("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(3 == offset);
assert(50 == x);
/* Compute width of replacement character */
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xef\xbf\xbd", 3, &width));
+ "\xef\xbf\xbd", 3, &width));
assert(17 == width);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xf0\xa0\x80\xa5", 4, &width));
+ "\xf0\xa0\x80\xa5", 4, &width));
assert(26 == width);
/* Measure font bounding box */
@@ -111,11 +109,11 @@ int main(int argc, const char **argv)
/* Trivial render */
assert(rufl_OK == rufl_paint("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 0, 0, 0));
+ "!\xc2\xa0", 3, 0, 0, 0));
/* Obtain metrics for a glyph */
assert(rufl_OK == rufl_glyph_metrics("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!", 1, &x_bearing, &y_bearing,
+ "!", 1, &x_bearing, &y_bearing,
&mwidth, &mheight, &x_advance, &y_advance));
assert(0 == x_bearing);
assert(10000 == y_bearing);
-----------------------------------------------------------------------
Summary of changes:
include/rufl.h | 14 +++++++-------
src/rufl_decompose.c | 2 +-
src/rufl_init.c | 11 +++++++----
src/rufl_metrics.c | 5 +++--
src/rufl_paint.c | 37 ++++++++++++++++++++-----------------
test/oldfminit.c | 16 +++++++---------
test/olducsinit.c | 16 +++++++---------
test/rufl_chars.c | 2 +-
test/rufl_test.c | 4 ++--
test/ucsinit.c | 16 +++++++---------
10 files changed, 62 insertions(+), 61 deletions(-)
diff --git a/include/rufl.h b/include/rufl.h
index bb44e49..e7d0987 100644
--- a/include/rufl.h
+++ b/include/rufl.h
@@ -86,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int x, int y, unsigned int flags);
@@ -96,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int *width);
@@ -106,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int click_x,
size_t *char_offset, int *actual_x);
@@ -117,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int width,
size_t *char_offset, int *actual_x);
@@ -135,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int x, int y,
rufl_callback_t callback, void *context);
@@ -146,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 uint8_t *string, size_t length,
+ const char *string, size_t length,
struct rufl_decomp_funcs *funcs, void *user);
@@ -167,7 +167,7 @@ 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 uint8_t *string, size_t length,
+ const char *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);
diff --git a/src/rufl_decompose.c b/src/rufl_decompose.c
index 0e9f6ea..2085e8f 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 uint8_t *string, size_t len,
+ const char *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 de3463a..6c06a8f 100644
--- a/src/rufl_init.c
+++ b/src/rufl_init.c
@@ -571,10 +571,14 @@ static rufl_code rufl_init_enumerate_characters(const
char *font_name,
rufl_fm_error->errmess);
return rufl_FONT_MANAGER_ERROR;
}
+ if (first == (unsigned int) -1) {
+ /* Font has no defined characters */
+ return rufl_OK;
+ }
/* Search the entire space up to the first codepoint it
* reported. */
- for (u = 1; u != (unsigned int) -1 && u != first; u++) {
+ for (u = 1; u != first; u++) {
rufl_fm_error = xfont_enumerate_characters(font, u,
(int *) &next, (int *) &internal);
if (rufl_fm_error) {
@@ -583,8 +587,7 @@ static rufl_code rufl_init_enumerate_characters(const char
*font_name,
font_name, u,
rufl_fm_error->errnum,
rufl_fm_error->errmess);
- result = rufl_FONT_MANAGER_ERROR;
- break;
+ return rufl_FONT_MANAGER_ERROR;
}
/* Skip unmapped characters */
@@ -594,7 +597,7 @@ static rufl_code rufl_init_enumerate_characters(const char
*font_name,
/* Character is mapped, emit it */
result = callback(pw, internal, u);
if (result != rufl_OK)
- break;
+ return result;
}
/* Now fall through to the normal path */
diff --git a/src/rufl_metrics.c b/src/rufl_metrics.c
index 876ac53..bbfd6bb 100644
--- a/src/rufl_metrics.c
+++ b/src/rufl_metrics.c
@@ -114,11 +114,12 @@ 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 uint8_t *string, size_t length,
+ const char *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 uint8_t *ustring = (const uint8_t *) string;
const char *font_encoding = NULL;
unsigned int font, font1, u;
uint32_t u1[2];
@@ -136,7 +137,7 @@ rufl_code rufl_glyph_metrics(const char *font_family,
if (code != rufl_OK)
return code;
- rufl_utf8_read(string, length, u);
+ rufl_utf8_read(ustring, length, u);
if (charset && rufl_character_set_test(charset, u))
font1 = font;
else {
diff --git a/src/rufl_paint.c b/src/rufl_paint.c
index 06ed509..9dc0e3f 100644
--- a/src/rufl_paint.c
+++ b/src/rufl_paint.c
@@ -58,12 +58,13 @@ 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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int x, int y, unsigned int flags)
{
return rufl_process(rufl_PAINT,
- font_family, font_style, font_size, string,
- length, x, y, flags, 0, 0, 0, 0, 0, 0);
+ font_family, font_style, font_size,
+ (const uint8_t *) string, length,
+ x, y, flags, 0, 0, 0, 0, 0, 0);
}
@@ -73,12 +74,13 @@ 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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int *width)
{
return rufl_process(rufl_WIDTH,
- font_family, font_style, font_size, string,
- length, 0, 0, 0, width, 0, 0, 0, 0, 0);
+ font_family, font_style, font_size,
+ (const uint8_t *) string, length,
+ 0, 0, 0, width, 0, 0, 0, 0, 0);
}
@@ -89,14 +91,14 @@ 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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int click_x,
size_t *char_offset, int *actual_x)
{
return rufl_process(rufl_X_TO_OFFSET,
- font_family, font_style, font_size, string,
- length, 0, 0, 0, 0,
- click_x, char_offset, actual_x, 0, 0);
+ font_family, font_style, font_size,
+ (const uint8_t *) string, length,
+ 0, 0, 0, 0, click_x, char_offset, actual_x, 0, 0);
}
@@ -106,14 +108,14 @@ 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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int width,
size_t *char_offset, int *actual_x)
{
return rufl_process(rufl_SPLIT,
- font_family, font_style, font_size, string,
- length, 0, 0, 0, 0,
- width, char_offset, actual_x, 0, 0);
+ font_family, font_style, font_size,
+ (const uint8_t *) string, length,
+ 0, 0, 0, 0, width, char_offset, actual_x, 0, 0);
}
@@ -123,13 +125,14 @@ 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 uint8_t *string, size_t length,
+ const char *string, size_t length,
int x, int y,
rufl_callback_t callback, void *context)
{
return rufl_process(rufl_PAINT_CALLBACK,
- font_family, font_style, font_size, string,
- length, x, y, 0, 0, 0, 0, 0, callback, context);
+ font_family, font_style, font_size,
+ (const uint8_t *) string, length,
+ x, y, 0, 0, 0, 0, 0, callback, context);
}
diff --git a/test/oldfminit.c b/test/oldfminit.c
index b545e9a..c554499 100644
--- a/test/oldfminit.c
+++ b/test/oldfminit.c
@@ -287,13 +287,12 @@ int main(int argc, const char **argv)
assert(0 == uline_thickness);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, &width));
+ "!\xc2\xa0", 3, &width));
assert(50 == width);
/* Place caret after first character */
assert(rufl_OK == rufl_x_to_offset("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(1 == offset);
assert(25 == x);
@@ -301,17 +300,16 @@ int main(int argc, const char **argv)
* coincident with the start of the second character, however,
* the split point is placed after it. */
assert(rufl_OK == rufl_split("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(3 == offset);
assert(50 == x);
/* Compute width of replacement character */
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xef\xbf\xbd", 3, &width));
+ "\xef\xbf\xbd", 3, &width));
assert(17 == width);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xf0\xa0\x80\xa5", 4, &width));
+ "\xf0\xa0\x80\xa5", 4, &width));
assert(26 == width);
/* Measure font bounding box */
@@ -324,13 +322,13 @@ int main(int argc, const char **argv)
/* Trivial render */
assert(rufl_OK == rufl_paint("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 0, 0, 0));
+ "!\xc2\xa0", 3, 0, 0, 0));
rufl_dump_state(true);
/* Obtain metrics for a glyph */
assert(rufl_OK == rufl_glyph_metrics("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!", 1, &x_bearing, &y_bearing,
+ "!", 1, &x_bearing, &y_bearing,
&mwidth, &mheight, &x_advance, &y_advance));
assert(0 == x_bearing);
assert(10000 == y_bearing);
diff --git a/test/olducsinit.c b/test/olducsinit.c
index 208484e..ed3d846 100644
--- a/test/olducsinit.c
+++ b/test/olducsinit.c
@@ -74,13 +74,12 @@ int main(int argc, const char **argv)
assert(0 == uline_thickness);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, &width));
+ "!\xc2\xa0", 3, &width));
assert(50 == width);
/* Place caret after first character */
assert(rufl_OK == rufl_x_to_offset("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(1 == offset);
assert(25 == x);
@@ -88,17 +87,16 @@ int main(int argc, const char **argv)
* coincident with the start of the second character, however,
* the split point is placed after it. */
assert(rufl_OK == rufl_split("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(3 == offset);
assert(50 == x);
/* Compute width of replacement character */
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xef\xbf\xbd", 3, &width));
+ "\xef\xbf\xbd", 3, &width));
assert(17 == width);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xf0\xa0\x80\xa5", 4, &width));
+ "\xf0\xa0\x80\xa5", 4, &width));
assert(26 == width);
/* Measure font bounding box */
@@ -111,11 +109,11 @@ int main(int argc, const char **argv)
/* Trivial render */
assert(rufl_OK == rufl_paint("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 0, 0, 0));
+ "!\xc2\xa0", 3, 0, 0, 0));
/* Obtain metrics for a glyph */
assert(rufl_OK == rufl_glyph_metrics("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!", 1, &x_bearing, &y_bearing,
+ "!", 1, &x_bearing, &y_bearing,
&mwidth, &mheight, &x_advance, &y_advance));
assert(0 == x_bearing);
assert(10000 == y_bearing);
diff --git a/test/rufl_chars.c b/test/rufl_chars.c
index 0559d4e..64831ad 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)
{
- uint8_t s[10];
+ char s[10];
unsigned int l;
unsigned int u;
rufl_code code;
diff --git a/test/rufl_test.c b/test/rufl_test.c
index 3edbcf1..bc644f5 100644
--- a/test/rufl_test.c
+++ b/test/rufl_test.c
@@ -24,7 +24,7 @@ static void callback(void *context,
int main(void)
{
- const uint8_t utf8_test[] = "Hello, world! ὕαλον "
+ const char utf8_test[] = "Hello, world! ὕαλον "
"Uherské Hradiště. 𐀀"
"\xf0\xa0\x80\xa1";
int width;
@@ -58,7 +58,7 @@ int main(void)
char_offset, utf8_test + char_offset);
}
try(rufl_decompose_glyph("Homerton", rufl_WEIGHT_400, 1280,
- (const uint8_t *) "A", 1, &funcs, 0),
+ "A", 1, &funcs, 0),
"rufl_decompose_glyph");
try(rufl_paint_callback("NewHall", rufl_WEIGHT_400, 240,
utf8_test, sizeof utf8_test - 1,
diff --git a/test/ucsinit.c b/test/ucsinit.c
index 45197a0..25aea60 100644
--- a/test/ucsinit.c
+++ b/test/ucsinit.c
@@ -74,13 +74,12 @@ int main(int argc, const char **argv)
assert(0 == uline_thickness);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, &width));
+ "!\xc2\xa0", 3, &width));
assert(50 == width);
/* Place caret after first character */
assert(rufl_OK == rufl_x_to_offset("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(1 == offset);
assert(25 == x);
@@ -88,17 +87,16 @@ int main(int argc, const char **argv)
* coincident with the start of the second character, however,
* the split point is placed after it. */
assert(rufl_OK == rufl_split("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 25,
- &offset, &x));
+ "!\xc2\xa0", 3, 25, &offset, &x));
assert(3 == offset);
assert(50 == x);
/* Compute width of replacement character */
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xef\xbf\xbd", 3, &width));
+ "\xef\xbf\xbd", 3, &width));
assert(17 == width);
assert(rufl_OK == rufl_width("Corpus", rufl_WEIGHT_500, 160,
- (const uint8_t *) "\xf0\xa0\x80\xa5", 4, &width));
+ "\xf0\xa0\x80\xa5", 4, &width));
assert(26 == width);
/* Measure font bounding box */
@@ -111,11 +109,11 @@ int main(int argc, const char **argv)
/* Trivial render */
assert(rufl_OK == rufl_paint("Trinity", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!\xc2\xa0", 3, 0, 0, 0));
+ "!\xc2\xa0", 3, 0, 0, 0));
/* Obtain metrics for a glyph */
assert(rufl_OK == rufl_glyph_metrics("Homerton", rufl_WEIGHT_500, 160,
- (const uint8_t *) "!", 1, &x_bearing, &y_bearing,
+ "!", 1, &x_bearing, &y_bearing,
&mwidth, &mheight, &x_advance, &y_advance));
assert(0 == x_bearing);
assert(10000 == y_bearing);
--
RISC OS Unicode Font Library
_______________________________________________
netsurf-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]