@@ -398,14 +398,14 @@ def _put_char_real(self, char):
398398 else :
399399 scale = font ._scale
400400 for x , y , f , g , w in font ._vf [char ].text :
401- newf = DviFont (scale = _mul2012 (scale , f ._scale ),
401+ newf = DviFont (scale = _mul1220 (scale , f ._scale ),
402402 tfm = f ._tfm , texname = f .texname , vf = f ._vf )
403- self .text .append (Text (self .h + _mul2012 (x , scale ),
404- self .v + _mul2012 (y , scale ),
403+ self .text .append (Text (self .h + _mul1220 (x , scale ),
404+ self .v + _mul1220 (y , scale ),
405405 newf , g , newf ._width_of (g )))
406- self .boxes .extend ([Box (self .h + _mul2012 (x , scale ),
407- self .v + _mul2012 (y , scale ),
408- _mul2012 (a , scale ), _mul2012 (b , scale ))
406+ self .boxes .extend ([Box (self .h + _mul1220 (x , scale ),
407+ self .v + _mul1220 (y , scale ),
408+ _mul1220 (a , scale ), _mul1220 (b , scale ))
409409 for x , y , a , b in font ._vf [char ].boxes ])
410410
411411 @_dispatch (137 , state = _dvistate .inpage , args = ('s4' , 's4' ))
@@ -577,12 +577,8 @@ class DviFont:
577577 size : float
578578 Size of the font in Adobe points, converted from the slightly
579579 smaller TeX points.
580- widths : list
581- Widths of glyphs in glyph-space units, typically 1/1000ths of
582- the point size.
583-
584580 """
585- __slots__ = ('texname' , 'size' , 'widths' , ' _scale' , '_vf' , '_tfm' )
581+ __slots__ = ('texname' , 'size' , '_scale' , '_vf' , '_tfm' )
586582
587583 def __init__ (self , scale , tfm , texname , vf ):
588584 _api .check_isinstance (bytes , texname = texname )
@@ -591,12 +587,10 @@ def __init__(self, scale, tfm, texname, vf):
591587 self .texname = texname
592588 self ._vf = vf
593589 self .size = scale * (72.0 / (72.27 * 2 ** 16 ))
594- try :
595- nchars = max (tfm .width ) + 1
596- except ValueError :
597- nchars = 0
598- self .widths = [(1000 * tfm .width .get (char , 0 )) >> 20
599- for char in range (nchars )]
590+
591+ widths = _api .deprecated ("3.11" )(property (lambda self : [
592+ (1000 * self ._tfm .width .get (char , 0 )) >> 20
593+ for char in range (max (self ._tfm .width , default = - 1 ) + 1 )]))
600594
601595 def __eq__ (self , other ):
602596 return (type (self ) is type (other )
@@ -612,7 +606,7 @@ def _width_of(self, char):
612606 """Width of char in dvi units."""
613607 width = self ._tfm .width .get (char , None )
614608 if width is not None :
615- return _mul2012 (width , self ._scale )
609+ return _mul1220 (width , self ._scale )
616610 _log .debug ('No width for char %d in font %s.' , char , self .texname )
617611 return 0
618612
@@ -627,7 +621,7 @@ def _height_depth_of(self, char):
627621 name , char , self .texname )
628622 result .append (0 )
629623 else :
630- result .append (_mul2012 (value , self ._scale ))
624+ result .append (_mul1220 (value , self ._scale ))
631625 # cmsyXX (symbols font) glyph 0 ("minus") has a nonzero descent
632626 # so that TeX aligns equations properly
633627 # (https://tex.stackexchange.com/q/526103/)
@@ -761,8 +755,8 @@ def _pre(self, i, x, cs, ds):
761755 # cs = checksum, ds = design size
762756
763757
764- def _mul2012 (num1 , num2 ):
765- """Multiply two numbers in 20.12 fixed point format."""
758+ def _mul1220 (num1 , num2 ):
759+ """Multiply two numbers in 12.20 fixed point format."""
766760 # Separated into a function because >> has surprising precedence
767761 return (num1 * num2 ) >> 20
768762
@@ -782,7 +776,8 @@ class Tfm:
782776 checksum : int
783777 Used for verifying against the dvi file.
784778 design_size : int
785- Design size of the font (unknown units)
779+ Design size of the font (in 12.20 TeX points); unused because it is
780+ overridden by the scale factor specified in the dvi file.
786781 width, height, depth : dict
787782 Dimensions of each character, need to be scaled by the factor
788783 specified in the dvi file. These are dicts because indexing may
0 commit comments