ftsf / nico

a Game Framework in Nim inspired by Pico-8.
MIT License
624 stars 35 forks source link

Remove font print engine generated char_gap and line_gap #118

Closed TakWolf closed 7 months ago

TakWolf commented 1 year ago

Try to fix: https://github.com/ftsf/nico/issues/115

Pay attention!

This is an incompatible change for who use custom font. They need update font png.

ftsf commented 1 year ago

I think you are correct that it's a better behaviour, but I think keeping backwards compatibility for old fonts would be important. We could have an optional parameter in loadFont or use a different function for the new version.

TakWolf commented 1 year ago

I'm just pointing out the issues, please design a better API.

ftsf commented 1 year ago

Thanks for improving on it!

We need to continue to support existing users when possible, otherwise all old games' fonts will break with the new version.

We can make the loadFont command accept an argument for spacing between characters defaulting to 1,

loadFont(index, filename, chars, charSpacing=1)

this way existing fonts will work as before but passing charSpacing=0 will allow the font.png to contain the spacing internally.

What do you think?

TakWolf commented 1 year ago

As the concept of fonts, I think there should three parameters included in a font struct. (Horizontal layout)

lineHeight: = ascent - descent, in nico is actually the proc fontHeight() charSpacing: additional gap of the glyphs in horizontal lineGap: additional gap of the lines in vertical

As a compatibility measure, we let the charSpacing and lineGap = 1 as default.