mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-04 17:05:38 +00:00
text/shaper: lookup closest font by weight
Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
This commit is contained in:
committed by
Elias Naur
parent
23f6dcb868
commit
49a7b2e6f4
@@ -114,3 +114,15 @@ func (s Style) String() string {
|
||||
panic("invalid Style")
|
||||
}
|
||||
}
|
||||
|
||||
// weightDistance returns the distance value between two font weights.
|
||||
func weightDistance(wa Weight, wb Weight) int {
|
||||
// Avoid dealing with negative Weight values.
|
||||
a := int(wa) + 400
|
||||
b := int(wb) + 400
|
||||
diff := a - b
|
||||
if diff < 0 {
|
||||
return -diff
|
||||
}
|
||||
return diff
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user