Decode a UTF-8 character sequence to Unicode code point
| 2982 | |
| 2983 | // Decode a UTF-8 character sequence to Unicode code point |
| 2984 | uint32_t decode_utf8(const char *s, int *bytes_read) { |
| 2985 | uint8_t c = s[0]; |
| 2986 | if (c < 0x80) { |
| 2987 | *bytes_read = 1; |
| 2988 | return c; |
| 2989 | } else if (c < 0xE0) { |
| 2990 | *bytes_read = 2; |
| 2991 | return ((s[0] & 0x1F) << 6) | (s[1] & 0x3F); |
| 2992 | } else if (c < 0xF0) { |
| 2993 | *bytes_read = 3; |
| 2994 | return ((s[0] & 0x0F) << 12) | ((s[1] & 0x3F) << 6) | (s[2] & 0x3F); |
| 2995 | } else { |
| 2996 | *bytes_read = 4; |
| 2997 | return ((s[0] & 0x07) << 18) | ((s[1] & 0x3F) << 12) | ((s[2] & 0x3F) << 6) | (s[3] & 0x3F); |
| 2998 | } |
| 2999 | } |
| 3000 | |
| 3001 | static void renderer_add_glyph(stbtt_aligned_quad q, int32_t max_descended_char_height, LfColor color, uint32_t tex_index) { |
| 3002 | vec2s texcoords[4] = { |
nothing calls this directly
no outgoing calls
no test coverage detected