Skip to content

Commit 9da7349

Browse files
committed
gg: minor fixes
1 parent eabc2da commit 9da7349

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

vlib/gg/text_rendering.v

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ fn (ctx &Context) set_cfg(cfg gx.TextCfg) {
103103
}
104104

105105
pub fn (ctx &Context) draw_text(x, y int, text_ string, cfg gx.TextCfg) {
106+
if !ctx.font_inited {
107+
eprintln('gg: draw_text(): font not initialized')
108+
return
109+
}
106110
//text := text_.trim_space() // TODO remove/optimize
107111
mut text := text_
108112
if text.contains('\t') {
@@ -133,6 +137,9 @@ pub fn (ctx &Context) text_width(s string) int {
133137
}
134138
mut buf := [4]f32{}
135139
C.fonsTextBounds(ctx.ft.fons, 0, 0, s.str, 0, buf)
140+
if s.ends_with(' ') {
141+
return int((buf[2] - buf[0]) / ctx.scale) + ctx.text_width('i') // TODO fix this in fontstash?
142+
}
136143
return int((buf[2] - buf[0]) / ctx.scale)
137144
}
138145

vlib/gx/color.v

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ pub fn (c Color) str() string {
109109
const (
110110
string_colors = {
111111
'black': black
112+
'blue': blue
112113
'red': red
113114
}
114115
)

0 commit comments

Comments
 (0)