From ecedfd66fc18e9db206c9f9a49fd5226561f94a9 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Mitsuharu Date: Wed, 30 Sep 2015 19:05:27 +0900 Subject: [PATCH] * src/macfont.m (mac_font_descriptor_supports_languages): Regard "zh" as synonym of "zh-Hans". --- src/macfont.m | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/src/macfont.m b/src/macfont.m index cfe0e0a2b92..bab9f7cf9ff 100644 --- a/src/macfont.m +++ b/src/macfont.m @@ -3427,18 +3427,24 @@ mac_font_descriptor_supports_languages (CTFontDescriptorRef descriptor, result = false; else { - CFIndex desc_languages_count, i, languages_count; + CFRange range = CFRangeMake (0, CFArrayGetCount (desc_languages)); + CFIndex i, languages_count = CFArrayGetCount (languages); - desc_languages_count = CFArrayGetCount (desc_languages); - languages_count = CFArrayGetCount (languages); for (i = 0; i < languages_count; i++) - if (!CFArrayContainsValue (desc_languages, - CFRangeMake (0, desc_languages_count), - CFArrayGetValueAtIndex (languages, i))) - { - result = false; - break; - } + { + CFStringRef language = CFArrayGetValueAtIndex (languages, i); + + if (!CFArrayContainsValue (desc_languages, range, language) + /* PingFang SC contains "zh" and "zh-Hant" as covered + languages, but does not contain "zh-Hans". */ + && !(CFEqual (language, CFSTR ("zh-Hans")) + && CFArrayContainsValue (desc_languages, range, + CFSTR ("zh")))) + { + result = false; + break; + } + } CFRelease (desc_languages); } -- 2.39.2