From 481cca5781448a3e9a18df281f84cdf654ad5ba5 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Sun, 13 Oct 2019 18:20:19 +0200 Subject: [PATCH] text: use the first registered font as the default in Shaper Before this change, the default font was the one registered with an empty Typeface. We're about to use the correct names for fonts, so change Shaper to fallback to the first registered typeface instead. Signed-off-by: Elias Naur --- text/shaper.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/text/shaper.go b/text/shaper.go index f30ef3cc..079ae9fe 100644 --- a/text/shaper.go +++ b/text/shaper.go @@ -14,6 +14,7 @@ import ( // Specify the default and fallback font by calling Register with the // empty Font. type Shaper struct { + def Typeface faces map[Font]*face } @@ -25,6 +26,7 @@ type face struct { func (s *Shaper) Register(font Font, tf Face) { if s.faces == nil { + s.def = font.Typeface s.faces = make(map[Font]*face) } // Treat all font sizes equally. @@ -72,7 +74,7 @@ func (s *Shaper) faceForFont(font Font) *face { font.Size = unit.Value{} tf := s.faceForStyle(font) if tf == nil { - font.Typeface = "" + font.Typeface = s.def tf = s.faceForStyle(font) } if tf == nil {