fix(fonts): use new rasterizer, all icons work

This commit is contained in:
Bondrake 2024-04-21 01:32:00 +10:00 committed by Jan De Dobbeleer
parent 6c44459b6f
commit 64eeb400c5
2 changed files with 10 additions and 6 deletions

View file

@ -42,8 +42,8 @@ import (
"github.com/esimov/stackblur-go"
"github.com/fogleman/gg"
"github.com/golang/freetype/truetype"
"golang.org/x/image/font"
"golang.org/x/image/font/opentype"
)
type ConnectionError struct {
@ -217,7 +217,7 @@ func (ir *ImageRenderer) loadFonts() error {
// Download font if not cached
if data == nil {
url := "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.0/Hack.zip"
url := "https://github.com/ryanoasis/nerd-fonts/releases/download/v3.2.1/Hack.zip"
var err error
data, err = fontCLI.Download(url)
@ -237,7 +237,7 @@ func (ir *ImageRenderer) loadFonts() error {
return err
}
fontFaceOptions := &truetype.Options{Size: 2.0 * 12, DPI: 144}
fontFaceOptions := &opentype.FaceOptions{Size: 2.0 * 12, DPI: 144}
parseFont := func(file *zip.File) (font.Face, error) {
rc, err := file.Open()
@ -252,12 +252,16 @@ func (ir *ImageRenderer) loadFonts() error {
return nil, err
}
font, err := truetype.Parse(data)
font, err := opentype.Parse(data)
if err != nil {
return nil, err
}
return truetype.NewFace(font, fontFaceOptions), nil
fontFace, err := opentype.NewFace(font, fontFaceOptions)
if err != nil {
return nil, err
}
return fontFace, nil
}
for _, file := range zipReader.File {

View file

@ -10,7 +10,6 @@ require (
github.com/alecthomas/repr v0.4.0 // indirect
github.com/esimov/stackblur-go v1.1.0
github.com/fogleman/gg v1.3.0
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0
github.com/google/uuid v1.6.0 // indirect
github.com/gookit/color v1.5.4
github.com/huandu/xstrings v1.4.0 // indirect
@ -70,6 +69,7 @@ require (
github.com/containerd/console v1.0.4 // indirect
github.com/dsnet/compress v0.0.1 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect