text: offset Weight constants so the zero value is normal text weight

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-11-16 14:54:44 +01:00
parent 23fa3480c6
commit 67594636e7
2 changed files with 5 additions and 7 deletions
-3
View File
@@ -83,9 +83,6 @@ func NewCache(collection []FontFace) *Cache {
faces: make(map[Font]*faceCache),
}
for i, ff := range collection {
if ff.Font.Weight == 0 {
ff.Font.Weight = Normal
}
if i == 0 {
c.def = ff.Font.Typeface
}
+5 -4
View File
@@ -33,7 +33,8 @@ type Glyph struct {
// Style is the font style.
type Style int
// Weight is a font weight, in CSS units.
// Weight is a font weight, in CSS units subtracted 400 so the zero value
// is normal text weight.
type Weight int
// Font specify a particular typeface variant, style and weight.
@@ -73,9 +74,9 @@ const (
)
const (
Normal Weight = 400
Medium Weight = 500
Bold Weight = 600
Normal Weight = 400 - 400
Medium Weight = 500 - 400
Bold Weight = 600 - 400
)
func (a Alignment) String() string {