@@ -271,7 +271,8 @@ def _output(self):
271
271
Output the text and boxes belonging to the most recent page.
272
272
page = dvi._output()
273
273
"""
274
- minx , miny , maxx , maxy = np .inf , np .inf , - np .inf , - np .inf
274
+ minx = miny = np .inf
275
+ maxx = maxy = - np .inf
275
276
maxy_pure = - np .inf
276
277
for elt in self .text + self .boxes :
277
278
if isinstance (elt , Box ):
@@ -422,7 +423,7 @@ def _nop(self, _):
422
423
@_dispatch (139 , state = _dvistate .outer , args = ('s4' ,)* 11 )
423
424
def _bop (self , c0 , c1 , c2 , c3 , c4 , c5 , c6 , c7 , c8 , c9 , p ):
424
425
self .state = _dvistate .inpage
425
- self .h , self .v , self .w , self .x , self .y , self .z = 0 , 0 , 0 , 0 , 0 , 0
426
+ self .h = self .v = self .w = self .x = self .y = self .z = 0
426
427
self .stack = []
427
428
self .text = [] # list of Text objects
428
429
self .boxes = [] # list of Box objects
@@ -678,16 +679,16 @@ def _read(self):
678
679
Read one page from the file. Return True if successful,
679
680
False if there were no more pages.
680
681
"""
681
- packet_char , packet_ends = None , None
682
- packet_len , packet_width = None , None
682
+ packet_char = packet_ends = None
683
+ packet_len = packet_width = None
683
684
while True :
684
685
byte = self .file .read (1 )[0 ]
685
686
# If we are in a packet, execute the dvi instructions
686
687
if self .state is _dvistate .inpage :
687
688
byte_at = self .file .tell ()- 1
688
689
if byte_at == packet_ends :
689
690
self ._finalize_packet (packet_char , packet_width )
690
- packet_len , packet_char , packet_width = None , None , None
691
+ packet_len = packet_char = packet_width = None
691
692
# fall through to out-of-packet code
692
693
elif byte_at > packet_ends :
693
694
raise ValueError ("Packet length mismatch in vf file" )
@@ -701,23 +702,31 @@ def _read(self):
701
702
# We are outside a packet
702
703
if byte < 242 : # a short packet (length given by byte)
703
704
packet_len = byte
704
- packet_char , packet_width = self ._arg (1 ), self ._arg (3 )
705
+ packet_char = self ._arg (1 )
706
+ packet_width = self ._arg (3 )
705
707
packet_ends = self ._init_packet (byte )
706
708
self .state = _dvistate .inpage
707
709
elif byte == 242 : # a long packet
708
- packet_len , packet_char , packet_width = \
709
- [self ._arg (x ) for x in (4 , 4 , 4 )]
710
+ packet_len = self ._arg (4 )
711
+ packet_char = self ._arg (4 )
712
+ packet_width = self ._arg (4 )
710
713
self ._init_packet (packet_len )
711
714
elif 243 <= byte <= 246 :
712
715
k = self ._arg (byte - 242 , byte == 246 )
713
- c , s , d , a , l = [self ._arg (x ) for x in (4 , 4 , 4 , 1 , 1 )]
716
+ c = self ._arg (4 )
717
+ s = self ._arg (4 )
718
+ d = self ._arg (4 )
719
+ a = self ._arg (1 )
720
+ l = self ._arg (1 )
714
721
self ._fnt_def_real (k , c , s , d , a , l )
715
722
if self ._first_font is None :
716
723
self ._first_font = k
717
724
elif byte == 247 : # preamble
718
- i , k = self ._arg (1 ), self ._arg (1 )
725
+ i = self ._arg (1 )
726
+ k = self ._arg (1 )
719
727
x = self .file .read (k )
720
- cs , ds = self ._arg (4 ), self ._arg (4 )
728
+ cs = self ._arg (4 )
729
+ ds = self ._arg (4 )
721
730
self ._pre (i , x , cs , ds )
722
731
elif byte == 248 : # postamble (just some number of 248s)
723
732
break
@@ -727,8 +736,10 @@ def _read(self):
727
736
def _init_packet (self , pl ):
728
737
if self .state != _dvistate .outer :
729
738
raise ValueError ("Misplaced packet in vf file" )
730
- self .h , self .v , self .w , self .x , self .y , self .z = 0 , 0 , 0 , 0 , 0 , 0
731
- self .stack , self .text , self .boxes = [], [], []
739
+ self .h = self .v = self .w = self .x = self .y = self .z = 0
740
+ self .stack = []
741
+ self .text = []
742
+ self .boxes = []
732
743
self .f = self ._first_font
733
744
self ._missing_font = None
734
745
return self .file .tell () + pl
@@ -794,7 +805,9 @@ def __init__(self, filename):
794
805
widths = struct .unpack (f'!{ nw } i' , file .read (4 * nw ))
795
806
heights = struct .unpack (f'!{ nh } i' , file .read (4 * nh ))
796
807
depths = struct .unpack (f'!{ nd } i' , file .read (4 * nd ))
797
- self .width , self .height , self .depth = {}, {}, {}
808
+ self .width = {}
809
+ self .height = {}
810
+ self .depth = {}
798
811
for idx , char in enumerate (range (bc , ec + 1 )):
799
812
byte0 = char_info [4 * idx ]
800
813
byte1 = char_info [4 * idx + 1 ]
0 commit comments