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

Prepare for {xe,lua}tex support in usetex.#29817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
timhoffm merged 3 commits intomatplotlib:mainfromanntzer:opentypedvi-prepare
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletionsdoc/api/next_api_changes/deprecations/29817-AL.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
``DviFont.widths``
~~~~~~~~~~~~~~~~~~
... is deprecated with no replacement.
8 changes: 6 additions & 2 deletionslib/matplotlib/backends/backend_pdf.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -991,15 +991,19 @@ def _embedTeXFont(self, fontinfo):

# Widths
widthsObject = self.reserveObject('font widths')
self.writeObject(widthsObject, fontinfo.dvifont.widths)
tfm = fontinfo.dvifont._tfm
# convert from TeX's 12.20 representation to 1/1000 text space units.
widths = [(1000 * tfm.width.get(char, 0)) >> 20
for char in range(max(tfm.width, default=-1) + 1)]
self.writeObject(widthsObject, widths)

# Font dictionary
fontdictObject = self.reserveObject('font dictionary')
fontdict = {
'Type': Name('Font'),
'Subtype': Name('Type1'),
'FirstChar': 0,
'LastChar': len(fontinfo.dvifont.widths) - 1,
'LastChar': len(widths) - 1,
'Widths': widthsObject,
}

Expand Down
39 changes: 17 additions & 22 deletionslib/matplotlib/dviread.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -398,14 +398,14 @@ def _put_char_real(self, char):
else:
scale = font._scale
for x, y, f, g, w in font._vf[char].text:
newf = DviFont(scale=_mul2012(scale, f._scale),
newf = DviFont(scale=_mul1220(scale, f._scale),
tfm=f._tfm, texname=f.texname, vf=f._vf)
self.text.append(Text(self.h +_mul2012(x, scale),
self.v +_mul2012(y, scale),
self.text.append(Text(self.h +_mul1220(x, scale),
self.v +_mul1220(y, scale),
newf, g, newf._width_of(g)))
self.boxes.extend([Box(self.h +_mul2012(x, scale),
self.v +_mul2012(y, scale),
_mul2012(a, scale),_mul2012(b, scale))
self.boxes.extend([Box(self.h +_mul1220(x, scale),
self.v +_mul1220(y, scale),
_mul1220(a, scale),_mul1220(b, scale))
for x, y, a, b in font._vf[char].boxes])

@_dispatch(137, state=_dvistate.inpage, args=('s4', 's4'))
Expand DownExpand Up@@ -577,12 +577,8 @@ class DviFont:
size : float
Size of the font in Adobe points, converted from the slightly
smaller TeX points.
widths : list
Widths of glyphs in glyph-space units, typically 1/1000ths of
the point size.

"""
__slots__ = ('texname', 'size', 'widths', '_scale', '_vf', '_tfm')
__slots__ = ('texname', 'size', '_scale', '_vf', '_tfm')

def __init__(self, scale, tfm, texname, vf):
_api.check_isinstance(bytes, texname=texname)
Expand All@@ -591,12 +587,10 @@ def __init__(self, scale, tfm, texname, vf):
self.texname = texname
self._vf = vf
self.size = scale * (72.0 / (72.27 * 2**16))
try:
nchars = max(tfm.width) + 1
except ValueError:
nchars = 0
self.widths = [(1000*tfm.width.get(char, 0)) >> 20
for char in range(nchars)]

widths = _api.deprecated("3.11")(property(lambda self: [
(1000 * self._tfm.width.get(char, 0)) >> 20
for char in range(max(self._tfm.width, default=-1) + 1)]))

def __eq__(self, other):
return (type(self) is type(other)
Expand All@@ -612,7 +606,7 @@ def _width_of(self, char):
"""Width of char in dvi units."""
width = self._tfm.width.get(char, None)
if width is not None:
return_mul2012(width, self._scale)
return_mul1220(width, self._scale)
_log.debug('No width for char %d in font %s.', char, self.texname)
return 0

Expand All@@ -627,7 +621,7 @@ def _height_depth_of(self, char):
name, char, self.texname)
result.append(0)
else:
result.append(_mul2012(value, self._scale))
result.append(_mul1220(value, self._scale))
# cmsyXX (symbols font) glyph 0 ("minus") has a nonzero descent
# so that TeX aligns equations properly
# (https://tex.stackexchange.com/q/526103/)
Expand DownExpand Up@@ -761,8 +755,8 @@ def _pre(self, i, x, cs, ds):
# cs = checksum, ds = design size


def_mul2012(num1, num2):
"""Multiply two numbers in20.12 fixed point format."""
def_mul1220(num1, num2):
"""Multiply two numbers in12.20 fixed point format."""
# Separated into a function because >> has surprising precedence
return (num1*num2) >> 20

Expand All@@ -782,7 +776,8 @@ class Tfm:
checksum : int
Used for verifying against the dvi file.
design_size : int
Design size of the font (unknown units)
Design size of the font (in 12.20 TeX points); unused because it is
overridden by the scale factor specified in the dvi file.
width, height, depth : dict
Dimensions of each character, need to be scaled by the factor
specified in the dvi file. These are dicts because indexing may
Expand Down
3 changes: 2 additions & 1 deletionlib/matplotlib/dviread.pyi
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -56,12 +56,13 @@ class Dvi:
class DviFont:
texname: bytes
size: float
widths: list[int]
def __init__(
self, scale: float, tfm: Tfm, texname: bytes, vf: Vf | None
) -> None: ...
def __eq__(self, other: object) -> bool: ...
def __ne__(self, other: object) -> bool: ...
@property
def widths(self) -> list[int]: ...

class Vf(Dvi):
def __init__(self, filename: str | os.PathLike) -> None: ...
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp