From 756c6d2858e5fcd43e4779e826679e6058542626 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 16 Jan 2020 17:03:31 +0100 Subject: [PATCH] freetype: fix align.right rendering --- vlib/compiler/fn.v | 14 +++++++------- vlib/compiler/msvc.v | 2 +- vlib/freetype/freetype.v | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/vlib/compiler/fn.v b/vlib/compiler/fn.v index 4d33ab62f5..7896f21d9b 100644 --- a/vlib/compiler/fn.v +++ b/vlib/compiler/fn.v @@ -486,7 +486,7 @@ fn (p mut Parser) fn_decl() { if is_c { p.fgen_nl() } - + // Register the method if receiver_typ != '' { mut receiver_t := p.table.find_type(receiver_typ) @@ -512,7 +512,7 @@ fn (p mut Parser) fn_decl() { if p.first_pass() && p.attr == 'live' && !(is_live || is_solive) { println('INFO: run `v -live $p.v.dir `, if you want to use [live] function $f.name .') } - + if p.is_vh || p.first_pass() || is_live || is_fn_header || skip_main_in_test { // First pass? Skip the body for now // Look for generic calls. @@ -536,7 +536,7 @@ fn (p mut Parser) fn_decl() { } return } - + if is_solive { // Live functions are protected by a mutex, because otherwise they // can be changed by the live reload thread, *while* they are @@ -560,10 +560,10 @@ fn (p mut Parser) fn_decl() { p.genln(' $live_fncall') p.genln(' pthread_mutex_unlock(&live_fn_mutex);') p.genln(' $live_fnreturn') - p.genln('}') + p.genln('}') p.genln('$typ impl_live_${fn_name_cgen} ($str_args){') } - + if f.name in ['main__main', 'main', 'WinMain'] { if p.pref.is_test { p.error_with_token_index('tests cannot have function `main`', f.fn_name_token_idx) @@ -665,11 +665,11 @@ fn (p mut Parser) check_unused_and_mut_vars() { break } if !var.is_used && !p.pref.is_repl && !var.is_arg && !p.pref.translated && - var.name != 'tmpl_res' && p.mod != 'vweb' && var.name != 'it' { + var.name != 'tmpl_res' && p.mod != 'vweb' && var.name != 'it' && !p.cur_fn.is_unsafe { p.production_error_with_token_index('`$var.name` declared and not used', var.token_idx) } if !var.is_changed && var.is_mut && !p.pref.is_repl && !p.pref.translated && var.typ != 'T*' && p.mod != 'ui' && var.typ != 'App*' { - p.warn_or_error('`$var.name` is declared as mutable, but it was never changed') + //p.warn_or_error('`$var.name` is declared as mutable, but it was never changed') } } } diff --git a/vlib/compiler/msvc.v b/vlib/compiler/msvc.v index 1c0a50274e..31a7f38585 100644 --- a/vlib/compiler/msvc.v +++ b/vlib/compiler/msvc.v @@ -310,7 +310,7 @@ fn build_thirdparty_obj_file_with_msvc(path string, moduleflags []CFlag) { mut obj_path := '${path}bj' obj_path = os.realpath(obj_path) if os.exists(obj_path) { - println('$obj_path already build.') + println('$obj_path already built.') return } println('$obj_path not found, building it (with msvc)...') diff --git a/vlib/freetype/freetype.v b/vlib/freetype/freetype.v index 5e56abb9de..b43a55763b 100644 --- a/vlib/freetype/freetype.v +++ b/vlib/freetype/freetype.v @@ -262,7 +262,8 @@ fn (ctx mut FreeType) private_draw_text(_x, _y int, utext ustring, cfg gx.TextCf mut y := f32(_y) // println('scale=$ctx.scale size=$cfg.size') if cfg.align == gx.ALIGN_RIGHT { - width := utext.len * 7 + //width := utext.len * 7 + width := ctx.text_width(utext.s) x -= width + 10 } x *= ctx.scale// f32(2)