Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb2b76d6

Browse files
authored
Merge pull request#29817 from anntzer/opentypedvi-prepare
2 parentsbfbd0b5 +c1dba8e commitb2b76d6

File tree

4 files changed

+28
-25
lines changed

4 files changed

+28
-25
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``DviFont.widths``
2+
~~~~~~~~~~~~~~~~~~
3+
... is deprecated with no replacement.

‎lib/matplotlib/backends/backend_pdf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -991,15 +991,19 @@ def _embedTeXFont(self, fontinfo):
991991

992992
# Widths
993993
widthsObject=self.reserveObject('font widths')
994-
self.writeObject(widthsObject,fontinfo.dvifont.widths)
994+
tfm=fontinfo.dvifont._tfm
995+
# convert from TeX's 12.20 representation to 1/1000 text space units.
996+
widths= [(1000*tfm.width.get(char,0))>>20
997+
forcharinrange(max(tfm.width,default=-1)+1)]
998+
self.writeObject(widthsObject,widths)
995999

9961000
# Font dictionary
9971001
fontdictObject=self.reserveObject('font dictionary')
9981002
fontdict= {
9991003
'Type':Name('Font'),
10001004
'Subtype':Name('Type1'),
10011005
'FirstChar':0,
1002-
'LastChar':len(fontinfo.dvifont.widths)-1,
1006+
'LastChar':len(widths)-1,
10031007
'Widths':widthsObject,
10041008
}
10051009

‎lib/matplotlib/dviread.py

Lines changed: 17 additions & 22 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
forx,y,f,g,winfont._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
forx,y,a,binfont._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-
exceptValueError:
597-
nchars=0
598-
self.widths= [(1000*tfm.width.get(char,0))>>20
599-
forcharinrange(nchars)]
590+
591+
widths=_api.deprecated("3.11")(property(lambdaself: [
592+
(1000*self._tfm.width.get(char,0))>>20
593+
forcharinrange(max(self._tfm.width,default=-1)+1)]))
600594

601595
def__eq__(self,other):
602596
return (type(self)istype(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
ifwidthisnotNone:
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
return0
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 in20.12 fixed point format."""
758+
def_mul1220(num1,num2):
759+
"""Multiply two numbers in12.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

‎lib/matplotlib/dviread.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,13 @@ class Dvi:
5656
classDviFont:
5757
texname:bytes
5858
size:float
59-
widths:list[int]
6059
def__init__(
6160
self,scale:float,tfm:Tfm,texname:bytes,vf:Vf|None
6261
)->None: ...
6362
def__eq__(self,other:object)->bool: ...
6463
def__ne__(self,other:object)->bool: ...
64+
@property
65+
defwidths(self)->list[int]: ...
6566

6667
classVf(Dvi):
6768
def__init__(self,filename:str|os.PathLike)->None: ...

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp