From edd8d5b71bce003f11a39a694bf4e92f2d41b946 Mon Sep 17 00:00:00 2001 From: bloeys Date: Sun, 3 Jul 2022 22:37:22 +0400 Subject: [PATCH] Remove commented out code --- glyphs/font_atlas.go | 3 --- glyphs/glyphs.go | 20 -------------------- main.go | 9 ++++----- 3 files changed, 4 insertions(+), 28 deletions(-) diff --git a/glyphs/font_atlas.go b/glyphs/font_atlas.go index 2e1b2c4..1f90d87 100755 --- a/glyphs/font_atlas.go +++ b/glyphs/font_atlas.go @@ -2,7 +2,6 @@ package glyphs import ( "errors" - "fmt" "image" "image/draw" "image/png" @@ -94,7 +93,6 @@ func NewFontAtlasFromFont(f *truetype.Font, face font.Face, pointSize uint) (*Fo } lineHeightFixed = fixed.I(lineHeightFixed.Ceil()) lineHeight := lineHeightFixed.Ceil() - fmt.Println("calculated line height:", lineHeight) //Calculate needed atlas size atlasSizeX := 64 @@ -172,7 +170,6 @@ func NewFontAtlasFromFont(f *truetype.Font, face font.Face, pointSize uint) (*Fo } //Draw glyph and advance dot - // fmt.Println("G:", string(g), "Y:", drawer.Dot.Y.Ceil(), "; rect:", imgRect.String()) draw.DrawMask(drawer.Dst, imgRect, drawer.Src, image.Point{}, mask, maskp, draw.Over) drawer.Dot.X += gAdvanceFixed + charPaddingXFixed diff --git a/glyphs/glyphs.go b/glyphs/glyphs.go index 223739e..6aa2939 100755 --- a/glyphs/glyphs.go +++ b/glyphs/glyphs.go @@ -83,25 +83,6 @@ func (gr *GlyphRend) DrawTextOpenGLAbs(text string, screenPos *gglm.Vec3, color pos.SetX(pos.X() + advanceF32) } - //Draw baselines - // g := gr.Atlas.Glyphs['-'] - // lineData := []float32{ - // g.U, g.V, - // g.U + g.SizeU, g.V, - // g.U, g.V + g.SizeV, - // g.U + g.SizeU, g.V + g.SizeV, - - // 1, 0, 0, 1, //Color - // 0, startPos.Y(), 1, //Model pos - // float32(gr.ScreenWidth), 5, 1, //Model scale - // } - - // instancedData = append(instancedData, lineData...) - // lineData[13] -= float32(gr.Atlas.LineHeight) - // instancedData = append(instancedData, lineData...) - // gr.GlyphCount++ - // gr.GlyphCount++ - gr.GlyphVBO = append(gr.GlyphVBO, instancedData...) } @@ -288,7 +269,6 @@ func NewGlyphRend(fontFile string, fontOptions *truetype.Options, screenWidth, s gr.GlyphMesh.Buf.SetLayout(buffers.Element{ElementType: buffers.DataTypeVec3}) gr.SetScreenSize(screenWidth, screenHeight) - // fmt.Printf("lineHeight=%d, glyphInfo=%+v\n", gr.Atlas.LineHeight, gr.Atlas.Glyphs['A']) return gr, nil } diff --git a/main.go b/main.go index be30652..58a56f3 100755 --- a/main.go +++ b/main.go @@ -14,6 +14,7 @@ import ( "github.com/go-gl/gl/v4.1-core/gl" "github.com/golang/freetype/truetype" "github.com/veandco/go-sdl2/sdl" + "golang.org/x/image/font" ) var _ engine.Game = &program{} @@ -33,11 +34,9 @@ type program struct { shouldDrawGrid bool } -//nTerm TODO: -// * Signed distance fields? - const subPixelX = 64 const subPixelY = 64 +const hinting = font.HintingNone func main() { @@ -87,7 +86,7 @@ func (p *program) Init() { fmt.Printf("DPI: %f, font size: %d\n", dpi, p.FontSize) w, h := p.win.SDLWin.GetSize() - p.GlyphRend, err = glyphs.NewGlyphRend("./res/fonts/Consolas.ttf", &truetype.Options{Size: float64(p.FontSize), DPI: p.Dpi, SubPixelsX: subPixelX, SubPixelsY: subPixelY}, w, h) + p.GlyphRend, err = glyphs.NewGlyphRend("./res/fonts/Consolas.ttf", &truetype.Options{Size: float64(p.FontSize), DPI: p.Dpi, SubPixelsX: subPixelX, SubPixelsY: subPixelY, Hinting: hinting}, w, h) if err != nil { panic("Failed to create atlas from font file. Err: " + err.Error()) } @@ -127,7 +126,7 @@ func (p *program) Update() { if fontSizeChanged { - err := p.GlyphRend.SetFace(&truetype.Options{Size: float64(p.FontSize), DPI: p.Dpi, SubPixelsX: subPixelX, SubPixelsY: subPixelY}) + err := p.GlyphRend.SetFace(&truetype.Options{Size: float64(p.FontSize), DPI: p.Dpi, SubPixelsX: subPixelX, SubPixelsY: subPixelY, Hinting: hinting}) if err != nil { p.FontSize = oldFont println("Failed to update font face. Err: " + err.Error())