File tree Expand file tree Collapse file tree 1 file changed +24
-9
lines changed Expand file tree Collapse file tree 1 file changed +24
-9
lines changed Original file line number Diff line number Diff line change 3030from fontio import Glyph
3131from .glyph_cache import GlyphCache
3232
33+ try :
34+ from bitmaptools import readinto as _bitmap_readinto
35+ except ImportError :
36+ _bitmap_readinto = None # pylint: disable=invalid-name
37+
3338_PCF_PROPERTIES = const (1 << 0 )
3439_PCF_ACCELERATORS = const (1 << 1 )
3540_PCF_METRICS = const (1 << 2 )
@@ -380,12 +385,22 @@ def load_glyphs(self, code_points):
380385 height = metrics .character_ascent + metrics .character_descent
381386
382387 bitmap = bitmaps [i ]
383- words_per_row = (width + 31 ) // 32
384- buf = bytearray (4 * words_per_row )
385- start = 0
386- for _ in range (height ):
387- self .file .readinto (buf )
388- for k in range (width ):
389- if buf [k // 8 ] & (128 >> (k % 8 )):
390- bitmap [start + k ] = 1
391- start += width
388+
389+ if _bitmap_readinto :
390+ _bitmap_readinto (
391+ bitmap ,
392+ self .file ,
393+ bits_per_pixel = 1 ,
394+ element_size = 4 ,
395+ reverse_pixels_in_element = True ,
396+ )
397+ else :
398+ words_per_row = (width + 31 ) // 32
399+ buf = bytearray (4 * words_per_row )
400+ start = 0
401+ for _ in range (height ):
402+ self .file .readinto (buf )
403+ for k in range (width ):
404+ if buf [k // 8 ] & (128 >> (k % 8 )):
405+ bitmap [start + k ] = 1
406+ start += width
You can’t perform that action at this time.
0 commit comments