Unsolicited advice
Opened this issue · 5 comments
Hey, I read your blog post on the editor, as Hajime Hoshi shared it on the discord chat. I follow the development of Ebitengine fairly closely, and I wanted to share a few tips and ideas that you may find useful / interesting, even if you are unlikely to implement most of them. Using an issue for this feels a bit wrong, but you can just close it without remorse, no problem, this is only meant to be informative for you or other people that may want to do something similar or take things one step further.
- Proper font rendering requires proper layout: you need to take into account the display DPI if you want to do any kind of sharp text rendering. This can be done by taking
ebiten.DeviceScaleFactor()
into account and applying it on theLayout()
function. While many Ebitengine examples do this, you can also check this article that goes more in depth explaining it. It also touches onLayoutF
, which can be fairly important for an application such as a text editor. - Pixel fonts are tricky: even if you are using high DPI, making pixel fonts look sharp can still be hard. In particular, the standard font DPI used is 72, but CSS uses 96 instead. For this reason, many fonts are designed with that in mind, and certain point sizes are likely to look better or worse. There are two tricks to solve this: either try both 72 and 96 DPIs when creating a font face to see what looks best, or apply a 3/4 or 4/3 factor (never remember which one of the two) when computing the font size.
- Efficient GPU usage: since Ebitengine v2.5.0 (still in alpha), draw calls are optimized when no draw commands happen. This means you can use
ebiten.SetScreenClearedEveryFrame(false)
and avoid doing anything in theDraw()
function unless necessary. This will make a massive difference in power usage, and for an application that's idle most of the time, this is a very big deal. It's still not as efficient as regular GUI frameworks, which skip buffer swaps altogether and often don't have a fixed timestep update loop called regularly, but it's still a massive improvement.
Maybe changing to vectorial fonts now is too bothersome, and you are probably doing this only for fun and learning, but wanted to share anyway! Have fun with Ebitengine!
Thank you for all of these notes @tinne26! They are appreciated.
I’ll update my blog post (where I talk about fonts) and link to this issue 👍
Hello, adding to all of the above, I would also like to mention golang-design/clipboard lib for cross-platform copy-paste.
Thanks @sedyh, I knew there must be a better way :)
I’ll add a note in the post.
Sorry for the fan post but a sincere thanks for blogging this, and the suggestions issue.
I'm just getting started with ebitenengine and golang, and while looking at the "keyboard" example, I went looking for a larger example of raw keyboard support and this is amazing. (I haven't seen any WASM frameworks support "console mode" text, so I'm still blown away).
Glad it was helpful @sprive! 😁