Page MenuHome

BLF: Improved CJK Font Preview Differentiation
ClosedPublic

Authored by Harley Acheson (harley) on Nov 13 2022, 6:43 PM.

Details

Summary

Use font's OS/2 table code page range bits to help differentiate
between Korean, Japanese, Simplified & Traditional Chinese fonts.


When showing previews of fonts we use a combination of OS/2 table "coverage bits" and testing of glyph inclusion to determine what to use as the sample characters. This works in most cases, especially with language-specific and specialty fonts.

However, as shown in this comment, fonts designed for Japanese, Korean, and Chinese are quite often misidentified. This is because these languages share common codepoints, so all have similar coverage bits. Differentiating between Simplified Chinese and Traditional Chinese is especially difficult because fonts made for each will often include identical coverage.

This patch improves on this by using the font's OS/2 table "code page range bits". Although not generally useful (since they identify only a small number of languages) they do differentiate between Japanese, Korean, Simplified Chinese, and Traditional Chinese. This helps in many cases where a font has a clear intended language.

Following shows previews of language-specific fonts for Korean, Simplified Chinese, and Traditional Chinese:

This changed code are just some "early returns" for fonts that are set correctly with these codepoint bits. If not, the existing detection code is still run.

Diff Detail

Repository
rB Blender

Event Timeline

Harley Acheson (harley) requested review of this revision.Nov 13 2022, 6:43 PM
Harley Acheson (harley) created this revision.
This revision is now accepted and ready to land.Jan 9 2023, 11:58 AM

@Harley Acheson (harley) I tested the latest version and it works fine. But it is still incorrect in some cases (I think this is not a common case, most fonts do not have similar problems)