From 806750550a3a5ac241e2c6620a3b77eb07d2ab89 Mon Sep 17 00:00:00 2001 From: Walter Werner SCHNEIDER Date: Thu, 2 Sep 2021 23:01:38 +0300 Subject: [PATCH] text: add fmt.Stringer implementation for Weight Signed-off-by: Walter Werner SCHNEIDER --- text/text.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/text/text.go b/text/text.go index d4188c451..978ddb571 100644 --- a/text/text.go +++ b/text/text.go @@ -115,6 +115,33 @@ func (s Style) String() string { } } +func (w Weight) String() string { + switch w { + case Thin: + return "Thin" + case ExtraLight: + return "ExtraLight" + case Light: + return "Light" + case Normal: + return "Normal" + case Medium: + return "Medium" + case SemiBold: + return "SemiBold" + case Bold: + return "Bold" + case ExtraBold: + return "ExtraBold" + case Black: + return "Black" + case ExtraBlack: + return "ExtraBlack" + default: + panic("invalid Weight") + } +} + // weightDistance returns the distance value between two font weights. func weightDistance(wa Weight, wb Weight) int { // Avoid dealing with negative Weight values.