freetype-devel
[Top][All Lists]
Advanced

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

Re: Glyph Rendering of CJK Font that Appears to have Hints


From: Charlie Jiang
Subject: Re: Glyph Rendering of CJK Font that Appears to have Hints
Date: Sun, 6 Nov 2022 08:14:49 +0800
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.1

Hi Roger,

Not quite in my case...

However I doubt that I've used a different SimSun font file from yours. You can use the `ftinspect` provided in the `freetypes-demos` package to check it out for your version (you maybe need to build this from the source using Qt since its latest version isn't packed by distro maintainer probably.).

To inspect the font's bitmap strokes, just open the font in the util and switch to "Font Info" tab, "Fixed Sizes" table will be available in the "General" sub-tab. To view the glyphs, select a CJK glyph in the "Singular Grid View" and toggle the "Enable Embedded Bitmap", then adjust the font size. If no glyph outline is displayed for one certain size, a bitmap stroke is indicated.

You can also play around with several rendering parameters with `ftinspect` if you like to 😀.

Cheers,
chariri

在 周日 2022/11/6 5:40, Roger Wang 写道:
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.

Context:
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
image.png

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

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!

Best,
Roger

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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