From 22c28499a9a8669c2105f89f929eef658b0d4b63 Mon Sep 17 00:00:00 2001 From: Corran Webster Date: Thu, 10 Mar 2022 14:21:25 +0000 Subject: [PATCH] Handle fonts with missing ulCodePageRange1 entries. I think this happens for either very old fonts or fonts which aren't fully compliant with the open type specification. Not much either we or the user can do about it. --- kiva/fonttools/_util.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/kiva/fonttools/_util.py b/kiva/fonttools/_util.py index 7240c5710..ae23f8a1f 100644 --- a/kiva/fonttools/_util.py +++ b/kiva/fonttools/_util.py @@ -155,10 +155,14 @@ def get_ttf_prop_dict(font): if bit in _ot_unicode_range_bits: languages.add(_ot_unicode_range_bits[bit]) # Check the codepage range bits - cp_bits = table.ulCodePageRange1 - for lang, mask in _ot_code_page_masks.items(): - if cp_bits & mask: - languages.add(lang) + try: + cp_bits = table.ulCodePageRange1 + for lang, mask in _ot_code_page_masks.items(): + if cp_bits & mask: + languages.add(lang) + except AttributeError: + # some fonts don't have ulCodePageRange1 + pass # Lock the set so that it's hashable propdict["languages"] = frozenset(languages) except KeyError: