Files
tiennm99bot/internal/modules/monkeyd/pdf/font.go
T
tiennm99 d211124aae refactor(monkeyd): port the crawler in-tree and drop the submodule
The monkeyd-crawler repository moved into tiennm99/mttools, so recursive
clones of the old submodule URL fail and block every deploy. The crawler,
PDF renderer, and export flow now live under internal/modules/monkeyd,
trimmed to the bot's use: a fixed phone page, the bundled font only, and
the font size as the single export option.
2026-10-03 11:23:45 +07:00

38 lines
1.2 KiB
Go

package pdf
import (
_ "embed"
)
// bundledTTF is the only font the bot renders with. A minimal container has no
// system fonts, and a single embedded font keeps the PDF identical on every
// host. See fonts/NOTICE.md for provenance and licensing.
//
// Vietnamese text needs the Latin Extended Additional block (ư, ạ, ế, ộ …);
// DejaVu Sans covers it, where a basic-Latin font would silently drop the
// diacritics.
//
//go:embed fonts/DejaVuSans.ttf
var bundledTTF []byte
// BundledFontName labels the embedded font in diagnostics. It is not a path;
// the font is compiled into the binary.
const BundledFontName = "DejaVu Sans (bundled)"
// Font is font data ready to embed in a PDF.
//
// The data is carried as bytes rather than as a path because fpdf joins a font
// path onto its own font directory, which it defaults to "." — turning an
// absolute path into a working-directory-relative one that resolves only when
// the process happens to run from the filesystem root.
type Font struct {
// Name identifies the font for diagnostics.
Name string
Data []byte
}
// BundledFont returns the font compiled into the binary.
func BundledFont() Font {
return Font{Name: BundledFontName, Data: bundledTTF}
}