BLF: Improved CJK Font Preview Differentiation
Use font's OS/2 table code page range bits to help differentiate between Korean, Japanese, Simplified & Traditional Chinese fonts. See D16484 for details. Differential Revision: https://developer.blender.org/D16484 Reviewed by Brecht Van Lommel
This commit is contained in:
parent
d48f95d31c
commit
485ab42075
|
@ -257,6 +257,22 @@ static const char32_t *blf_get_sample_text(FT_Face face)
|
|||
count_bits_i((uint)os2_table->ulUnicodeRange3) +
|
||||
count_bits_i((uint)os2_table->ulUnicodeRange4);
|
||||
|
||||
/* Use OS/2 Table code page range bits to differentiate between (combined) CJK fonts.
|
||||
* See https://learn.microsoft.com/en-us/typography/opentype/spec/os2#cpr */
|
||||
FT_ULong codepages = os2_table->ulCodePageRange1;
|
||||
if (codepages & (1 << 19) || codepages & (1 << 21)) {
|
||||
return U"\ud55c\uad6d\uc5b4"; /* 한국어 Korean. */
|
||||
}
|
||||
if (codepages & (1 << 20)) {
|
||||
return U"\u7E41\u9AD4\u5B57"; /* 繁體字 Traditional Chinese. */
|
||||
}
|
||||
if (codepages & (1 << 17) && !(codepages & (1 << 18))) {
|
||||
return U"\u65E5\u672C\u8A9E"; /* 日本語 Japanese. */
|
||||
}
|
||||
if (codepages & (1 << 18) && !(codepages & (1 << 17))) {
|
||||
return U"\u7B80\u4F53\u5B57"; /* 简体字 Simplified Chinese. */
|
||||
}
|
||||
|
||||
for (uint i = 0; i < ARRAY_SIZE(unicode_samples); ++i) {
|
||||
const UnicodeSample *s = &unicode_samples[i];
|
||||
if (os2_table && s->field && s->mask) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "../../blenfont/BLF_api.h"
|
||||
|
||||
/* Only change if we need to update the previews in the on-disk cache. */
|
||||
#define FONT_THUMB_VERSION "1.0.0"
|
||||
#define FONT_THUMB_VERSION "1.0.1"
|
||||
|
||||
struct ImBuf *IMB_thumb_load_font(const char *filename, uint x, uint y)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue