mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 12:08:58 +01:00
text: fix typos and add fields to struct initializers (#2556)
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
This commit is contained in:
parent
7502da50ba
commit
04170d628f
@ -270,7 +270,7 @@ func DrawWithOptions(dst *ebiten.Image, text string, face font.Face, options *eb
|
|||||||
|
|
||||||
// cacheSoftLimit indicates the soft limit of the number of glyphs in the cache.
|
// cacheSoftLimit indicates the soft limit of the number of glyphs in the cache.
|
||||||
// If the number of glyphs exceeds this soft limits, old glyphs are removed.
|
// If the number of glyphs exceeds this soft limits, old glyphs are removed.
|
||||||
// Even after clearning up the cache, the number of glyphs might still exceeds the soft limit, but
|
// Even after cleaning up the cache, the number of glyphs might still exceed the soft limit, but
|
||||||
// this is fine.
|
// this is fine.
|
||||||
const cacheSoftLimit = 512
|
const cacheSoftLimit = 512
|
||||||
|
|
||||||
@ -363,7 +363,7 @@ func BoundString(face font.Face, text string) image.Rectangle {
|
|||||||
//
|
//
|
||||||
// If a rune's glyph is already cached, CacheGlyphs does nothing for the rune.
|
// If a rune's glyph is already cached, CacheGlyphs does nothing for the rune.
|
||||||
//
|
//
|
||||||
// One rune can have multiple varitations of glyphs due to sub-pixels in X direction.
|
// One rune can have multiple variations of glyphs due to sub-pixels in X direction.
|
||||||
// CacheGlyphs creates all such variations for one rune, while Draw creates only necessary glyphs.
|
// CacheGlyphs creates all such variations for one rune, while Draw creates only necessary glyphs.
|
||||||
func CacheGlyphs(face font.Face, text string) {
|
func CacheGlyphs(face font.Face, text string) {
|
||||||
textM.Lock()
|
textM.Lock()
|
||||||
@ -435,7 +435,7 @@ func (f faceWithLineHeight) Metrics() font.Metrics {
|
|||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
// Glyphs is information to render one glyph.
|
// Glyph is information to render one glyph.
|
||||||
type Glyph struct {
|
type Glyph struct {
|
||||||
// Rune is a character for this glyph.
|
// Rune is a character for this glyph.
|
||||||
Rune rune
|
Rune rune
|
||||||
@ -484,7 +484,6 @@ func AppendGlyphs(glyphs []Glyph, face font.Face, text string) []Glyph {
|
|||||||
Y: b.Min.Y & ((1 << 6) - 1),
|
Y: b.Min.Y & ((1 << 6) - 1),
|
||||||
}
|
}
|
||||||
if img := getGlyphImage(face, r, offset); img != nil {
|
if img := getGlyphImage(face, r, offset); img != nil {
|
||||||
b := getGlyphBounds(face, r)
|
|
||||||
// Adjust the position to the integers.
|
// Adjust the position to the integers.
|
||||||
// The current glyph images assume that they are rendered on integer positions so far.
|
// The current glyph images assume that they are rendered on integer positions so far.
|
||||||
glyphs = append(glyphs, Glyph{
|
glyphs = append(glyphs, Glyph{
|
||||||
|
@ -33,7 +33,7 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestTextColor(t *testing.T) {
|
func TestTextColor(t *testing.T) {
|
||||||
clr := color.RGBA{0x80, 0x80, 0x80, 0x80}
|
clr := color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}
|
||||||
img := ebiten.NewImage(30, 30)
|
img := ebiten.NewImage(30, 30)
|
||||||
text.Draw(img, "Hello", bitmapfont.Face, 12, 12, clr)
|
text.Draw(img, "Hello", bitmapfont.Face, 12, 12, clr)
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ func TestTextColor(t *testing.T) {
|
|||||||
for j := 0; j < h; j++ {
|
for j := 0; j < h; j++ {
|
||||||
for i := 0; i < w; i++ {
|
for i := 0; i < w; i++ {
|
||||||
got := img.At(i, j)
|
got := img.At(i, j)
|
||||||
want1 := color.RGBA{0x80, 0x80, 0x80, 0x80}
|
want1 := color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}
|
||||||
want2 := color.RGBA{}
|
want2 := color.RGBA{}
|
||||||
if got != want1 && got != want2 {
|
if got != want1 && got != want2 {
|
||||||
t.Errorf("img At(%d, %d): got %v; want %v or %v", i, j, got, want1, want2)
|
t.Errorf("img At(%d, %d): got %v; want %v or %v", i, j, got, want1, want2)
|
||||||
@ -68,13 +68,13 @@ func (f *testFace) Glyph(dot fixed.Point26_6, r rune) (dr image.Rectangle, mask
|
|||||||
case 'a':
|
case 'a':
|
||||||
for j := 0; j < testFaceSize; j++ {
|
for j := 0; j < testFaceSize; j++ {
|
||||||
for i := 0; i < testFaceSize; i++ {
|
for i := 0; i < testFaceSize; i++ {
|
||||||
a.SetAlpha(i, j, color.Alpha{0x80})
|
a.SetAlpha(i, j, color.Alpha{A: 0x80})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 'b':
|
case 'b':
|
||||||
for j := 0; j < testFaceSize; j++ {
|
for j := 0; j < testFaceSize; j++ {
|
||||||
for i := 0; i < testFaceSize; i++ {
|
for i := 0; i < testFaceSize; i++ {
|
||||||
a.SetAlpha(i, j, color.Alpha{0xff})
|
a.SetAlpha(i, j, color.Alpha{A: 0xff})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ func TestTextOverlap(t *testing.T) {
|
|||||||
for j := 0; j < testFaceSize; j++ {
|
for j := 0; j < testFaceSize; j++ {
|
||||||
for i := 0; i < testFaceSize; i++ {
|
for i := 0; i < testFaceSize; i++ {
|
||||||
got := dst.At(i, j)
|
got := dst.At(i, j)
|
||||||
want := color.RGBA{0xff, 0xff, 0xff, 0xff}
|
want := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ func TestTextOverlap(t *testing.T) {
|
|||||||
for j := 0; j < testFaceSize; j++ {
|
for j := 0; j < testFaceSize; j++ {
|
||||||
for i := testFaceSize; i < testFaceSize*2; i++ {
|
for i := testFaceSize; i < testFaceSize*2; i++ {
|
||||||
got := dst.At(i, j)
|
got := dst.At(i, j)
|
||||||
want := color.RGBA{0x80, 0x80, 0x80, 0x80}
|
want := color.RGBA{R: 0x80, G: 0x80, B: 0x80, A: 0x80}
|
||||||
if got != want {
|
if got != want {
|
||||||
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
t.Errorf("At(%d, %d): got: %v, want: %v", i, j, got, want)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user