Skip to content

Commit b70adf5

Browse files
TakWolfftsf
authored andcommitted
Fix print font lineHeight calculate
1 parent 46c67a7 commit b70adf5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

nico.nim

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ proc glyph*(c: Rune, x,y: Pint, scale: Pint = 1): Pint {.discardable, inline.}
148148
proc glyph*(c: char, x,y: Pint, scale: Pint = 1): Pint {.discardable, inline.}
149149

150150
proc cursor*(x,y: Pint) # set cursor position
151-
proc print*(text: string) # print at cursor
151+
proc print*(text: string, scale: Pint = 1) # print at cursor
152152
proc print*(text: string, x,y: Pint, scale: Pint = 1)
153153
proc printc*(text: string, x,y: Pint, scale: Pint = 1) # centered
154154
proc printr*(text: string, x,y: Pint, scale: Pint = 1) # right aligned
@@ -2249,21 +2249,23 @@ proc print*(text: string, x,y: Pint, scale: Pint = 1) =
22492249
var x = x
22502250
var y = y
22512251
let ix = x
2252+
let lineHeight = fontHeight() + scale
22522253
for line in text.splitLines:
22532254
for c in line.runes:
22542255
x += glyph(c, x, y, scale)
22552256
x = ix
2256-
y += currentFont.h
2257+
y += lineHeight
22572258

2258-
proc print*(text: string) =
2259+
proc print*(text: string, scale: Pint = 1) =
22592260
## prints a string using the current font at cursor position
22602261
if currentFont == nil:
22612262
raise newException(Exception, "No font selected")
22622263
var x = cursorX
22632264
let y = cursorY
2265+
let lineHeight = fontHeight() + scale
22642266
for c in text.runes:
2265-
x += glyph(c, x, y, 1)
2266-
cursorY += 6
2267+
x += glyph(c, x, y, scale)
2268+
cursorY += lineHeight
22672269

22682270
proc glyphWidth*(c: Rune, scale: Pint = 1): Pint =
22692271
## returns the width of the glyph in the current font

0 commit comments

Comments
 (0)