Celtoys / Remotery

Single C file, Realtime CPU/GPU Profiler with Remote Web Viewer
Apache License 2.0
3.11k stars 264 forks source link

Sample window font in Firefox (macOS) is blurry #226

Open JCash opened 2 years ago

JCash commented 2 years ago
Screenshot 2022-07-20 at 09 46 07 Screenshot 2022-07-20 at 10 29 56

The W and S are most visibly cut off.

I tried to verify the texture with the Spector.js extension, but it wouldn't run for me. Although I expect it to be the shader code to be slightly off here.

dwilliamson commented 2 years ago

Yes, there's not much I can do about this at the moment beyond making the font and spacing bigger, consuming more space in the UI.

The font renderer needs to be a lot more sophisticated to match the browser.

Although there will likely be flaws in how the atlas is baked. I haven't spent much time on it.

JCash commented 2 years ago

What's confusing to me is that the header font looks a lot more crisp. Is that the same font? The S's look diffferent to me, so I guess not?

dwilliamson commented 2 years ago

The header is rendered by the DOM, not Remotery's shaders.

dwilliamson commented 2 years ago

I think an immediate improvement could be had with a pre-generated font atlas.

Can you run this for me: https://lucide.github.io/Font-Atlas-Generator/

Use these properties:

Do the letters in the atlas look better than they do in Remotery?

dwilliamson commented 2 years ago

In fact, it appears they have the same problem in that generator: you can't reliably generate letters as the amount of anti-aliasing varies depending on where the letter is rendered into the atlas. These are two of the sample letter positioned differently on the atlas:

image image

What also seems to vary it is the width of the output rectangle: odd generates different to even.

I think for reliability for now, I'll need a custom-built atlas. Then later (much later) quality font rendering can be addressed.

dwilliamson commented 2 years ago

I might try this if I get time https://github.com/memononen/fontstash. I already use it on an internal UI project and it's pretty flawless.

JCash commented 2 years ago

Sorry, I couldn't get the font atlas generator to produce a Fira Code atlas (or Fira Sans of any kind).

Yes, if the atlas is problematic to start with, it sounds good to look into alternatives.

dwilliamson commented 2 years ago

Linking for reference https://www.warp.dev/blog/adventures-text-rendering-kerning-glyph-atlases

dwilliamson commented 2 years ago

Rather than generating the atlas offline, we might find some clues on water-tight atlas generation from xterm.js:

Interestingly, it appears to render a quad per glyph, so is still quite a ways from being the most optimal. This may imply requirements of their atlas generation that we can't match.