mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 11:18:54 +01:00
text/v2: refactoring
This commit is contained in:
parent
5354ccc44f
commit
4694b78d54
@ -179,7 +179,7 @@ func MustParseTag(str string) Tag {
|
|||||||
|
|
||||||
// Metrics implements Face.
|
// Metrics implements Face.
|
||||||
func (g *GoTextFace) Metrics() Metrics {
|
func (g *GoTextFace) Metrics() Metrics {
|
||||||
scale := float64(g.SizeInPoints) / float64(g.Source.f.Font.Upem())
|
scale := g.Source.scale(g.SizeInPoints)
|
||||||
|
|
||||||
var m Metrics
|
var m Metrics
|
||||||
if h, ok := g.Source.f.FontHExtents(); ok {
|
if h, ok := g.Source.f.FontHExtents(); ok {
|
||||||
|
@ -178,7 +178,7 @@ func (g *GoTextFaceSource) shape(text string, face *GoTextFace) (shaping.Output,
|
|||||||
}
|
}
|
||||||
|
|
||||||
scaledSegs := make([]api.Segment, len(segs))
|
scaledSegs := make([]api.Segment, len(segs))
|
||||||
scale := fixed26_6ToFloat32(out.Size) / float32(out.Face.Font.Upem())
|
scale := float32(g.scale(fixed26_6ToFloat64(out.Size)))
|
||||||
for i, seg := range segs {
|
for i, seg := range segs {
|
||||||
scaledSegs[i] = seg
|
scaledSegs[i] = seg
|
||||||
for j := range seg.Args {
|
for j := range seg.Args {
|
||||||
@ -214,3 +214,7 @@ func (g *GoTextFaceSource) shape(text string, face *GoTextFace) (shaping.Output,
|
|||||||
|
|
||||||
return out, gs
|
return out, gs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (g *GoTextFaceSource) scale(sizeInPoints float64) float64 {
|
||||||
|
return sizeInPoints / float64(g.f.Upem())
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user