From e980ef85d142ecfe194c130a0a076c8262f85e21 Mon Sep 17 00:00:00 2001 From: akiyosi Date: Mon, 18 Dec 2023 01:34:08 +0900 Subject: [PATCH] fontscan: add function to return all matched font locations --- fontscan/fontmap.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fontscan/fontmap.go b/fontscan/fontmap.go index 9a09d9c..e0a26c3 100644 --- a/fontscan/fontmap.go +++ b/fontscan/fontmap.go @@ -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) {