From cebb6cd53700d251ccd1b05ae18419fdcd59ff0c Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Wed, 7 Aug 2019 13:00:19 +0200 Subject: [PATCH] ft: minor fixes --- compiler/parser.v | 5 +++-- vlib/ft/ft.v | 26 ++++++++++---------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/compiler/parser.v b/compiler/parser.v index f267d50e9c..211c6d63fe 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -1191,9 +1191,10 @@ fn (p mut Parser) statement(add_semi bool) string { // this can be `user = ...` or `user.field = ...`, in both cases `v` is `user` fn (p mut Parser) assign_statement(v Var, ph int, is_map bool) { p.log('assign_statement() name=$v.name tok=') + is_vid := p.fileis('vid') // TODO remove tok := p.tok //if !v.is_mut && !v.is_arg && !p.pref.translated && !v.is_global{ - if !v.is_mut && !p.pref.translated && !v.is_global{ + if !v.is_mut && !p.pref.translated && !v.is_global && !is_vid { p.error('`$v.name` is immutable') } if !v.is_changed { @@ -1758,7 +1759,7 @@ fn (p mut Parser) dot(str_typ string, method_ph int) string { // Is the next token `=`, `+=` etc? (Are we modifying the field?) next := p.peek() modifying := next.is_assign() || next == .inc || next == .dec - is_vi := p.fileis('vi') + is_vi := p.fileis('vid') if !p.builtin_mod && !p.pref.translated && modifying && !field.is_mut && !is_vi { p.error('cannot modify immutable field `$field_name` (type `$typ.name`)') } diff --git a/vlib/ft/ft.v b/vlib/ft/ft.v index d600f87515..38ae616aec 100644 --- a/vlib/ft/ft.v +++ b/vlib/ft/ft.v @@ -248,20 +248,11 @@ fn (ctx mut GG) init_utf8_runes() { // fn (ctx &GG) render_text(text string, x, y, scale f32, color gx.Color) { pub fn (ctx &GG) draw_text(_x, _y int, text string, cfg gx.TextCfg) { - // dont draw non ascii for now - /* - for i := 0; i < text.len; i++ { - c := text[i] - if int(c) > 128 { - // ctx.text_ctx._draw_text(_x, _y, '[NON ASCII]', cfg) - // return - } - } -*/ - // # glScissor(0,0,300,300); +println('draw text start') utext := text.ustring_tmp() // utext := text.ustring() - ctx.text_ctx._draw_text(_x, _y, utext, cfg) + ctx._draw_text(_x, _y, utext, cfg) +println('draw text end') // utext.free() // # glScissor(0,0,ctx->width*2,ctx->height*2); // gl.disable(GL_SCISSOR_TEST)// TODO @@ -286,16 +277,19 @@ fn (ctx &GG) _draw_text(_x, _y int, utext ustring, cfg gx.TextCfg) { } } */ + mut x := f32(_x) + mut y := f32(_y) // println('scale=$ctx.scale size=$cfg.size') if cfg.align == gx.ALIGN_RIGHT { width := utext.len * 7 - _x -= width + 10 + x -= width + 10 } - x := f32(_x) * ctx.scale// f32(2) + x *= ctx.scale// f32(2) // println('y=$_y height=$ctx.height') // _y = _y * int(ctx.scale) //+ 26 - _y = _y * int(ctx.scale) + ((cfg.size * ctx.scale) / 2) + 5 * ctx.scale - y := f32(ctx.height - _y) + y = y * int(ctx.scale) + ((cfg.size * ctx.scale) / 2) + 5 * ctx.scale + y = f32(ctx.height) - y +println('($x, $y)' ) color := cfg.color // Activate corresponding render state ctx.shader.use()