gg: fix text rendering (#5727)

pull/5733/head
Louis Schmieder 2020-07-07 17:09:35 +02:00 committed by GitHub
parent b3ed2a4dcc
commit f8a89e3f8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 2 deletions

View File

@ -50,7 +50,8 @@ pub fn (ctx &Context) draw_text(x, y int, text string, cfg gx.TextCfg) {
return return
} }
ctx.ft.fons.set_font(ctx.ft.font_normal) ctx.ft.fons.set_font(ctx.ft.font_normal)
ctx.ft.fons.set_size(2.0 * ctx.ft.scale * f32(cfg.size)) scale := if ctx.ft.scale == 0 { f32(1) } else { ctx.ft.scale }
ctx.ft.fons.set_size(2.0 * scale * f32(cfg.size))
if cfg.align == gx.align_right { if cfg.align == gx.align_right {
C.fonsSetAlign(ctx.ft.fons, C.FONS_ALIGN_RIGHT | C.FONS_ALIGN_TOP) C.fonsSetAlign(ctx.ft.fons, C.FONS_ALIGN_RIGHT | C.FONS_ALIGN_TOP)
} }
@ -63,7 +64,7 @@ pub fn (ctx &Context) draw_text(x, y int, text string, cfg gx.TextCfg) {
descender := f32(0.0) descender := f32(0.0)
lh := f32(0.0) lh := f32(0.0)
ctx.ft.fons.vert_metrics(&ascender, &descender, &lh) ctx.ft.fons.vert_metrics(&ascender, &descender, &lh)
C.fonsDrawText(ctx.ft.fons, x*ctx.ft.scale, y*ctx.ft.scale, text.str, 0) // TODO: check offsets/alignment C.fonsDrawText(ctx.ft.fons, x*scale, y*scale, text.str, 0) // TODO: check offsets/alignment
} }
pub fn (ctx &Context) draw_text_def(x, y int, text string) { pub fn (ctx &Context) draw_text_def(x, y int, text string) {