From ab08d42a8a37c5f1d5a4481aca35e70bd05b643a Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Wed, 19 Aug 2015 16:33:39 +1000 Subject: [PATCH] shiny/font: add Hinting, Stretch, Style and Weight option types. These will be used by other vector font packages, such as the truetype package, to select specific faces. Change-Id: I3db8c97335089c2076811e8f85d9a8868fc900bd Reviewed-on: https://go-review.googlesource.com/13714 Reviewed-by: Rob Pike --- font/font.go | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/font/font.go b/font/font.go index b3647f5..c370986 100644 --- a/font/font.go +++ b/font/font.go @@ -108,3 +108,59 @@ func (d *Drawer) DrawString(s string) { d.Dot, prevC = newDot, c } } + +// Hinting selects how to quantize a vector font's glyph nodes. +// +// Not all fonts support hinting. +type Hinting int + +const ( + HintingNone Hinting = iota + HintingVertical + HintingFull +) + +// Stretch selects a normal, condensed, or expanded face. +// +// Not all fonts support stretches. +type Stretch int + +const ( + StretchUltraCondensed Stretch = -4 + StretchExtraCondensed Stretch = -3 + StretchCondensed Stretch = -2 + StretchSemiCondensed Stretch = -1 + StretchNormal Stretch = +0 + StretchSemiExpanded Stretch = +1 + StretchExpanded Stretch = +2 + StretchExtraExpanded Stretch = +3 + StretchUltraExpanded Stretch = +4 +) + +// Style selects a normal, italic, or oblique face. +// +// Not all fonts support styles. +type Style int + +const ( + StyleNormal Style = iota + StyleItalic + StyleOblique +) + +// Weight selects a normal, light or bold face. +// +// Not all fonts support weights. +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 +)