Skip to content

Commit

Permalink
text: add fmt.Stringer implementation for Weight
Browse files Browse the repository at this point in the history
Signed-off-by: Walter Werner SCHNEIDER <[email protected]>
  • Loading branch information
SchnWalter authored and eliasnaur committed Sep 5, 2021
1 parent 03cfe55 commit 8067505
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions text/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8067505

Please sign in to comment.