text: refactoring

This commit is contained in:
Hajime Hoshi 2023-11-19 17:37:25 +09:00
parent c45e9d0c00
commit 85fdf90d4d

View File

@ -66,14 +66,14 @@ func (f *testFace) Glyph(dot fixed.Point26_6, r rune) (dr image.Rectangle, mask
a := image.NewAlpha(dr) a := image.NewAlpha(dr)
switch r { switch r {
case 'a': case 'a':
for j := 0; j < testFaceSize; j++ { for j := dr.Min.Y; j < dr.Max.Y; j++ {
for i := 0; i < testFaceSize; i++ { for i := dr.Min.X; i < dr.Max.X; i++ {
a.SetAlpha(i, j, color.Alpha{A: 0x80}) a.SetAlpha(i, j, color.Alpha{A: 0x80})
} }
} }
case 'b': case 'b':
for j := 0; j < testFaceSize; j++ { for j := dr.Min.Y; j < dr.Max.Y; j++ {
for i := 0; i < testFaceSize; i++ { for i := dr.Min.X; i < dr.Max.X; i++ {
a.SetAlpha(i, j, color.Alpha{A: 0xff}) a.SetAlpha(i, j, color.Alpha{A: 0xff})
} }
} }
@ -109,15 +109,16 @@ func (f *testFace) Close() error {
func (f *testFace) Metrics() font.Metrics { func (f *testFace) Metrics() font.Metrics {
return font.Metrics{ return font.Metrics{
Height: fixed.I(testFaceSize), Height: fixed.I(testFaceSize),
Ascent: fixed.I(testFaceSize), Ascent: 0,
Descent: 0, Descent: fixed.I(testFaceSize),
XHeight: 0, XHeight: 0,
CapHeight: fixed.I(testFaceSize), CapHeight: fixed.I(testFaceSize),
CaretSlope: image.Pt(0, 1), CaretSlope: image.Pt(0, 1),
} }
} }
func TestTextOverlap(t *testing.T) { // Issue #1378
func TestNegativeKern(t *testing.T) {
f := &testFace{} f := &testFace{}
dst := ebiten.NewImage(testFaceSize*2, testFaceSize) dst := ebiten.NewImage(testFaceSize*2, testFaceSize)