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 <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2019-10-13 18:20:19 +02:00
parent 5a82fc9267
commit 481cca5781
+3 -1
View File
@@ -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 {