def writing_system_for_font(font): has_latin = True systems = QFontDatabase().writingSystems(font.family()) # this just confuses the algorithm below. Vietnamese is Latin with lots of # special chars try: systems.remove(QFontDatabase.WritingSystem.Vietnamese) except ValueError: pass system = QFontDatabase.WritingSystem.Any if (QFontDatabase.WritingSystem.Latin not in systems): has_latin = False # we need to show something if systems: system = systems[-1] else: systems.remove(QFontDatabase.WritingSystem.Latin) if not systems: return system, has_latin if (len(systems) == 1 and systems[0] > QFontDatabase.WritingSystem.Cyrillic): return systems[0], has_latin if (len(systems) <= 2 and systems[-1] > QFontDatabase.WritingSystem.Armenian and systems[-1] < QFontDatabase.WritingSystem.Vietnamese): return systems[-1], has_latin if (len(systems) <= 5 and systems[-1] >= QFontDatabase.WritingSystem.SimplifiedChinese and systems[-1] <= QFontDatabase.WritingSystem.Korean): system = systems[-1] return system, has_latin
def writing_system_for_font(font): has_latin = True systems = QFontDatabase().writingSystems(font.family()) # this just confuses the algorithm below. Vietnamese is Latin with lots of # special chars try: systems.remove(QFontDatabase.Vietnamese) except ValueError: pass system = QFontDatabase.Any if (QFontDatabase.Latin not in systems): has_latin = False # we need to show something if systems: system = systems[-1] else: systems.remove(QFontDatabase.Latin) if not systems: return system, has_latin if (len(systems) == 1 and systems[0] > QFontDatabase.Cyrillic): return systems[0], has_latin if (len(systems) <= 2 and systems[-1] > QFontDatabase.Armenian and systems[-1] < QFontDatabase.Vietnamese): return systems[-1], has_latin if (len(systems) <= 5 and systems[-1] >= QFontDatabase.SimplifiedChinese and systems[-1] <= QFontDatabase.Korean): system = systems[-1] return system, has_latin