Skip to content

Commit

Permalink
Handle fonts with missing ulCodePageRange1 entries. (#906)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
corranwebster authored Mar 15, 2022
1 parent 13111f6 commit bcb8d25
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions kiva/fonttools/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit bcb8d25

Please sign in to comment.