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

ft: rename to freetype

This commit is contained in:
Alexander Medvednikov 2019-08-08 16:43:11 +02:00
parent 865eee2f6b
commit fbc480fbed
2 changed files with 12 additions and 14 deletions

View File

@ -185,7 +185,7 @@ fn (p mut Parser) parse() {
} }
p.fgenln('\n') p.fgenln('\n')
p.builtin_mod = p.mod == 'builtin' 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 // Import pass - the first and the smallest pass that only analyzes imports
// fully qualify the module name, eg base64 to encoding.base64 // fully qualify the module name, eg base64 to encoding.base64
fq_mod := p.table.qualify_module(p.mod, p.file_path) fq_mod := p.table.qualify_module(p.mod, p.file_path)

View File

@ -2,7 +2,7 @@
// Use of this source code is governed by an MIT license // Use of this source code is governed by an MIT license
// that can be found in the LICENSE file. // that can be found in the LICENSE file.
module ft module freetype
import ( import (
os os
@ -44,7 +44,7 @@ struct Face {
cobj voidptr cobj voidptr
} }
struct GG { struct Context {
shader gl.Shader shader gl.Shader
// use_ortho bool // use_ortho bool
width int width int
@ -58,7 +58,6 @@ struct GG {
chars []Character chars []Character
utf_runes []string utf_runes []string
utf_chars []Character utf_chars []Character
text_ctx *GG
face Face face Face
scale int // retina = 2 , normal = 1 scale int // retina = 2 , normal = 1
} }
@ -116,10 +115,10 @@ fn ft_load_char(_face Face, code i64) Character {
return ch 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 // Can only have text in ortho mode
if !cfg.use_ortho { if !cfg.use_ortho {
return &GG{text_ctx: 0} return &Context{}
} }
mut width := cfg.width * scale mut width := cfg.width * scale
mut height := cfg.height * 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); // # glVertexAttribPointer(0, 4, GL_FLOAT,false, 4 * sizeof(GLf32), 0);
// gl.bind_buffer(GL_ARRAY_BUFFER, uint(0)) // gl.bind_buffer(GL_ARRAY_BUFFER, uint(0))
// # glBindVertexArray(0); // # glBindVertexArray(0);
mut ctx := &GG { mut ctx := &Context {
shader: shader, shader: shader,
width: width, width: width,
height: height, height: height,
@ -225,7 +224,6 @@ pub fn new_context(cfg gg.Cfg, scale int) *GG {
vbo: vbo, vbo: vbo,
chars: chars, chars: chars,
face: f face: f
text_ctx: 0
} }
ctx.init_utf8_runes() ctx.init_utf8_runes()
return ctx 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. // A dirty hack to implement rendering of cyrillic letters.
// All UTF-8 must be supported. // All UTF-8 must be supported.
fn (ctx mut GG) init_utf8_runes() { fn (ctx mut Context) init_utf8_runes() {
s := 'йцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ' s := 'йцукенгшщзхъфывапролджэячсмитьбюЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮ'
println(s) println(s)
us := s.ustring() 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) { // 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_tmp()
// utext := text.ustring() // utext := text.ustring()
ctx._draw_text(_x, _y, utext, cfg) 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); // #free(text.str);
} }
fn (ctx &GG) draw_text_fast(_x, _y int, text ustring, cfg gx.TextCfg) { fn (ctx &Context) draw_text_fast(_x, _y int, text ustring, cfg gx.TextCfg) {
ctx.text_ctx._draw_text(_x, _y, text, cfg) ctx._draw_text(_x, _y, text, cfg)
} }
// TODO HACK with second text context // 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, 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') { if utext.s.contains('on_seg') {
println('\nat(0)') println('\nat(0)')
@ -369,7 +367,7 @@ fn (ctx &GG) _draw_text(_x, _y int, utext ustring, cfg gx.TextCfg) {
// #free(runes.data); // #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 { cfg := gx.TextCfg {
color: gx.Black, color: gx.Black,
size: DEFAULT_FONT_SIZE, size: DEFAULT_FONT_SIZE,