Skip to content

Commit

Permalink
[fontscan] specify Location in AddFace, closes #112
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitkugler committed Dec 2, 2023
1 parent 0024ac6 commit 5525c8c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions fontscan/fontmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ func (fm *FontMap) AddFont(fontFile font.Resource, fileID, familyName string) er
//
// The order of calls to [AddFont] and [AddFace] determines relative priority
// of manually loaded fonts. See [ResolveFace] for details about when this matters.
func (fm *FontMap) AddFace(face font.Face, md meta.Description) {
fp := newFootprintFromFont(face.Font, md)
func (fm *FontMap) AddFace(face font.Face, location Location, md meta.Description) {
fp := newFootprintFromFont(face.Font, location, md)
fm.cache(fp, face)

fm.appendFootprints(fp)
Expand Down
2 changes: 1 addition & 1 deletion fontscan/fontmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func ExampleFontMap_AddFace() {
md := meta.Metadata(ld)
f, _ := fontapi.NewFont(ld) // error handling omitted
fontMap := NewFontMap(log.Default())
fontMap.AddFace(&fontapi.Face{Font: f}, md)
fontMap.AddFace(&fontapi.Face{Font: f}, Location{File: fmt.Sprint(md)}, md)

// set the font description
fontMap.SetQuery(Query{Families: []string{"Arial", "serif"}}) // regular Aspect
Expand Down
4 changes: 2 additions & 2 deletions fontscan/footprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ type footprint struct {
isUserProvided bool
}

func newFootprintFromFont(f font.Font, md meta.Description) (out footprint) {
func newFootprintFromFont(f font.Font, location Location, md meta.Description) (out footprint) {
out.Runes, out.scripts, _ = newCoveragesFromCmap(f.Cmap, nil)
out.langs = newLangsetFromCoverage(out.Runes)
out.Family = meta.NormalizeFamily(md.Family)
out.Aspect = md.Aspect
out.Location.File = fmt.Sprintf("%v", md)
out.Location = location
out.isUserProvided = true
return out
}
Expand Down

0 comments on commit 5525c8c

Please sign in to comment.