@@ -23,11 +23,12 @@ func splitCoverTextLines(pdf *fpdf.Fpdf, text string, maxW float64) []string {
2323 return lines2424 }2525 26-func splitCoverSubtitleLines(pdf *fpdf.Fpdf, subtitle string, maxW float64, maxLines int) []string {26+func splitClampedTextLines(pdf *fpdf.Fpdf, text string, maxW float64, maxLines int) []string {2727 if maxLines < 1 {2828 maxLines = 12929 }30- lines := splitCoverTextLines(pdf, subtitle, maxW)30+31+ lines := splitCoverTextLines(pdf, text, maxW)3132 if len(lines) <= maxLines {3233 return lines3334 }@@ -38,6 +39,10 @@ func splitCoverSubtitleLines(pdf *fpdf.Fpdf, subtitle string, maxW float64, maxL
3839 return out3940 }4041 42+func splitCoverSubtitleLines(pdf *fpdf.Fpdf, subtitle string, maxW float64, maxLines int) []string {43+ return splitClampedTextLines(pdf, subtitle, maxW, maxLines)44+}45+4146 func renderCoverPage(pdf *fpdf.Fpdf, _ []Puzzle, cfg RenderConfig, coverColor RGB) {4247 ink := RGB{R: 8, G: 8, B: 8}4348 @@ -50,9 +55,6 @@ func renderCoverPage(pdf *fpdf.Fpdf, _ []Puzzle, cfg RenderConfig, coverColor RG
5055 frameInset := 7.55156 drawCoverFrame(pdf, frameInset, pageW, pageH, ink)5257 53- scene := rectMM{x: frameInset + 4.0, y: frameInset + 10.0, w: pageW - (frameInset+4.0)*2, h: 132.0}54- drawCoverArtwork(pdf, scene, cfg.ShuffleSeed, coverColor, ink)55-5658 subtitle := strings.TrimSpace(cfg.CoverSubtitle)5759 if subtitle == "" {5860 subtitle = "PuzzleTea Collection"@@ -76,7 +78,7 @@ func renderCoverPage(pdf *fpdf.Fpdf, _ []Puzzle, cfg RenderConfig, coverColor RG
7678 pdf.SetFont(coverFontFamily, "", fontSize)7779 titleLines := splitCoverSubtitleLines(pdf, subtitle, labelW, 2)7880 lineH := fontSize * 0.4579- y := scene.y + scene.h + 8.581+ y := frameInset + 12.08082 for _, line := range titleLines {8183 pdf.SetXY(frameInset+6.0, y)8284 pdf.CellFormat(labelW, lineH, line, "", 0, "L", false, 0, "")@@ -98,18 +100,6 @@ func drawCoverFrame(pdf *fpdf.Fpdf, inset, pageW, pageH float64, ink RGB) {
98100 pdf.Rect(inner, inner, pageW-2*inner, pageH-2*inner, "D")99101 }100102 101-func drawCoverArtwork(pdf *fpdf.Fpdf, scene rectMM, seed string, bg, ink RGB) {102- drawCoverArtworkImage(pdf, scene, seed, "front", bg)103-104- pdf.SetDrawColor(int(ink.R), int(ink.G), int(ink.B))105- pdf.SetLineWidth(0.40)106- pdf.Rect(scene.x, scene.y, scene.w, scene.h, "D")107-108- pdf.SetLineWidth(0.20)109- inset := 1.8110- pdf.Rect(scene.x+inset, scene.y+inset, scene.w-2*inset, scene.h-2*inset, "D")111-}112-113103 func renderBackCoverPage(pdf *fpdf.Fpdf, cfg RenderConfig, coverColor RGB) {114104 ink := RGB{R: 8, G: 8, B: 8}115105 @@ -121,9 +111,6 @@ func renderBackCoverPage(pdf *fpdf.Fpdf, cfg RenderConfig, coverColor RGB) {
121111 frameInset := 7.5122112 drawCoverFrame(pdf, frameInset, pageW, pageH, ink)123113 124- motif := rectMM{x: frameInset + 5.5, y: frameInset + 14.0, w: pageW - 2*(frameInset+5.5), h: 96.0}125- drawBackMotif(pdf, motif, cfg.ShuffleSeed, coverColor, ink)126-127114 labelW := pageW - 2*(frameInset+6.0)128115 pdf.SetTextColor(int(ink.R), int(ink.G), int(ink.B))129116 pdf.SetFont(sansFontFamily, "B", 8.4)@@ -131,18 +118,16 @@ func renderBackCoverPage(pdf *fpdf.Fpdf, cfg RenderConfig, coverColor RGB) {
131118 pdf.CellFormat(labelW, 4.2, "PuzzleTea", "", 0, "L", false, 0, "")132119 133120 pdf.SetFont(sansFontFamily, "", 8.0)134- pdf.SetXY(frameInset+6.0, pageH-frameInset-17.0)135- pdf.CellFormat(labelW, 4.2, cfg.AdvertText, "", 0, "L", false, 0, "")121+ advertLines := splitCoverTextLines(pdf, cfg.AdvertText, labelW)122+ advertLineH := 4.2123+ advertY := pageH - frameInset - 17.0 - float64(len(advertLines)-1)*advertLineH124+ for _, line := range advertLines {125+ pdf.SetXY(frameInset+6.0, advertY)126+ pdf.CellFormat(labelW, advertLineH, line, "", 0, "L", false, 0, "")127+ advertY += advertLineH128+ }136129 137130 pdf.SetFont(sansFontFamily, "B", 8.2)138131 pdf.SetXY(frameInset+6.0, pageH-frameInset-10.5)139132 pdf.CellFormat(labelW, 4.2, fmt.Sprintf("VOL. %02d", cfg.VolumeNumber), "", 0, "L", false, 0, "")140133 }141-142-func drawBackMotif(pdf *fpdf.Fpdf, scene rectMM, seed string, bg, ink RGB) {143- drawCoverArtworkImage(pdf, scene, seed, "back", bg)144-145- pdf.SetDrawColor(int(ink.R), int(ink.G), int(ink.B))146- pdf.SetLineWidth(0.34)147- pdf.Rect(scene.x, scene.y, scene.w, scene.h, "D")148-}