Mageia Bugzilla – Attachment 11502 Details for
Bug 26165
The unconfigured fonts-otf-source-han font causes fontconfig to select Japanese rather than the Unicode base characters.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
Python script for testing the fontconfig matching.
fontconfig_testing.py (text/plain), 3.64 KB, created by
Edward d'Auvergne
on 2020-02-10 15:26:39 CET
(
hide
)
Description:
Python script for testing the fontconfig matching.
Filename:
MIME Type:
Creator:
Edward d'Auvergne
Created:
2020-02-10 15:26:39 CET
Size:
3.64 KB
patch
obsolete
>#! /usr/bin/env python3 > ># Python module imports. >from re import search >from subprocess import PIPE, Popen > > ># Debugging flag. >DEBUG = False > ># The base command. >BASE_CMD = "LC_CTYPE=%s.UTF-8 FC_DEBUG=4 python3 -c 'from PySide2.QtWidgets import QApplication, QLabel\napp = QApplication()\nQLabel(\"%s\").show()'" > ># The locales to test. >LOCALES = [ > 'en_US', > 'ja_JP', > 'ko_KP', > 'ko_KR', > 'yue_CN', > 'yue_HK', > 'zh_CN', > 'zh_HK', > 'zh_MO', > 'zh_SG', > 'zh_TW', >] > ># The character to test with. >CHAR = { > 'en_US': ["X", "\u95e8"], > 'ja_JP': ["\u95e8"], > 'ko_KP': ["\u9580"], > 'ko_KR': ["\u9580"], > 'yue_CN': ["\u9580"], > 'yue_HK': ["\u9580"], > 'zh_CN': ["\u95e8"], > 'zh_HK': ["\u9580"], > 'zh_MO': ["\u9580"], > 'zh_SG': ["\u95e8"], > 'zh_TW': ["\u9580"], >} > ># The expected highest priority font family name. >FONT = { > 'en_US': ["Noto Sans", "Source Han Sans TC"], > 'ja_JP': ["Source Han Sans"], > 'ko_KP': ["Source Han Sans K"], > 'ko_KR': ["Source Han Sans K"], > 'yue_CN': ["Source Han Sans TC"], > 'yue_HK': ["Source Han Sans TC"], > 'zh_CN': ["Source Han Sans SC"], > 'zh_HK': ["Source Han Sans HC"], > 'zh_MO': ["Source Han Sans TC"], > 'zh_SG': ["Source Han Sans SC"], > 'zh_TW': ["Source Han Sans TC"], >} > ># The expected hinting values. >HINTING = { > 'en_US': [None, "False(w)"], > 'ja_JP': ["False(w)"], > 'ko_KP': ["False(w)"], > 'ko_KR': ["False(w)"], > 'yue_CN': ["False(w)"], > 'yue_HK': ["False(w)"], > 'zh_CN': ["False(w)"], > 'zh_HK': ["False(w)"], > 'zh_MO': ["False(w)"], > 'zh_SG': ["False(w)"], > 'zh_TW': ["False(w)"], >} > >#LOCALES = ['ko_KR'] > ># Check each locale. >for locale in LOCALES: > # Loop over each character. > for char_index in range(len(CHAR[locale])): > # The full command. > cmd = BASE_CMD % (locale, CHAR[locale][char_index]) > > # Execute the command, capturing STDOUT. > if DEBUG: > print(repr(cmd)) > pipe = Popen(cmd, shell=True, stdout=PIPE) > > # Read the output. > lines = pipe.stdout.readlines() > for i in range(len(lines)): > lines[i] = lines[i].decode() > #print(lines[i].rstrip()) > > # Find the last font. > last_font_index = None > for i in range(len(lines)): > if search("^FcConfigSubstitute donePattern", lines[i]): > last_font_index = i > > # Find the font family. > for i in range(last_font_index, len(lines)): > if search("family:", lines[i]): > family = lines[i].strip() > break > > # Check the font family. > elements = family.split('"') > for i in range(int((len(elements)-1)/2)): > if elements[i*2+1][0].isascii(): > top_priority = elements[i*2+1] > break > if top_priority != FONT[locale][char_index]: > print(repr(cmd)) > print("FAIL: fontconfig matches of '%s' should start with '%s'." % (family, FONT[locale][char_index])) > elif DEBUG: > print("PASS: fontconfig match of '%s'." % top_priority) > > # Find the hinting. > hinting = None > for i in range(last_font_index, len(lines)): > if search("hinting:", lines[i]): > hinting = lines[i].strip() > hinting = hinting.split()[1] > break > > # Check the hinting. > if hinting != HINTING[locale][char_index]: > print(repr(cmd)) > print("FAIL: fontconfig hinting of '%s' should be '%s'." % (hinting, HINTING[locale][char_index])) > elif DEBUG: > print("PASS: fontconfig hinting of %s." % repr(hinting))
#! /usr/bin/env python3 # Python module imports. from re import search from subprocess import PIPE, Popen # Debugging flag. DEBUG = False # The base command. BASE_CMD = "LC_CTYPE=%s.UTF-8 FC_DEBUG=4 python3 -c 'from PySide2.QtWidgets import QApplication, QLabel\napp = QApplication()\nQLabel(\"%s\").show()'" # The locales to test. LOCALES = [ 'en_US', 'ja_JP', 'ko_KP', 'ko_KR', 'yue_CN', 'yue_HK', 'zh_CN', 'zh_HK', 'zh_MO', 'zh_SG', 'zh_TW', ] # The character to test with. CHAR = { 'en_US': ["X", "\u95e8"], 'ja_JP': ["\u95e8"], 'ko_KP': ["\u9580"], 'ko_KR': ["\u9580"], 'yue_CN': ["\u9580"], 'yue_HK': ["\u9580"], 'zh_CN': ["\u95e8"], 'zh_HK': ["\u9580"], 'zh_MO': ["\u9580"], 'zh_SG': ["\u95e8"], 'zh_TW': ["\u9580"], } # The expected highest priority font family name. FONT = { 'en_US': ["Noto Sans", "Source Han Sans TC"], 'ja_JP': ["Source Han Sans"], 'ko_KP': ["Source Han Sans K"], 'ko_KR': ["Source Han Sans K"], 'yue_CN': ["Source Han Sans TC"], 'yue_HK': ["Source Han Sans TC"], 'zh_CN': ["Source Han Sans SC"], 'zh_HK': ["Source Han Sans HC"], 'zh_MO': ["Source Han Sans TC"], 'zh_SG': ["Source Han Sans SC"], 'zh_TW': ["Source Han Sans TC"], } # The expected hinting values. HINTING = { 'en_US': [None, "False(w)"], 'ja_JP': ["False(w)"], 'ko_KP': ["False(w)"], 'ko_KR': ["False(w)"], 'yue_CN': ["False(w)"], 'yue_HK': ["False(w)"], 'zh_CN': ["False(w)"], 'zh_HK': ["False(w)"], 'zh_MO': ["False(w)"], 'zh_SG': ["False(w)"], 'zh_TW': ["False(w)"], } #LOCALES = ['ko_KR'] # Check each locale. for locale in LOCALES: # Loop over each character. for char_index in range(len(CHAR[locale])): # The full command. cmd = BASE_CMD % (locale, CHAR[locale][char_index]) # Execute the command, capturing STDOUT. if DEBUG: print(repr(cmd)) pipe = Popen(cmd, shell=True, stdout=PIPE) # Read the output. lines = pipe.stdout.readlines() for i in range(len(lines)): lines[i] = lines[i].decode() #print(lines[i].rstrip()) # Find the last font. last_font_index = None for i in range(len(lines)): if search("^FcConfigSubstitute donePattern", lines[i]): last_font_index = i # Find the font family. for i in range(last_font_index, len(lines)): if search("family:", lines[i]): family = lines[i].strip() break # Check the font family. elements = family.split('"') for i in range(int((len(elements)-1)/2)): if elements[i*2+1][0].isascii(): top_priority = elements[i*2+1] break if top_priority != FONT[locale][char_index]: print(repr(cmd)) print("FAIL: fontconfig matches of '%s' should start with '%s'." % (family, FONT[locale][char_index])) elif DEBUG: print("PASS: fontconfig match of '%s'." % top_priority) # Find the hinting. hinting = None for i in range(last_font_index, len(lines)): if search("hinting:", lines[i]): hinting = lines[i].strip() hinting = hinting.split()[1] break # Check the hinting. if hinting != HINTING[locale][char_index]: print(repr(cmd)) print("FAIL: fontconfig hinting of '%s' should be '%s'." % (hinting, HINTING[locale][char_index])) elif DEBUG: print("PASS: fontconfig hinting of %s." % repr(hinting))
View Attachment As Raw
Actions:
View
Attachments on
bug 26165
:
11495
|
11496
|
11497
|
11498
|
11500
| 11502 |
11503
|
11504