From 8b5ac8f8e598a62e443f4797fd70f6387ce04ab8 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Sat, 2 Apr 2016 11:44:24 +1100 Subject: [PATCH] image/font: make a zero Weight mean a normal weight. Change-Id: I2000bdf1c49174b9eaefe1c680138392e3434ace Reviewed-on: https://go-review.googlesource.com/21440 Reviewed-by: David Crawshaw --- font/font.go | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/font/font.go b/font/font.go index c3041d9..31e48c9 100644 --- a/font/font.go +++ b/font/font.go @@ -205,16 +205,21 @@ const ( // Weight selects a normal, light or bold face. // // Not all fonts support weights. +// +// The named Weight constants (e.g. WeightBold) correspond to CSS' common +// weight names (e.g. "Bold"), but the numerical values differ, so that in Go, +// the zero value means to use a normal weight. For the CSS names and values, +// see https://developer.mozilla.org/en/docs/Web/CSS/font-weight type Weight int const ( - WeightThin Weight = 100 - WeightExtraLight Weight = 200 - WeightLight Weight = 300 - WeightNormal Weight = 400 - WeightMedium Weight = 500 - WeightSemiBold Weight = 600 - WeightBold Weight = 700 - WeightExtraBold Weight = 800 - WeightBlack Weight = 900 + WeightThin Weight = -3 // CSS font-weight value 100. + WeightExtraLight Weight = -2 // CSS font-weight value 200. + WeightLight Weight = -1 // CSS font-weight value 300. + WeightNormal Weight = +0 // CSS font-weight value 400. + WeightMedium Weight = +1 // CSS font-weight value 500. + WeightSemiBold Weight = +2 // CSS font-weight value 600. + WeightBold Weight = +3 // CSS font-weight value 700. + WeightExtraBold Weight = +4 // CSS font-weight value 800. + WeightBlack Weight = +5 // CSS font-weight value 900. )