erm/app/fontinfo/matchers.go

27 lines
619 B
Go
Raw Permalink Normal View History

2023-01-16 06:03:38 +00:00
package fontinfo
import (
"strings"
)
type Matcher func(m *FontMetadata) bool
// MatchFamily is a matcher which matches fonts with the specified font family (case insensitive)
func MatchFamily(family string) Matcher {
return func(m *FontMetadata) bool {
return strings.EqualFold(m.FontFamily, family)
}
}
// MatchStyle is a matcher which matches fonts with the specified font family (case insensitive)
func MatchStyle(style string) Matcher {
if style == "*" {
return func(m *FontMetadata) bool {
return true
}
}
return func(m *FontMetadata) bool {
return strings.EqualFold(m.FontStyle, style)
}
}