mirror of
https://github.com/bloeys/nterm.git
synced 2025-12-29 14:38:19 +00:00
Use accurate space advance+correct grid drawing
This commit is contained in:
@ -152,7 +152,7 @@ func NewFontAtlasFromFont(f *truetype.Font, face font.Face, pointSize uint) (*Fo
|
|||||||
Img: image.NewRGBA(image.Rect(0, 0, atlasSizeX, atlasSizeY)),
|
Img: image.NewRGBA(image.Rect(0, 0, atlasSizeX, atlasSizeY)),
|
||||||
Glyphs: make(map[rune]FontAtlasGlyph, len(glyphs)),
|
Glyphs: make(map[rune]FontAtlasGlyph, len(glyphs)),
|
||||||
|
|
||||||
SpaceAdvance: float32(spaceAdv.Ceil()),
|
SpaceAdvance: I26_6ToF32(spaceAdv),
|
||||||
LineHeight: float32(lineHeight.Ceil()),
|
LineHeight: float32(lineHeight.Ceil()),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,8 +165,7 @@ func NewFontAtlasFromFont(f *truetype.Font, face font.Face, pointSize uint) (*Fo
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Put glyphs on atlas
|
//Put glyphs on atlas
|
||||||
drawer.Dot = fixed.P(int(atlas.SpaceAdvance), 0)
|
drawer.Dot.X = spaceAdv + charPaddingXFixed
|
||||||
drawer.Dot.X += charPaddingXFixed
|
|
||||||
drawer.Dot.Y = lineHeight
|
drawer.Dot.Y = lineHeight
|
||||||
|
|
||||||
const drawBoundingBoxes bool = false
|
const drawBoundingBoxes bool = false
|
||||||
|
|||||||
4
main.go
4
main.go
@ -249,8 +249,8 @@ func (p *program) drawGrid() {
|
|||||||
|
|
||||||
//columns
|
//columns
|
||||||
adv := p.GlyphRend.Atlas.SpaceAdvance
|
adv := p.GlyphRend.Atlas.SpaceAdvance
|
||||||
for i := int32(0); i < p.GlyphRend.ScreenWidth; i += int32(adv) {
|
for i := 0; i < int(p.GlyphRend.ScreenWidth); i++ {
|
||||||
p.rend.Draw(p.gridMesh, gglm.NewTrMatId().Translate(gglm.NewVec3(float32(i)+0.5, sizeY/2, 0)).Scale(gglm.NewVec3(1, sizeY, 1)), p.gridMat)
|
p.rend.Draw(p.gridMesh, gglm.NewTrMatId().Translate(gglm.NewVec3(adv*float32(i), sizeY/2, 0)).Scale(gglm.NewVec3(1, sizeY, 1)), p.gridMat)
|
||||||
}
|
}
|
||||||
|
|
||||||
//rows
|
//rows
|
||||||
|
|||||||
Reference in New Issue
Block a user