aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-11-17 03:15:16 +0100
committerdec05eba <dec05eba@protonmail.com>2021-11-17 03:15:16 +0100
commitc18f87ad13da518af5ff245dbce2a9e608097ea1 (patch)
tree3ca8a22df68fc1ef7ecd7b9ec449a733b76de67a /include
parentccd0e65a0ddccd9c52d4c075ec1cad41ae7edb40 (diff)
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
Diffstat (limited to 'include')
-rw-r--r--include/mgl/graphics/font.h2
-rw-r--r--include/mgl/system/utf8.h7
2 files changed, 8 insertions, 1 deletions
diff --git a/include/mgl/graphics/font.h b/include/mgl/graphics/font.h
index adcc8a7..6b7eb34 100644
--- a/include/mgl/graphics/font.h
+++ b/include/mgl/graphics/font.h
@@ -25,7 +25,7 @@ typedef struct {
} mgl_font_atlas;
struct mgl_font {
- mgl_texture texture;
+ mgl_texture texture; /* Font texture coordinates are in pixel space */
mgl_font_atlas font_atlas;
unsigned int character_size;
mgl_font_char_map char_map;
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 */