Merge remote-tracking branch 'origin/master'

This commit is contained in:
2026-02-16 11:59:14 +03:00
parent 96b973b71f
commit ec6d547641
2 changed files with 40 additions and 43 deletions

View File

@@ -9,31 +9,21 @@ import (
"github.com/jung-kurt/gofpdf"
)
func resolvePdfAssetPath(file string) (string, error) {
func resolvePdfAssetPath(name string) (string, error) {
envMap := map[string]string{
"DejaVuSans.ttf": "PDF_FONT_PATH",
"DejaVuSans-Bold.ttf": "PDF_FONT_BOLD_PATH",
"FreeSans.ttf": "PDF_FONT_ALT_PATH",
"FreeSansBold.ttf": "PDF_FONT_ALT_BOLD_PATH",
base := strings.TrimSpace(os.Getenv("PDF_FONT_DIR"))
if base == "" {
base = "/opt/bssapp/svc/fonts"
}
envKey, ok := envMap[file]
if !ok {
return "", fmt.Errorf("unknown font: %s", file)
p := filepath.Join(base, name)
if _, err := os.Stat(p); err != nil {
return "", fmt.Errorf("font not found: %s", p)
}
path := os.Getenv(envKey)
if path == "" {
return "", fmt.Errorf("env %s not set", envKey)
}
if _, err := os.Stat(path); err != nil {
return "", fmt.Errorf("font not found: %s", path)
}
return path, nil
return p, nil
}
func resolvePdfImagePath(fileName string) (string, error) {