From 1d1fda952256534fa678a43ae80247d27c61e4b3 Mon Sep 17 00:00:00 2001 From: penguindark <57967770+penguindark@users.noreply.github.com> Date: Fri, 15 Jan 2021 19:40:56 +0100 Subject: [PATCH] x.ttf: fix for the MSVC `get_string` pointer issue (#8139) * fix tab and spaces in indentation * fix for glyph not found error * fix for get_String in ttf.v pointer problems with MSVC * avoid second return in get_string * move from u32 to u64 to byteptr in 64 bit systems --- vlib/x/ttf/ttf.v | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/vlib/x/ttf/ttf.v b/vlib/x/ttf/ttf.v index 26fbb2ef18..c5b98d193e 100644 --- a/vlib/x/ttf/ttf.v +++ b/vlib/x/ttf/ttf.v @@ -557,25 +557,10 @@ fn (mut tf TTF_File) get_fixed() f32 { return f32(tf.get_i32() / f32(1 << 16)) } -/*---- restore when MSVC will work again! ---- fn (mut tf TTF_File) get_string(length int) string { tmp_pos := tf.pos tf.pos += u32(length) - unsafe{ - return tos(&tf.buf.data[tmp_pos], length) - } -} -*/ - -fn (mut tf TTF_File) get_string(length int) string { - tmp_pos := tf.pos - mut tmp_txt := strings.new_builder(length) - for _ in 0..length { - tmp_txt.write_b(tf.get_u8()) - } - res_txt := tmp_txt.str() - tf.pos = tmp_pos + u32(length) - return res_txt + return unsafe{ tos(byteptr(u64(tf.buf.data)+u64(tmp_pos)), length) } } fn (mut tf TTF_File) get_unicode_string(length int) string {