samdze / playdate-nim

Nim bindings with extra features for the Playdate SDK
63 stars 3 forks source link

Default to UTF8 when drawing text #30

Closed Nycto closed 10 months ago

Nycto commented 10 months ago

Nim strings are encoded with UTF8 by default, so this updates the drawText proc to also default to this. I also added an optional parameter in case this needs to be overridden.

samdze commented 10 months ago

Makes sense. Using UTF8 here should not bring performance penalties, I suppose.

Nycto commented 10 months ago

Using UTF8 here should not bring performance penalties, I suppose.

It really shouldn't. And if it does, users can still manually switch back to ascii encoding.

This is also a "principal of least surprise" kind of thing -- users are going to expect UTF8 to be the default, since it's the default in Nim. When you try to use a more complicated string right now, it spits out mojibake. This is especially salient since the default Playdate font represents things like the buttons using high order unicode characters: Ⓐ Ⓑ 🟨 ⊙ 🔒 🎣 ✛ ⬆️ ➡️ ⬇️ ⬅️

samdze commented 10 months ago

Thank you!