@@ -65,14 +65,14 @@ def __init__(self, display,
65
65
self ._key = key
66
66
self ._show = show
67
67
self ._clear = clear
68
- self ._reversion = reversion
69
- self ._color_type = color_type
70
- self ._color = color
71
- self ._bg_color = bg_color
72
- self ._size = size
73
- self ._auto_wrap = auto_wrap
74
- self ._half_char = half_char
75
- self ._line_spacing = line_spacing
68
+ self .reversion = reversion
69
+ self .color_type = color_type
70
+ self .color = color
71
+ self .bg_color = bg_color
72
+ self .font_size = size
73
+ self .auto_wrap = auto_wrap
74
+ self .half_char = half_char
75
+ self .line_spacing = line_spacing
76
76
self .font_bmf_info = None
77
77
self .font_version = None
78
78
self .font_file = None
@@ -260,7 +260,7 @@ def load_font(self, file: str):
260
260
# 位图开始字节,位图数据位于文件尾,需要通过位图开始字节来确定字体数据实际位置
261
261
self .font_start_bitmap = unpack (">I" , b'\x00 ' + self .font_bmf_info [4 :7 ])[0 ]
262
262
# 字体大小,默认的文字字号,用于缩放方面的处理
263
- self ._size = self .font_bmf_info [7 ]
263
+ self .font_size = self .font_bmf_info [7 ]
264
264
# 点阵所占字节,用来定位字体数据位置
265
265
self .font_bitmap_size = self .font_bmf_info [8 ]
266
266
@@ -287,30 +287,30 @@ def text(self, s: str, x: int, y: int,
287
287
line_spacing: 行间距
288
288
"""
289
289
if color is None :
290
- color = self ._color
290
+ color = self .color
291
291
if bg_color is None :
292
- bg_color = self ._bg_color
292
+ bg_color = self .bg_color
293
293
if key is None :
294
294
key = self ._key
295
295
if size is None :
296
- size = self ._size
296
+ size = self .font_size
297
297
if show is None :
298
298
show = self ._show
299
299
if clear is None :
300
300
clear = self ._clear
301
301
if reversion is None :
302
- reversion = self ._reversion
302
+ reversion = self .reversion
303
303
if auto_wrap is None :
304
- auto_wrap = self ._auto_wrap
304
+ auto_wrap = self .auto_wrap
305
305
if half_char is None :
306
- half_char = self ._half_char
306
+ half_char = self .half_char
307
307
if color_type is None :
308
- color_type = self ._color_type
308
+ color_type = self .color_type
309
309
if line_spacing is None :
310
- line_spacing = self ._line_spacing
310
+ line_spacing = self .line_spacing
311
311
312
312
# 如果没有指定字号则使用默认字号
313
- font_size = size or self ._size
313
+ font_size = size or self .font_size
314
314
# 记录初始的 x 位置
315
315
init_x = x
316
316
@@ -359,18 +359,18 @@ def text(self, s: str, x: int, y: int,
359
359
# 4. 彩色屏幕/放缩
360
360
byte_data = self ._reverse_byte_data (byte_data ) if reversion else byte_data
361
361
if color_type == MONO_HLSB :
362
- if font_size == self ._size :
362
+ if font_size == self .font_size :
363
363
dp .blit (
364
364
FrameBuffer (bytearray (byte_data ), font_size , font_size , MONO_HLSB ),
365
365
x , y ,
366
366
key )
367
367
else :
368
368
dp .blit (
369
- FrameBuffer (self ._HLSB_font_size (byte_data , font_size , self ._size ), font_size ,
369
+ FrameBuffer (self ._HLSB_font_size (byte_data , font_size , self .font_size ), font_size ,
370
370
font_size , MONO_HLSB ), x , y , key )
371
371
elif color_type == RGB565 :
372
372
palette = self ._calculate_palette (color , bg_color )
373
- if font_size == self ._size :
373
+ if font_size == self .font_size :
374
374
data = self ._flatten_byte_data (byte_data , palette )
375
375
if self ._buffer :
376
376
dp .blit (
@@ -380,7 +380,7 @@ def text(self, s: str, x: int, y: int,
380
380
dp .set_window (x , y , x + font_size - 1 , y + font_size - 1 )
381
381
dp .write_data (data )
382
382
else :
383
- data = self ._RGB565_font_size (byte_data , font_size , palette , self ._size )
383
+ data = self ._RGB565_font_size (byte_data , font_size , palette , self .font_size )
384
384
if self ._buffer :
385
385
dp .blit (
386
386
FrameBuffer (data ,
@@ -430,13 +430,13 @@ def pbm(self, file: str, x, y, key: int = -1, show: bool = None, clear: bool = N
430
430
if clear is None :
431
431
clear = self ._clear
432
432
if reversion is None :
433
- reversion = self ._reversion
433
+ reversion = self .reversion
434
434
if color_type is None :
435
- color_type = self ._color_type
435
+ color_type = self .color_type
436
436
if color is None :
437
- color = self ._color
437
+ color = self .color
438
438
if bg_color is None :
439
- bg_color = self ._bg_color
439
+ bg_color = self .bg_color
440
440
if clear : # 清屏
441
441
self .clear ()
442
442
dp = self .display
@@ -577,13 +577,13 @@ def bmp(self, file: str, x, y, key: int = -1, show: bool = None, clear: bool = N
577
577
if clear is None :
578
578
clear = self ._clear
579
579
if reversion is None :
580
- reversion = self ._reversion
580
+ reversion = self .reversion
581
581
if color_type is None :
582
- color_type = self ._color_type
582
+ color_type = self .color_type
583
583
if color is None :
584
- color = self ._color
584
+ color = self .color
585
585
if bg_color is None :
586
- bg_color = self ._bg_color
586
+ bg_color = self .bg_color
587
587
with open (file , 'rb' ) as f :
588
588
f_read = f .read
589
589
f_rinto = f .readinto
0 commit comments