From 8ec4304eca6404977bb7c87477f0377ba8c4a57b Mon Sep 17 00:00:00 2001 From: HXY <2479895356@qq.com> Date: Thu, 7 Sep 2023 13:14:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=AD=97=E4=BD=93=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/servants/web/utils.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/servants/web/utils.go b/internal/servants/web/utils.go index 77a13ab7..bd51fe35 100644 --- a/internal/servants/web/utils.go +++ b/internal/servants/web/utils.go @@ -19,6 +19,7 @@ import ( "io/ioutil" "log" "math/rand" + "path/filepath" "strings" "time" "unicode/utf8" @@ -159,7 +160,10 @@ func createAvatar(size int, bgColor color.RGBA, text string) image.Image { // 在头像上绘制文字 textColor := color.RGBA{255, 255, 255, 255} // 白色文字 - fontBytes, err := ioutil.ReadFile("internal/servants/web/typeface/TTF/SourceSans3-Black.ttf") + path, _ := filepath.Abs("./internal/servants/web/typeface/TTF/SourceSans3-Black.ttf") + fmt.Println(path) + + fontBytes, err := ioutil.ReadFile(path) if err != nil { log.Println("unable to read font file:", err) return avatar