Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fontscan] Specify Location in AddFace #119

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading