mirror of
https://github.com/bloeys/nterm.git
synced 2025-12-29 06:28:20 +00:00
Use vec2 for glyph model scale
This commit is contained in:
@ -148,8 +148,7 @@ func NewFontAtlasFromFont(f *truetype.Font, face font.Face, pointSize uint) (*Fo
|
||||
drawer.Dot = fixed.P(0, lineHeight)
|
||||
for _, g := range glyphs {
|
||||
|
||||
gBounds, gAdvanceFixed, _ := face.GlyphBounds(g)
|
||||
|
||||
gBounds, _, _ := face.GlyphBounds(g)
|
||||
ascent := absFixedI26_6(gBounds.Min.Y)
|
||||
descent := absFixedI26_6(gBounds.Max.Y)
|
||||
bearingX := absFixedI26_6(gBounds.Min.X)
|
||||
@ -165,7 +164,7 @@ func NewFontAtlasFromFont(f *truetype.Font, face font.Face, pointSize uint) (*Fo
|
||||
|
||||
//Get glyph to draw but undo any applied descent so that the glyph is drawn sitting on the line exactly.
|
||||
//Bearing will be applied correctly but descent will be the responsibility of the positioning code
|
||||
imgRect, mask, maskp, _, _ := face.Glyph(drawer.Dot, g)
|
||||
imgRect, mask, maskp, gAdvanceFixed, _ := face.Glyph(drawer.Dot, g)
|
||||
if imgRect.Max.Y > drawer.Dot.Y.Ceil() {
|
||||
diff := imgRect.Max.Y - drawer.Dot.Y.Ceil()
|
||||
imgRect.Min.Y -= diff
|
||||
|
||||
@ -64,7 +64,7 @@ func (gr *GlyphRend) DrawTextOpenGLAbs(text string, screenPos *gglm.Vec3, color
|
||||
}
|
||||
gr.GlyphCount++
|
||||
|
||||
scale := gglm.NewVec3(advanceF32, lineHeightF32, 1)
|
||||
scale := gglm.NewVec2(advanceF32, lineHeightF32)
|
||||
|
||||
//See: https://developer.apple.com/library/archive/documentation/TextFonts/Conceptual/CocoaTextArchitecture/Art/glyph_metrics_2x.png
|
||||
//The uvs coming in make it so that glyphs are sitting on top of the baseline (no descent) and with horizontal bearing applied.
|
||||
@ -77,7 +77,7 @@ func (gr *GlyphRend) DrawTextOpenGLAbs(text string, screenPos *gglm.Vec3, color
|
||||
g.U, g.V,
|
||||
color.R(), color.G(), color.B(), color.A(), //Color
|
||||
roundF32(drawPos.X()), roundF32(drawPos.Y()), drawPos.Z(), //Model pos
|
||||
scale.X(), scale.Y(), scale.Z(), //Model scale
|
||||
scale.X(), scale.Y(), //Model scale
|
||||
}...)
|
||||
|
||||
pos.SetX(pos.X() + advanceF32)
|
||||
@ -253,7 +253,7 @@ func NewGlyphRend(fontFile string, fontOptions *truetype.Options, screenWidth, s
|
||||
buffers.Element{ElementType: buffers.DataTypeVec2}, //UV0
|
||||
buffers.Element{ElementType: buffers.DataTypeVec4}, //Color
|
||||
buffers.Element{ElementType: buffers.DataTypeVec3}, //ModelPos
|
||||
buffers.Element{ElementType: buffers.DataTypeVec3}, //ModelScale
|
||||
buffers.Element{ElementType: buffers.DataTypeVec2}, //ModelScale
|
||||
)
|
||||
|
||||
gr.InstancedBuf.Bind()
|
||||
|
||||
Reference in New Issue
Block a user