add Text.Bounds, Atlas.Ascent, Atlas.Descent
This commit is contained in:
parent
e9a3c900cf
commit
c47d77b2b5
|
@ -20,6 +20,8 @@ type Atlas struct {
|
||||||
pic pixel.Picture
|
pic pixel.Picture
|
||||||
mapping map[rune]Glyph
|
mapping map[rune]Glyph
|
||||||
kern map[struct{ r0, r1 rune }]float64
|
kern map[struct{ r0, r1 rune }]float64
|
||||||
|
ascent float64
|
||||||
|
descent float64
|
||||||
lineHeight float64
|
lineHeight float64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,10 +97,12 @@ func NewAtlas(face font.Face, runes []rune) *Atlas {
|
||||||
}
|
}
|
||||||
|
|
||||||
return &Atlas{
|
return &Atlas{
|
||||||
pixel.PictureDataFromImage(atlasImg),
|
pic: pixel.PictureDataFromImage(atlasImg),
|
||||||
mapping,
|
mapping: mapping,
|
||||||
kern,
|
kern: kern,
|
||||||
float64(face.Metrics().Height) / (1 << 6),
|
ascent: float64(face.Metrics().Ascent) / (1 << 6),
|
||||||
|
descent: float64(face.Metrics().Descent) / (1 << 6),
|
||||||
|
lineHeight: float64(face.Metrics().Height) / (1 << 6),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +123,14 @@ func (a *Atlas) Kern(r0, r1 rune) float64 {
|
||||||
return a.kern[struct{ r0, r1 rune }{r0, r1}]
|
return a.kern[struct{ r0, r1 rune }{r0, r1}]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *Atlas) Ascent() float64 {
|
||||||
|
return a.ascent
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Atlas) Descent() float64 {
|
||||||
|
return a.descent
|
||||||
|
}
|
||||||
|
|
||||||
func (a *Atlas) LineHeight() float64 {
|
func (a *Atlas) LineHeight() float64 {
|
||||||
return a.lineHeight
|
return a.lineHeight
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue