Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question: How to achieve subpixel hinting?

Discussion in 'UGUI & TextMesh Pro' started by fherbst, Jul 31, 2019.

  1. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    Seems I keep getting back on the topic of rendering legible font in Unity like, once a year, always unhappy with previous results.

    Neither the default UI fonts (set to "Hinted Smooth" or "Hinted Raster") nor TMPro seem to support subpixel hinting. This would be great to have to get small-scale font to be legible and improve the overall reading experience for text-heavy apps and games.

    Every text you read in this browser and most text displayed anywhere is properly subpixel-hinted.
    Some examples: zoomed in from this post
    upload_2019-7-31_3-14-32.png

    How can I achieve that in Unity? No matter what settings I do on text, it's always black and white and only hinted to pixel borders, not subpixels.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Microsoft is moving away from Clear Type and Apple dropped hinting and similar techniques several years ago.

    The main reason is because these techniques have a higher performance overhead / size requiring RGBA textures. More importantly, they are highly affected by monitor gamma and color calibration.

    See the following article about the challenges of rendering small text and the various techniques available.

    The challenge here is low dpi where the # of pixels available to work with is too limited to correctly represent the shape of glyphs. As resolution / DPI increases with Retina / 4K screens becoming more common, these small type rendering issues all go away as you now have enough pixel density to properly represent the shape of the glyphs and without having to use hinting which adds additional complexities since it alters the shape of the glyphs.

    Until then selecting the correct font for use at low dpi and small point size is crucial. This is why for instance Verdana was created and many other types that are specifically designed for this. Using Hinted Raster with pixel perfect and displaying the text at 1:1 will provide the best results. Ie. if the font is using hinted raster at 14 points, it has to be displayed at 14 points without scaling.

    I wish there was a magic solution but as that article points out, there is not. Plus this is also so subjective based on how individuals evaluate / see text and what "looks better to them" vs. someone else.

    P.S. Again, the clear solution is higher pixel density which most mobile devices now support where interestingly enough the development environment is still lagging behind. Most developers are still on lower DPI screens creating products that target high dpi devices.