MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / _fnt_def_real

Method _fnt_def_real

lib/matplotlib/dviread.py:513–543  ·  view source on GitHub ↗
(self, k, c, s, d, a, l)

Source from the content-addressed store, hash-verified

511 self._fnt_def_real(k, c, s, d, a, l)
512
513 def _fnt_def_real(self, k, c, s, d, a, l):
514 n = self.file.read(a + l)
515 fontname = n[-l:]
516 if fontname.startswith(b"[") and c == 0x4c756146: # c == "LuaF"
517 # See https://chat.stackexchange.com/rooms/106428 (and also
518 # https://tug.org/pipermail/dvipdfmx/2021-January/000168.html).
519 # AFAICT luatex's dvi drops info re: OpenType variation-axis values.
520 self.fonts[k] = DviFont.from_luatex(s, n)
521 return
522 fontname = fontname.decode("ascii")
523 try:
524 tfm = _tfmfile(fontname)
525 except FileNotFoundError as exc:
526 if fontname.startswith("[") and fontname.endswith(";") and c == 0:
527 exc.add_note(
528 "This dvi file was likely generated with a too-old "
529 "version of luaotfload; luaotfload 3.23 is required.")
530 # Explicitly allow defining missing fonts for Vf support; we only
531 # register an error when trying to load a glyph from a missing font
532 # and throw that error in Dvi._read. For Vf, _finalize_packet
533 # checks whether a missing glyph has been used, and in that case
534 # skips the glyph definition.
535 self.fonts[k] = cbook._ExceptionInfo.from_exception(exc)
536 return
537 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
538 raise ValueError(f'tfm checksum mismatch: {n}')
539 try:
540 vf = _vffile(fontname)
541 except FileNotFoundError:
542 vf = None
543 self.fonts[k] = DviFont(scale=s, metrics=tfm, texname=n, vf=vf)
544
545 @_dispatch(247, state=_dvistate.pre, args=('u1', 'u4', 'u4', 'u4', 'u1'))
546 def _pre(self, i, num, den, mag, k):

Callers 2

_fnt_defMethod · 0.95
_readMethod · 0.80

Calls 3

DviFontClass · 0.85
from_luatexMethod · 0.80
from_exceptionMethod · 0.80

Tested by

no test coverage detected