1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/gx/text.v

38 lines
790 B
V
Raw Permalink Normal View History

module gx
// TODO: remove these, and use the enum everywhere
pub const (
align_left = HorizontalAlign.left
2020-08-19 08:10:42 +03:00
align_right = HorizontalAlign.right
)
[params]
pub struct TextCfg {
pub:
2020-08-19 08:10:42 +03:00
color Color = black
size int = 16
2020-08-19 08:10:42 +03:00
align HorizontalAlign = .left
vertical_align VerticalAlign = .top
2020-08-19 08:10:42 +03:00
max_width int
family string
bold bool
mono bool
italic bool
}
// to_css_string returns a CSS compatible string of the TextCfg `cfg`.
// For example: `'mono 14px serif'`.
pub fn (cfg TextCfg) to_css_string() string {
mut font_style := ''
if cfg.bold {
font_style += 'bold '
}
if cfg.mono {
font_style += 'mono '
}
if cfg.italic {
font_style += 'italic '
}
return '${font_style} ${cfg.size}px ${cfg.family}'
}