[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Glyph Rendering of CJK Font that Appears to have Hints

From: Roger Wang
Subject: Glyph Rendering of CJK Font that Appears to have Hints
Date: Sat, 5 Nov 2022 17:40:24 -0400

Hi FreeType developers!

My name is Roger, and I am a developer currently located in Pennsylvania. I do have to apologize in advance for this lengthy email, but I think I ran into some very interesting issues with certain glyph rendering in CJK fonts, which is why I am reaching out. I would also have to apologize for any ignorance showed or confusion caused by my language, as I am very clueless about the internal structure of a font file and relevant hinting information.

I am currently building a monochrome LED rendering software (with GUI) that takes fonts and characters as input and spits out a monochrome bitmap for use on LED screens. I had two approaches to this application, and the initial one was to simply render a character onto an image of fixed sizes and then get the gray value of all the pixels generated. (I am using Qt on Windows with libraries like QImage and QPainter, and I found out that this rendering process utilized Window's ClearType and other hinting algorithms already). I set an adjustable "threshold" by which pixels darker than a certain gray value are treated as "black" and others treated as "white".

In a later effort to make this application cross-platform without spitting out different results (e.g. macOS doesn't utilize a hinting algorithm), I came across FreeType and integrated the library into my application (thank you!). I set up the option to use either the Monochrome Render Mode (which I am certain utilizes the auto hinting algorithm of FreeType) or the Normal Render Mode (which generates a grayscale bitmap like the one described in the windows approach along with the threshold value).

The Issue:
The issue I have is concerned with a particular CJK font, a version of the SimSun font that comes with Windows XP (3.03, recent versions don't display the behavior that I'm about to describe). I know beforehand that this font contained bitmaps for sizes smaller than 16px for LCD displays, but not for any sizes larger than 16px.

However, when I used the first Windows approach on this font with a size of 24px, generated Chinese glyphs doesn't change when I adjust the "threshold", meaning a monochrome bitmap was generated despite my telling QImage to render a grayscale image. Substantial amounts of hinting also seem to take place, making me believe that hints were contained for 24px. (I can also adjust the width of a glyph to transform it, and the rendered image seems to be in monochrome even when the glyph is stretched/condensed).

When I use the FreeType approach, interestingly, Monochrome Render Mode gives the same result for a number of glyphs, but not all. Some other glyphs show similar hints to the Windows results, but discrepancies exist. Please see the comparison below (all results are "bolded" by simply adding a pixel to the right of each existing pixel to improve visibility):

Sample text: 龚陆路华丰津, 24px, 90% Width

Sample text: 龙阳路地铁站, 24px, 100% Width

My main question is, are there hints for 24px and maybe other sizes that I am unaware of in this font, which allowed Windows to easily render monochrome images? Are hints usually used at a size despite of the transformation (in my case, horizontal only) applied to the glyph? In addition, if there are hints at 24px, why is the Monochrome Render Mode of FreeType, which by default uses hints available in the font, giving different results?

Thank you so much for going through my email. I made the decision to contact because I believe this is an intriguing issue that I am certainly not capable to find the answer to by myself. I hope you are not bored by my description, and any help would be greatly appreciated! Please don't hesitate to ask if there is anything you would like me to provide in addition (code snippets, etc.).

Looking forward to hearing from you!


reply via email to

[Prev in Thread] Current Thread [Next in Thread]