25
25
from collections import namedtuple
26
26
import gc
27
27
import struct
28
+ from micropython import const
28
29
29
30
from fontio import Glyph
30
31
from .glyph_cache import GlyphCache
31
32
32
- _PCF_PROPERTIES = 1 << 0
33
- _PCF_ACCELERATORS = 1 << 1
34
- _PCF_METRICS = 1 << 2
35
- _PCF_BITMAPS = 1 << 3
36
- _PCF_INK_METRICS = 1 << 4
37
- _PCF_BDF_ENCODINGS = 1 << 5
38
- _PCF_SWIDTHS = 1 << 6
39
- _PCF_GLYPH_NAMES = 1 << 7
40
- _PCF_BDF_ACCELERATORS = 1 << 8
41
-
42
- _PCF_DEFAULT_FORMAT = 0x00000000
43
- _PCF_INKBOUNDS = 0x00000200
44
- _PCF_ACCEL_W_INKBOUNDS = 0x00000100
45
- _PCF_COMPRESSED_METRICS = 0x00000100
46
-
47
- _PCF_GLYPH_PAD_MASK = 3 << 0 # See the bitmap table for explanation */
48
- _PCF_BYTE_MASK = 1 << 2 # If set then Most Sig Byte First */
49
- _PCF_BIT_MASK = 1 << 3 # If set then Most Sig Bit First */
50
- _PCF_SCAN_UNIT_MASK = 3 << 4
33
+ _PCF_PROPERTIES = const (1 << 0 )
34
+ _PCF_ACCELERATORS = const (1 << 1 )
35
+ _PCF_METRICS = const (1 << 2 )
36
+ _PCF_BITMAPS = const (1 << 3 )
37
+ _PCF_INK_METRICS = const (1 << 4 )
38
+ _PCF_BDF_ENCODINGS = const (1 << 5 )
39
+ _PCF_SWIDTHS = const (1 << 6 )
40
+ _PCF_GLYPH_NAMES = const (1 << 7 )
41
+ _PCF_BDF_ACCELERATORS = const (1 << 8 )
42
+
43
+ _PCF_DEFAULT_FORMAT = const (0x00000000 )
44
+ _PCF_ACCEL_W_INKBOUNDS = const (0x00000100 )
45
+ _PCF_COMPRESSED_METRICS = const (0x00000100 )
46
+
47
+ _PCF_GLYPH_PAD_MASK = const (3 << 0 ) # See the bitmap table for explanation */
48
+ _PCF_BYTE_MASK = const (1 << 2 ) # If set then Most Sig Byte First */
49
+ _PCF_BIT_MASK = const (1 << 3 ) # If set then Most Sig Bit First */
50
+ _PCF_SCAN_UNIT_MASK = const (3 << 4 )
51
51
52
52
# https://fontforge.org/docs/techref/pcf-format.html
53
53
@@ -214,9 +214,7 @@ def _read_accelerator_tables(self):
214
214
raise RuntimeError ("Accelerator table missing" )
215
215
216
216
format_ = self ._seek_table (accelerators )
217
-
218
217
has_inkbounds = format_ & _PCF_ACCEL_W_INKBOUNDS
219
- compressed_metrics = format_ & _PCF_COMPRESSED_METRICS
220
218
221
219
(
222
220
no_overlap ,
@@ -231,11 +229,11 @@ def _read_accelerator_tables(self):
231
229
font_descent ,
232
230
max_overlap ,
233
231
) = self ._read (">BBBBBBBBIII" )
234
- minbounds = self ._read_metrics (compressed_metrics )
235
- maxbounds = self ._read_metrics (compressed_metrics )
232
+ minbounds = self ._read_metrics (False )
233
+ maxbounds = self ._read_metrics (False )
236
234
if has_inkbounds :
237
- ink_minbounds = self ._read_metrics (compressed_metrics )
238
- ink_maxbounds = self ._read_metrics (compressed_metrics )
235
+ ink_minbounds = self ._read_metrics (False )
236
+ ink_maxbounds = self ._read_metrics (False )
239
237
else :
240
238
ink_minbounds = minbounds
241
239
ink_maxbounds = maxbounds
0 commit comments