kopia lustrzana https://github.com/peterhinch/micropython-font-to-py
font_to_py.py Implement fix for iss #23.
rodzic
72d595f99a
commit
5b0b3fce97
|
@ -6,11 +6,11 @@
|
||||||
|
|
||||||
# Some code adapted from Daniel Bader's work at the following URL
|
# Some code adapted from Daniel Bader's work at the following URL
|
||||||
# http://dbader.org/blog/monochrome-font-rendering-with-freetype-and-python
|
# 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)
|
# 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
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
# of this software and associated documentation files (the "Software"), to deal
|
||||||
|
@ -275,9 +275,9 @@ class Font(dict):
|
||||||
elif charset == '':
|
elif charset == '':
|
||||||
self.charset = [chr(defchar)] + [chr(ordv) for ordv in self.crange]
|
self.charset = [chr(defchar)] + [chr(ordv) for ordv in self.crange]
|
||||||
else:
|
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
|
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.
|
# .charset has an item for all chars in range. '' if unsupported.
|
||||||
# item 0 is the default char. Subsequent chars are in increasing ordinal value.
|
# item 0 is the default char. Subsequent chars are in increasing ordinal value.
|
||||||
self.charset = [chr(defchar)] + cs
|
self.charset = [chr(defchar)] + cs
|
||||||
|
|
Ładowanie…
Reference in New Issue