This commit is contained in:
2026-10-23 00:55:44 +07:00
parent 146700cf4c
commit a9326ef3ed
5 changed files with 46 additions and 23 deletions
+5 -6
View File
@@ -152,8 +152,8 @@ func renderReceipt(card team_qr_pdf.Card) (*image.Gray, error) {
return nil, ErrInvalidReceipt
}
qrSize := len(bitmap) * scale
qrY := 16 + len(lines)*nameLineHeight + 16
height := qrY + qrSize + 24 + len(instructions)*26
qrY := 16 + len(instructions)*26 + 16
height := qrY + qrSize + 24 + len(lines)*nameLineHeight
for card.WiFiName != "" && height > receiptMaxHeight && nameSize > 16 {
_ = face.Close()
nameSize -= 2
@@ -163,8 +163,7 @@ func renderReceipt(card team_qr_pdf.Card) (*image.Gray, error) {
return nil, fmt.Errorf("resize receipt font: %w", err)
}
lines = wrapReceiptName(name, face)
qrY = 16 + len(lines)*nameLineHeight + 16
height = qrY + qrSize + 24 + len(instructions)*26
height = qrY + qrSize + 24 + len(lines)*nameLineHeight
}
if height > receiptMaxHeight {
return nil, ErrInvalidReceipt
@@ -174,7 +173,7 @@ func renderReceipt(card team_qr_pdf.Card) (*image.Gray, error) {
drawer := font.Drawer{Dst: img, Src: image.Black, Face: face}
for i, line := range lines {
width := drawer.MeasureString(line).Ceil()
drawer.Dot = fixed.P((receiptWidth-width)/2, 16+face.Metrics().Ascent.Ceil()+i*nameLineHeight)
drawer.Dot = fixed.P((receiptWidth-width)/2, qrY+qrSize+face.Metrics().Ascent.Ceil()+i*nameLineHeight)
drawer.DrawString(line)
}
x := (receiptWidth - qrSize) / 2
@@ -187,7 +186,7 @@ func renderReceipt(card team_qr_pdf.Card) (*image.Gray, error) {
}
drawer.Face = instructionFace
for i, line := range instructions {
drawer.Dot = fixed.P(16, qrY+qrSize+instructionFace.Metrics().Ascent.Ceil()+i*26)
drawer.Dot = fixed.P(16, 16+instructionFace.Metrics().Ascent.Ceil()+i*26)
drawer.DrawString(line)
}
for i, pixel := range img.Pix {