This commit is contained in:
2026-10-12 15:58:24 +07:00
parent 0e20c3e151
commit 7fe8c6a5f0
18 changed files with 1314 additions and 149 deletions
+6 -1
View File
@@ -25,6 +25,11 @@ type Card struct {
//go:embed fonts/DejaVuSansCondensed.ttf
var font []byte
// RegisterFont adds the existing Cyrillic print font to a PDF document.
func RegisterFont(pdf *fpdf.Fpdf) {
pdf.AddUTF8FontFromBytes("teams", "", font)
}
// Generate returns a PDF containing team QR-code cards.
func Generate(cards []Card) ([]byte, error) {
if len(cards) == 0 {
@@ -33,7 +38,7 @@ func Generate(cards []Card) ([]byte, error) {
pdf := fpdf.New("P", "mm", "A4", "")
pdf.SetAutoPageBreak(false, 0)
pdf.SetCellMargin(0)
pdf.AddUTF8FontFromBytes("teams", "", font)
RegisterFont(pdf)
pdf.SetFillColor(0, 0, 0)
const margin, width, height, qrSize = 10.0, 190.0 / 3, 277.0 / 4, 36.0
for i, card := range cards {