mirror of
https://github.com/bloeys/nterm.git
synced 2025-12-29 14:38:19 +00:00
Advance by char width+better debug tools
This commit is contained in:
@ -35,6 +35,7 @@ type FontAtlasGlyph struct {
|
||||
Ascent float32
|
||||
Descent float32
|
||||
BearingX float32
|
||||
Advance float32
|
||||
}
|
||||
|
||||
//NewFontAtlasFromFile reads a TTF or TTC file and produces a font texture atlas containing
|
||||
@ -149,7 +150,7 @@ func NewFontAtlasFromFont(f *truetype.Font, face font.Face, pointSize uint) (*Fo
|
||||
|
||||
for currGlyphCount, g := range glyphs {
|
||||
|
||||
gBounds, _, _ := face.GlyphBounds(g)
|
||||
gBounds, gAdvance, _ := face.GlyphBounds(g)
|
||||
bearingX := gBounds.Min.X
|
||||
ascentAbsFixed := absFixedI26_6(gBounds.Min.Y)
|
||||
descentAbsFixed := absFixedI26_6(gBounds.Max.Y)
|
||||
@ -174,6 +175,7 @@ func NewFontAtlasFromFont(f *truetype.Font, face font.Face, pointSize uint) (*Fo
|
||||
Ascent: float32(ascentAbsFixed.Ceil()),
|
||||
Descent: float32(descentAbsFixed.Ceil()),
|
||||
BearingX: float32(bearingX.Ceil()),
|
||||
Advance: float32(gAdvance.Ceil()),
|
||||
}
|
||||
|
||||
imgRect, mask, maskp, _, _ := face.Glyph(drawer.Dot, g)
|
||||
|
||||
@ -178,15 +178,13 @@ func (gr *GlyphRend) drawRune(rs []rune, i int, prevRune rune, screenPos, pos *g
|
||||
*bufIndex += 2
|
||||
|
||||
gr.GlyphCount++
|
||||
pos.AddX(advanceF32)
|
||||
pos.AddX(g.Advance)
|
||||
|
||||
//If we fill the buffer we issue a draw call
|
||||
if gr.GlyphCount == MaxGlyphsPerBatch {
|
||||
gr.Draw()
|
||||
*bufIndex = 0
|
||||
}
|
||||
|
||||
// prevRune = r
|
||||
}
|
||||
|
||||
func (gr *GlyphRend) GetTextRuns(t string) [][]rune {
|
||||
|
||||
Reference in New Issue
Block a user