erm/app/fontinfo/matchers.go

27 lines
619 B
Go

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)
}
}