From 85bced7801875e6cc754bb943dcf1572c748c429 Mon Sep 17 00:00:00 2001 From: Bruno Reis Date: Fri, 10 Aug 2018 23:25:01 -0700 Subject: [PATCH] tests and fixes #123, SIGSEGV on text.NewAtlas if glyph absent --- text/atlas.go | 5 +++-- text/atlas_test.go | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/text/atlas.go b/text/atlas.go index b7ddf43..2430a32 100644 --- a/text/atlas.go +++ b/text/atlas.go @@ -60,8 +60,9 @@ func NewAtlas(face font.Face, runeSets ...[]rune) *Atlas { )) for r, fg := range fixedMapping { - dr, mask, maskp, _, _ := face.Glyph(fg.dot, r) - draw.Draw(atlasImg, dr, mask, maskp, draw.Src) + if dr, mask, maskp, _, ok := face.Glyph(fg.dot, r); ok { + draw.Draw(atlasImg, dr, mask, maskp, draw.Src) + } } bounds := pixel.R( diff --git a/text/atlas_test.go b/text/atlas_test.go index 2cb99bb..fdb69b0 100644 --- a/text/atlas_test.go +++ b/text/atlas_test.go @@ -4,6 +4,7 @@ import ( "testing" "github.com/faiface/pixel/text" + "golang.org/x/image/font/inconsolata" ) func TestAtlas7x13(t *testing.T) { @@ -22,3 +23,7 @@ func TestAtlas7x13(t *testing.T) { } } } + +func TestAtlasInconsolata(t *testing.T) { + text.NewAtlas(inconsolata.Regular8x16, text.ASCII) +}