🎨 Improve export PDF footer font

This commit is contained in:
Liang Ding 2023-04-01 13:23:45 +08:00
parent 3eaa043889
commit 345857ae79
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
4 changed files with 47 additions and 27 deletions

View file

@ -40,7 +40,6 @@ import (
"github.com/88250/lute/parse"
"github.com/88250/lute/render"
"github.com/88250/pdfcpu/pkg/api"
"github.com/88250/pdfcpu/pkg/font"
"github.com/88250/pdfcpu/pkg/pdfcpu"
"github.com/Masterminds/sprig/v3"
"github.com/emirpasic/gods/sets/hashset"
@ -995,20 +994,7 @@ func processPDFFooter(pdfCtx *pdfcpu.Context) {
}
footer := buf.String()
fontName := "Helvetica"
names := font.UserFontNames()
if 1 > len(names) {
preferredFont := util.GetPreferredFontFilePath(Conf.Lang)
if err = api.InstallFonts([]string{preferredFont.Path}); nil != err {
logging.LogErrorf("install font failed: %s", err)
} else {
names = font.UserFontNames()
logging.LogInfof("install pdf font: %s", names)
}
}
if 0 < len(names) {
fontName = names[0]
}
fontName := util.InstallPDFFonts()
pos := "bc"
desc := fmt.Sprintf("font:%s, points:8, sc:1 abs, pos:%s, off:10 10, fillc: 0.5 0.5 0.5, rot:0", fontName, pos)