Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ae3d057

Browse files
committed
Rename the confusingly named dviread._mul2012.
Dvi fixed-point values are in 12.20 format (12 bits before the decimal point, 20 bits after -- see e.g. the 20-bit bitshifts scattered in the dviread module), not 20.12. Rename the helper function accordingly.
1 parent cb5d039 commit ae3d057

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

lib/matplotlib/dviread.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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'))
@@ -606,7 +606,7 @@ def _width_of(self, char):
606606
"""Width of char in dvi units."""
607607
width = self._tfm.width.get(char, None)
608608
if width is not None:
609-
return _mul2012(width, self._scale)
609+
return _mul1220(width, self._scale)
610610
_log.debug('No width for char %d in font %s.', char, self.texname)
611611
return 0
612612

@@ -621,7 +621,7 @@ def _height_depth_of(self, char):
621621
name, char, self.texname)
622622
result.append(0)
623623
else:
624-
result.append(_mul2012(value, self._scale))
624+
result.append(_mul1220(value, self._scale))
625625
# cmsyXX (symbols font) glyph 0 ("minus") has a nonzero descent
626626
# so that TeX aligns equations properly
627627
# (https://tex.stackexchange.com/q/526103/)
@@ -755,8 +755,8 @@ def _pre(self, i, x, cs, ds):
755755
# cs = checksum, ds = design size
756756

757757

758-
def _mul2012(num1, num2):
759-
"""Multiply two numbers in 20.12 fixed point format."""
758+
def _mul1220(num1, num2):
759+
"""Multiply two numbers in 12.20 fixed point format."""
760760
# Separated into a function because >> has surprising precedence
761761
return (num1*num2) >> 20
762762

0 commit comments

Comments
 (0)