@@ -398,14 +398,14 @@ def _put_char_real(self, char):
398
398
else :
399
399
scale = font ._scale
400
400
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 ),
402
402
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 ),
405
405
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 ))
409
409
for x , y , a , b in font ._vf [char ].boxes ])
410
410
411
411
@_dispatch (137 , state = _dvistate .inpage , args = ('s4' , 's4' ))
@@ -577,12 +577,8 @@ class DviFont:
577
577
size : float
578
578
Size of the font in Adobe points, converted from the slightly
579
579
smaller TeX points.
580
- widths : list
581
- Widths of glyphs in glyph-space units, typically 1/1000ths of
582
- the point size.
583
-
584
580
"""
585
- __slots__ = ('texname' , 'size' , 'widths' , ' _scale' , '_vf' , '_tfm' )
581
+ __slots__ = ('texname' , 'size' , '_scale' , '_vf' , '_tfm' )
586
582
587
583
def __init__ (self , scale , tfm , texname , vf ):
588
584
_api .check_isinstance (bytes , texname = texname )
@@ -591,12 +587,10 @@ def __init__(self, scale, tfm, texname, vf):
591
587
self .texname = texname
592
588
self ._vf = vf
593
589
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 )]))
600
594
601
595
def __eq__ (self , other ):
602
596
return (type (self ) is type (other )
@@ -612,7 +606,7 @@ def _width_of(self, char):
612
606
"""Width of char in dvi units."""
613
607
width = self ._tfm .width .get (char , None )
614
608
if width is not None :
615
- return _mul2012 (width , self ._scale )
609
+ return _mul1220 (width , self ._scale )
616
610
_log .debug ('No width for char %d in font %s.' , char , self .texname )
617
611
return 0
618
612
@@ -627,7 +621,7 @@ def _height_depth_of(self, char):
627
621
name , char , self .texname )
628
622
result .append (0 )
629
623
else :
630
- result .append (_mul2012 (value , self ._scale ))
624
+ result .append (_mul1220 (value , self ._scale ))
631
625
# cmsyXX (symbols font) glyph 0 ("minus") has a nonzero descent
632
626
# so that TeX aligns equations properly
633
627
# (https://tex.stackexchange.com/q/526103/)
@@ -761,8 +755,8 @@ def _pre(self, i, x, cs, ds):
761
755
# cs = checksum, ds = design size
762
756
763
757
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."""
766
760
# Separated into a function because >> has surprising precedence
767
761
return (num1 * num2 ) >> 20
768
762
@@ -782,7 +776,8 @@ class Tfm:
782
776
checksum : int
783
777
Used for verifying against the dvi file.
784
778
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.
786
781
width, height, depth : dict
787
782
Dimensions of each character, need to be scaled by the factor
788
783
specified in the dvi file. These are dicts because indexing may
0 commit comments