diff options
author | Mattias Andrée <maandree@kth.se> | 2021-12-26 11:45:41 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2021-12-26 11:45:41 +0100 |
commit | 9ada93e99ab3cdfc9542a5facbeacd582d2c5227 (patch) | |
tree | 9bca146ed6baaadf7b12f206a723e6f5fb2525a6 | |
parent | Small fixes + other font types should be handled via conversion (diff) | |
download | libskrift-9ada93e99ab3cdfc9542a5facbeacd582d2c5227.tar.gz libskrift-9ada93e99ab3cdfc9542a5facbeacd582d2c5227.tar.bz2 libskrift-9ada93e99ab3cdfc9542a5facbeacd582d2c5227.tar.xz |
Update to use version 1 of libgrapheme
Signed-off-by: Mattias Andrée <maandree@kth.se>
-rw-r--r-- | libskrift_draw_text.c | 2 | ||||
-rw-r--r-- | libskrift_get_cluster_glyph.c | 12 | ||||
-rw-r--r-- | libskrift_get_grapheme_glyph.c | 2 |
3 files changed, 9 insertions, 7 deletions
diff --git a/libskrift_draw_text.c b/libskrift_draw_text.c index e827159..f3615d7 100644 --- a/libskrift_draw_text.c +++ b/libskrift_draw_text.c @@ -6,7 +6,7 @@ reverse_text(const char *restrict text, size_t text_length, char *restrict s) { size_t n, off = text_length; for (; text_length; text += n, text_length -= n) { - off -= n = grapheme_bytelen(text); + off -= n = grapheme_next_character_break(text, text_length); memcpy(&s[off], text, n); } } diff --git a/libskrift_get_cluster_glyph.c b/libskrift_get_cluster_glyph.c index 6b3abaa..67ddf72 100644 --- a/libskrift_get_cluster_glyph.c +++ b/libskrift_get_cluster_glyph.c @@ -8,10 +8,12 @@ libskrift_get_cluster_glyph(LIBSKRIFT_CONTEXT *ctx, const char *text, size_t tex struct libskrift_saved_grapheme *saved, double x, double y, struct libskrift_glyph **glyphp) { struct libskrift_glyph *glyph0, *glyph1, *glyph2; - uint32_t cp0, cp1; - int state = 0; + uint_least32_t cp0, cp1; + GRAPHEME_STATE state; size_t r, len; + memset(&state, 0, sizeof(state)); + *glyphp = NULL; if (!text_length) { @@ -23,7 +25,7 @@ libskrift_get_cluster_glyph(LIBSKRIFT_CONTEXT *ctx, const char *text, size_t tex cp0 = saved->cp; len = saved->len; } else { - len = grapheme_cp_decode(&cp0, (const void *)text, text_length); + len = grapheme_decode_utf8(text, text_length, &cp0); } if (libskrift_get_grapheme_glyph(ctx, cp0, x, y, &glyph0)) @@ -32,8 +34,8 @@ libskrift_get_cluster_glyph(LIBSKRIFT_CONTEXT *ctx, const char *text, size_t tex x += glyph0->advance * ctx->char_x_advancement; y += glyph0->advance * ctx->char_y_advancement; for (; len < text_length; cp0 = cp1, len += r) { - r = grapheme_cp_decode(&cp1, (const void *)&text[len], text_length - len); - if (grapheme_boundary(cp0, cp1, &state)) { + r = grapheme_decode_utf8((const void *)&text[len], text_length - len, &cp1); + if (grapheme_is_character_break(cp0, cp1, &state)) { if (saved) { saved->have_saved = 1; saved->cp = cp1; diff --git a/libskrift_get_grapheme_glyph.c b/libskrift_get_grapheme_glyph.c index e0b699d..79b36dc 100644 --- a/libskrift_get_grapheme_glyph.c +++ b/libskrift_get_grapheme_glyph.c @@ -115,6 +115,6 @@ libskrift_get_grapheme_glyph(LIBSKRIFT_CONTEXT *ctx, libskrift_codepoint_t codep return r; } - /* TODO add callback for drawing fallback glyph, draw square by default. */ + /* TODO Use glyph 0 */ return -1; } |