From 9a1ef444bad25410cf43f2b4da324dd9c6b39369 Mon Sep 17 00:00:00 2001 From: Daniele Tonon Date: Thu, 23 Nov 2023 14:46:46 +0100 Subject: [PATCH] Fix line height for the textual sharing image --- render_image.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/render_image.go b/render_image.go index 14904af..546782d 100644 --- a/render_image.go +++ b/render_image.go @@ -179,14 +179,11 @@ func drawImage(lines []string, ttf *truetype.Font, style Style) (image.Image, er Hinting: font.HintingFull, })) + lineSpacing := 0.3 + lineHeight := float64(FONT_SIZE)*FONT_DPI/72.0 + float64(FONT_SIZE)*lineSpacing*FONT_DPI/72.0 for i, line := range lines { - img.DrawStringWrapped(line, - float64(10+paddingLeft), - float64(10+(i*FONT_SIZE*FONT_DPI*256.0/72.0)>>8), - 0, 0, - float64(width-10-paddingLeft), - float64(height-10), gg.AlignLeft, - ) + y := float64(i)*lineHeight + 50 // Calculate the Y position for each line + img.DrawString(line, float64(20+paddingLeft), y) // Draw the line at the calculated Y position } return img.Image(), nil }