From 67594636e7d5049c7e336f147f8130c3de74f073 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 16 Nov 2020 14:54:44 +0100 Subject: [PATCH] text: offset Weight constants so the zero value is normal text weight Signed-off-by: Elias Naur --- text/shaper.go | 3 --- text/text.go | 9 +++++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/text/shaper.go b/text/shaper.go index 880547ac..8e95befa 100644 --- a/text/shaper.go +++ b/text/shaper.go @@ -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 } diff --git a/text/text.go b/text/text.go index 3601e367..927ab118 100644 --- a/text/text.go +++ b/text/text.go @@ -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 {