diff --git a/compiler/parser.v b/compiler/parser.v index 1e69e29ef0..2fdc7ec667 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -185,7 +185,7 @@ fn (p mut Parser) parse() { } p.fgenln('\n') p.builtin_mod = p.mod == 'builtin' - p.can_chash = p.mod == 'ft' || p.mod == 'glfw' || p.mod=='glfw2' || p.mod=='ui' // TODO tmp remove + p.can_chash = p.mod == 'freetype' || p.mod == 'glfw' || p.mod=='glfw2' || p.mod=='ui' // TODO tmp remove // Import pass - the first and the smallest pass that only analyzes imports // fully qualify the module name, eg base64 to encoding.base64 fq_mod := p.table.qualify_module(p.mod, p.file_path) diff --git a/vlib/ft/ft.v b/vlib/freetype/freetype.v similarity index 95% rename from vlib/ft/ft.v rename to vlib/freetype/freetype.v index f06939be7c..2eacaaeec6 100644 --- a/vlib/ft/ft.v +++ b/vlib/freetype/freetype.v @@ -2,7 +2,7 @@ // Use of this source code is governed by an MIT license // that can be found in the LICENSE file. -module ft +module freetype import ( os @@ -44,7 +44,7 @@ struct Face { cobj voidptr } -struct GG { +struct Context { shader gl.Shader // use_ortho bool width int @@ -58,7 +58,6 @@ struct GG { chars []Character utf_runes []string utf_chars []Character - text_ctx *GG face Face scale int // retina = 2 , normal = 1 } @@ -116,10 +115,10 @@ fn ft_load_char(_face Face, code i64) Character { return ch } -pub fn new_context(cfg gg.Cfg, scale int) *GG { +pub fn new_context(cfg gg.Cfg, scale int) *Context { // Can only have text in ortho mode if !cfg.use_ortho { - return &GG{text_ctx: 0} + return &Context{} } mut width := cfg.width * scale mut height := cfg.height * scale @@ -216,7 +215,7 @@ pub fn new_context(cfg gg.Cfg, scale int) *GG { // # glVertexAttribPointer(0, 4, GL_FLOAT,false, 4 * sizeof(GLf32), 0); // gl.bind_buffer(GL_ARRAY_BUFFER, uint(0)) // # glBindVertexArray(0); - mut ctx := &GG { + mut ctx := &Context { shader: shader, width: width, height: height, @@ -225,7 +224,6 @@ pub fn new_context(cfg gg.Cfg, scale int) *GG { vbo: vbo, chars: chars, face: f - text_ctx: 0 } ctx.init_utf8_runes() return ctx @@ -233,7 +231,7 @@ pub fn new_context(cfg gg.Cfg, scale int) *GG { // A dirty hack to implement rendering of cyrillic letters. // All UTF-8 must be supported. -fn (ctx mut GG) init_utf8_runes() { +fn (ctx mut Context) init_utf8_runes() { s := '≈йцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ' println(s) us := s.ustring() @@ -247,7 +245,7 @@ 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) { +pub fn (ctx &Context) draw_text(_x, _y int, text string, cfg gx.TextCfg) { utext := text.ustring_tmp() // utext := text.ustring() ctx._draw_text(_x, _y, utext, cfg) @@ -257,13 +255,13 @@ pub fn (ctx &GG) draw_text(_x, _y int, text string, cfg gx.TextCfg) { // #free(text.str); } -fn (ctx &GG) draw_text_fast(_x, _y int, text ustring, cfg gx.TextCfg) { - ctx.text_ctx._draw_text(_x, _y, text, cfg) +fn (ctx &Context) draw_text_fast(_x, _y int, text ustring, cfg gx.TextCfg) { + ctx._draw_text(_x, _y, text, cfg) } // TODO HACK with second text context // fn (ctx &GG) _draw_text(_x, _y int, text string, cfg gx.TextCfg) { -fn (ctx &GG) _draw_text(_x, _y int, utext ustring, cfg gx.TextCfg) { +fn (ctx &Context) _draw_text(_x, _y int, utext ustring, cfg gx.TextCfg) { /* if utext.s.contains('on_seg') { println('\nat(0)') @@ -369,7 +367,7 @@ fn (ctx &GG) _draw_text(_x, _y int, utext ustring, cfg gx.TextCfg) { // #free(runes.data); } -pub fn (ctx &GG) draw_text_def(x, y int, text string) { +pub fn (ctx &Context) draw_text_def(x, y int, text string) { cfg := gx.TextCfg { color: gx.Black, size: DEFAULT_FONT_SIZE,