gg: text_height()
parent
9c43d36513
commit
cad816a19d
|
@ -94,11 +94,21 @@ pub fn (ctx &Context) text_width(s string) int {
|
||||||
return int((buf[2] - buf[0]) / ctx.scale)
|
return int((buf[2] - buf[0]) / ctx.scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (ft &Context) text_height(s string) int {
|
pub fn (ctx &Context) text_height(s string) int {
|
||||||
|
if !ctx.font_inited {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
mut buf := [4]f32
|
||||||
pub fn (ft &Context) text_size(s string) (int, int) {
|
C.fonsTextBounds(ctx.ft.fons, 0, 0, s.str, 0, buf)
|
||||||
return 0,0
|
return int((buf[3] - buf[1]) / ctx.scale)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (ctx &Context) text_size(s string) (int, int) {
|
||||||
|
if !ctx.font_inited {
|
||||||
|
return 0,0
|
||||||
|
}
|
||||||
|
mut buf := [4]f32
|
||||||
|
C.fonsTextBounds(ctx.ft.fons, 0, 0, s.str, 0, buf)
|
||||||
|
return int((buf[2] - buf[0]) / ctx.scale), int((buf[3] - buf[1]) / ctx.scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue