v.0.3.0 calculate char_width with shift operator
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
from machine import Pin, RTC
|
||||
from neopixel import NeoPixel
|
||||
from .fonts.fonts_utils import fonts_meta
|
||||
from .fonts.fonts_utils import fonts_meta, char_width as charwidth
|
||||
|
||||
from .fonts.font_5x7 import font_5x7
|
||||
from .fonts.font_5x7_opt import font_5x7 as font_5x7_opt, get_char_width
|
||||
@@ -124,17 +124,20 @@ class NeoPixel_64x64(NeoPixel):
|
||||
color: RGB color tuple
|
||||
"""
|
||||
|
||||
# background for the letter (full font size)
|
||||
[
|
||||
# print(xpos, ypos)
|
||||
self.set_pixel(xpos, ypos, GRAY)
|
||||
for xpos in range(x, x + 8) # 8 because full with of character representation
|
||||
for ypos in range(y, y + self.font_height)
|
||||
]
|
||||
|
||||
if letter in self.selected_font:
|
||||
char_data = self.selected_font[letter]
|
||||
char_width = get_char_width(letter)
|
||||
# char_width = get_char_width(letter, default_witdth=16)
|
||||
char_width = charwidth(char_data)
|
||||
|
||||
# background for the letter (full font size)
|
||||
[
|
||||
# print(xpos, ypos)
|
||||
self.set_pixel(xpos, ypos, GRAY)
|
||||
for xpos in range(
|
||||
x, x + char_width
|
||||
) # 8 because full with of character representation
|
||||
for ypos in range(y, y + self.font_height)
|
||||
]
|
||||
|
||||
for row in range(self.font_height):
|
||||
row_data = char_data[row]
|
||||
|
||||
Reference in New Issue
Block a user