From c18f87ad13da518af5ff245dbce2a9e608097ea1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 17 Nov 2021 03:15:16 +0100 Subject: Attempt to fix font glyph texture overlap by aligning texture size to next character size Add function to get the start of a utf8 codepoint (backwards), test utf8 functions --- include/mgl/system/utf8.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/mgl/system') diff --git a/include/mgl/system/utf8.h b/include/mgl/system/utf8.h index 7120f1a..794884d 100644 --- a/include/mgl/system/utf8.h +++ b/include/mgl/system/utf8.h @@ -9,6 +9,13 @@ Returns false on failure. |decoded_codepoint| is set to |str[0]| if size > 0 and |codepoint_length| is set to 1 */ bool mgl_utf8_decode(const unsigned char *str, size_t size, uint32_t *decoded_codepoint, size_t *codepoint_length); +/* + |str| should be the start of the utf8 string and |size| is the size of the string. + Returns the index of the start of the codepoint that starts at or before |offset|, + or if the string contains invalid utf8 then the index to the invalid character is returned. + Returns 0 if start of codepoint is not found. +*/ +size_t mgl_utf8_get_start_of_codepoint(const unsigned char *str, size_t size, size_t offset); #endif /* MGL_UTF8_H */ -- cgit v1.2.3