Skip to content
This repository has been archived by the owner on Nov 5, 2022. It is now read-only.

Investigation: Font glyph rendering doesn't seem quite right. #22

Open
ben-clayton opened this issue Mar 19, 2015 · 6 comments
Open

Investigation: Font glyph rendering doesn't seem quite right. #22

ben-clayton opened this issue Mar 19, 2015 · 6 comments
Assignees

Comments

@ben-clayton
Copy link
Contributor

I've spent a few days looking into what exactly I'm finding disagreeable, and I have a few theories starting from most likely to least:

  • By dropping the integer-pixel offsets, I've screwed up the hinting. I would have thought this would be simple to confirm by comparing glyphs I've rendered to glyphs produced by another application - I tried, and I couldn't really convince myself that this was the problem.
  • Gamma isn't quite right. I had a play trying to compensate the curve in the shader used to display the rasterized glyphs - nothing I tried made it look significantly better.
  • It's in my head. I've spent so long with my retina MBP looking at the lovely smooth fonts, that all other displays just look crap.

I will need to spend a bit more time investigating what isn't quite right here.

@ben-clayton ben-clayton self-assigned this Mar 19, 2015
@nieware
Copy link

nieware commented Apr 10, 2015

First of all, thanks for starting this project! I think there's a lot of promise in a native Go UI library and I'm looking forward to how it will develop!

I don't know about you, but what I find disagreeable about the fonts in GXUI is the lack of subpixel rendering. This has become so commonplace nowadays that fonts rendered with "conventional" smoothing techniques look "not quite right", as you wrote, at least on low-DPI screens. I have investigated a bit, and unfortunately freetype-go doesn't support subpixel rendering at the moment - which makes sense considering that the initial application was drawing text into images, but is unfortunate when you want to use it for a UI library. I'd even volunteer to do it, but there's a lot of theory involved that I'm not familiar with, so the task is pretty daunting. Maybe looking at the subpixel rendering code of the original freetype library and porting that to go is more feasible?

@ben-clayton
Copy link
Contributor Author

First of all, thanks for starting this project! I think there's a lot of promise in a native Go UI library and I'm looking forward to how it will develop!

Thank you and welcome.

I don't know about you, but what I find disagreeable about the fonts in GXUI is the lack of subpixel rendering.

This is certainly likely to be a contributor to the poor quality and I definitely would love to have support for sub-pixel rendering, but is unfortunately a minefield for patents. Last time I checked sub-pixel rendering was still disabled by default in freetype.

I'm sure there's other things that could be done to improve the quality though. Glyphy looks interesting, although the pre-computation and rendering cost seems quite scary.

@dmitshur
Copy link
Member

Another factor to take into account is that anti-aliasing is turned on with 4 samples:

glfw.WindowHint(glfw.Samples, 4)

glfw.WindowHint(glfw.Samples, 4)

@ben-clayton
Copy link
Contributor Author

MSAA does not affect texture sampling. It is only used to anti-alias the polygon edges, which in the case of the glyphs should always be fully transparent.

@dmitshur
Copy link
Member

Ah, so each glyph is just a textured quad? I see; I hadn't looked into its details yet. In that case you are right, MSAA should not affect it.

@ben-clayton
Copy link
Contributor Author

Ah, so each glyph is just a textured quad?

Yes. A very brief overview of how they work:

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants