mirror of
https://github.com/bloeys/nterm.git
synced 2025-12-29 06:28:20 +00:00
Remove commented out code
This commit is contained in:
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
9
main.go
9
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())
|
||||
|
||||
Reference in New Issue
Block a user