fix(fonts): only install tff for CascadiaCode

This commit is contained in:
Jan De Dobbeleer 2024-12-22 17:27:45 +01:00 committed by Jan De Dobbeleer
parent 3b40f825c3
commit b4a51815f9

View file

@ -43,7 +43,7 @@ func Fonts() ([]*Asset, error) {
cascadiaCode, err := CascadiaCode() cascadiaCode, err := CascadiaCode()
if err == nil { if err == nil {
assets = append(assets, cascadiaCode...) assets = append(assets, cascadiaCode)
} }
sort.Slice(assets, func(i, j int) bool { return assets[i].Name < assets[j].Name }) sort.Slice(assets, func(i, j int) bool { return assets[i].Name < assets[j].Name })
@ -85,38 +85,16 @@ func setCachedFontData(assets []*Asset) {
cache.Set(cache_.FONTLISTCACHE, string(data), cache_.ONEDAY) cache.Set(cache_.FONTLISTCACHE, string(data), cache_.ONEDAY)
} }
func CascadiaCode() ([]*Asset, error) { func CascadiaCode() (*Asset, error) {
assets, err := fetchFontAssets("microsoft/cascadia-code") assets, err := fetchFontAssets("microsoft/cascadia-code")
if err != nil || len(assets) != 1 { if err != nil || len(assets) != 1 {
return nil, errors.New("no assets found") return nil, errors.New("no assets found")
} }
return []*Asset{ return &Asset{
{ Name: CascadiaCodeMS,
Name: fmt.Sprintf("%s - TTF", CascadiaCodeMS),
URL: assets[0].URL, URL: assets[0].URL,
Folder: "ttf/", Folder: "ttf/",
},
{
Name: fmt.Sprintf("%s - TTF Static", CascadiaCodeMS),
URL: assets[0].URL,
Folder: "ttf/static/",
},
{
Name: fmt.Sprintf("%s - OTF Static", CascadiaCodeMS),
URL: assets[0].URL,
Folder: "otf/static/",
},
{
Name: fmt.Sprintf("%s - WOFF2", CascadiaCodeMS),
URL: assets[0].URL,
Folder: "woff2/static/",
},
{
Name: fmt.Sprintf("%s - WOFF2 Static", CascadiaCodeMS),
URL: assets[0].URL,
Folder: "woff2/static/",
},
}, nil }, nil
} }