Skip to content

Commit

Permalink
fontscan: add function to return all matched font locations
Browse files Browse the repository at this point in the history
  • Loading branch information
akiyosi authored and whereswaldon committed Dec 19, 2023
1 parent 4b4ad9c commit cc0073e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions fontscan/fontmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,22 @@ func (fm *FontMap) FindSystemFont(family string) (Location, bool) {
return Location{}, false
}

// FindSystemFonts is the same as FindSystemFont, but returns all matched fonts.
func (fm *FontMap) FindSystemFonts(family string) []Location {
var locations []Location
family = meta.NormalizeFamily(family)
for _, footprint := range fm.database {
if footprint.isUserProvided {
continue
}
if footprint.Family == family {
locations = append(locations, footprint.Location)
}
}

return locations
}

// SetQuery set the families and aspect required, influencing subsequent
// `ResolveFace` calls.
func (fm *FontMap) SetQuery(query Query) {
Expand Down

0 comments on commit cc0073e

Please sign in to comment.