Skip to content

Commit fca26ec

Browse files
committed
"The Gang Fixes The Offset Problem Properly"
1 parent 77f23a7 commit fca26ec

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

main.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ const (
2020
fontsize = 120
2121
linepadding = 32
2222
dpi = 72
23-
offsetX = -32 // it's off to the left so i'm just gonna fix it like this cuz i'm lazy LMAO
24-
offsetY = 0
2523
maxLineWidth = 1800 // anything higher results in weirdness
2624
)
2725

@@ -71,17 +69,18 @@ func main() {
7169
linelength := d.MeasureString(textsplit[i] + word).Round()
7270
if linelength >= maxLineWidth {
7371
i++
74-
textsplit = append(textsplit, "")
72+
textsplit = append(textsplit, word)
73+
} else {
74+
textsplit[i] += " " + word
7575
}
76-
textsplit[i] += " " + word
7776
}
7877
// write the text to the image
7978
lines := len(textsplit)
8079
fmt.Printf("Split into %d lines\n", lines)
8180
for line := 0; line < lines; line++ {
8281
linelength := d.MeasureString(textsplit[line]).Round()
8382
y := ((height - ((fontsize + linepadding) * lines)) / 2) + ((fontsize + linepadding) * (line + 1)) - linepadding
84-
d.Dot = freetype.Pt((width-linelength)/2+offsetX, y+offsetY)
83+
d.Dot = freetype.Pt((width-linelength)/2, y)
8584
d.DrawString(textsplit[line])
8685
}
8786
// write image to disk

0 commit comments

Comments
 (0)