mirror of
https://github.com/nicbarker/clay.git
synced 2025-09-18 04:26:18 +00:00
Compare commits
6 commits
a577895910
...
faa388b3e0
Author | SHA1 | Date | |
---|---|---|---|
![]() |
faa388b3e0 | ||
![]() |
2388d06726 | ||
![]() |
b284305e12 | ||
![]() |
80e28e7088 | ||
![]() |
55453f8e45 | ||
![]() |
a6cf58c74c |
|
@ -21,9 +21,17 @@ measure_text :: proc "c" (text: clay.StringSlice, config: ^clay.TextElementConfi
|
||||||
|
|
||||||
font := raylib_fonts[config.fontId].font
|
font := raylib_fonts[config.fontId].font
|
||||||
|
|
||||||
for i in 0 ..< text.length {
|
byte_index := 0
|
||||||
glyph_index := text.chars[i] - 32
|
for byte_index < int(text.length) {
|
||||||
|
// handle utf-8 codepoints
|
||||||
|
codepoint_bytes: i32 = 0
|
||||||
|
codepoint := rl.GetCodepoint(
|
||||||
|
transmute(cstring)&text.chars[byte_index],
|
||||||
|
&codepoint_bytes,
|
||||||
|
)
|
||||||
|
byte_index += int(codepoint_bytes)
|
||||||
|
|
||||||
|
glyph_index := rl.GetGlyphIndex(font, codepoint)
|
||||||
glyph := font.glyphs[glyph_index]
|
glyph := font.glyphs[glyph_index]
|
||||||
|
|
||||||
if glyph.advanceX != 0 {
|
if glyph.advanceX != 0 {
|
||||||
|
@ -198,4 +206,4 @@ draw_rect :: proc(x, y, w, h: f32, color: clay.Color) {
|
||||||
@(private = "file")
|
@(private = "file")
|
||||||
draw_rect_rounded :: proc(x,y,w,h: f32, radius: f32, color: clay.Color){
|
draw_rect_rounded :: proc(x,y,w,h: f32, radius: f32, color: clay.Color){
|
||||||
rl.DrawRectangleRounded({x,y,w,h},radius,8,clay_color_to_rl_color(color))
|
rl.DrawRectangleRounded({x,y,w,h},radius,8,clay_color_to_rl_color(color))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue