font_to_py.py Implement fix for iss #23.

pull/28/head
Peter Hinch 2019-11-01 18:26:53 +00:00
rodzic 72d595f99a
commit 5b0b3fce97
1 zmienionych plików z 4 dodań i 4 usunięć

Wyświetl plik

@ -6,11 +6,11 @@
# Some code adapted from Daniel Bader's work at the following URL
# http://dbader.org/blog/monochrome-font-rendering-with-freetype-and-python
# With thanks to Stephen Irons @ironss for fix for leading left pixels.
# With thanks to Stephen Irons @ironss for various improvements.
# The MIT License (MIT)
#
# Copyright (c) 2016 Peter Hinch
# Copyright (c) 2016-2019 Peter Hinch
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
@ -275,9 +275,9 @@ class Font(dict):
elif charset == '':
self.charset = [chr(defchar)] + [chr(ordv) for ordv in self.crange]
else:
cl = [ord(x) for x in chr(defchar) + charset]
cl = [ord(x) for x in chr(defchar) + charset if self._face.get_char_index(x) != 0 ]
self.crange = range(min(cl), max(cl) + 1) # Inclusive ordinal value range
cs = [chr(ordv) if chr(ordv) in charset else '' for ordv in self.crange]
cs = [chr(ordv) if chr(ordv) in charset and self._face.get_char_index(chr(ordv)) != 0 else '' for ordv in self.crange]
# .charset has an item for all chars in range. '' if unsupported.
# item 0 is the default char. Subsequent chars are in increasing ordinal value.
self.charset = [chr(defchar)] + cs