Repository: matplotlib/matplotlib
File: lib/matplotlib/dviread.py (Python)

Code before:
        # (https://tex.stackexchange.com/q/526103/)
        # but we actually care about the rasterization depth to align
        # the dvipng-generated images.
        if re.match(br'^cmsy\d+$', self.texname) and char == 0:
            hd[-1] = 0
        return hd


class Vf(Dvi):
    r"""
    A virtual font (\*.vf file) containing subroutines for dvi files.

    Parameters
    ----------
    filename : str or path-like

    Notes
    -----
    The virtual font format is a derivative of dvi:
    http://mirrors.ctan.org/info/knuth/virtual-fonts
    This class reuses some of the machinery of `Dvi`
    but replaces the `!_read` loop and dispatch mechanism.

    Examples
    --------
    ::

        vf = Vf(filename)
        glyph = vf[code]
        glyph.text, glyph.boxes, glyph.width
    """

    def __init__(self, filename):
        super().__init__(filename, 0)
        try:
            self._first_font = None
            self._chars = {}
            self._read()
        finally:
            self.close()

    def __getitem__(self, code):
        return self._chars[code]

    def _read(self):
        """
        Read one page from the file. Return True if successful,
        False if there were no more pages.
        """
        packet_char = packet_ends = None
        packet_len = packet_width = None

Review comment (suggestion):
just checking but is this why this step is no longer needed: ```index = t1_encodings[font][glyph_name_or_index]```

Code after:
        if metrics is None:
            _log.debug('No metrics for char %d in font %s', char, self.texname)
            return [0, 0]
        hd = [
            _mul1220(metrics.tex_height, self._scale),
            _mul1220(metrics.tex_depth, self._scale),
        ]
        # cmsyXX (symbols font) glyph 0 ("minus") has a nonzero descent
        # so that TeX aligns equations properly
        # (https://tex.stackexchange.com/q/526103/)
        # but we actually care about the rasterization depth to align
        # the dvipng-generated images.
        if re.match(br'^cmsy\d+$', self.texname) and char == 0:
            hd[-1] = 0
        return hd

    def _index_dvi_to_freetype(self, idx):
        """Convert dvi glyph indices to FreeType ones."""
        # Glyphs indices stored in the dvi file map to FreeType glyph indices
        # (i.e., which can be passed to FT_Load_Glyph) in various ways:
        # - if pdftex.map specifies an ".enc" file for the font, that file maps
        #   dvi indices to Adobe glyph names, which can then be converted to
        #   FreeType glyph indices with FT_Get_Name_Index.
        # - if no ".enc" file is specified, then the font must be a Type 1
        #   font, and dvi indices directly index into the font's CharStrings
        #   vector.
        # - (xetex & luatex, currently unsupported, can also declare "native
        #   fonts", for which dvi indices are equal to FreeType indices.)
        if self._encoding is None:
            psfont = PsfontsMap(find_tex_file("pdftex.map"))[self.texname]
            if psfont.filename is None:
                raise ValueError("No usable font file found for {} ({}); "
                                 "the font may lack a Type-1 version"
                                 .format(psfont.psname.decode("ascii"),
                                         psfont.texname.decode("ascii")))
            face = font_manager.get_font(psfont.filename)
            if psfont.encoding:
                self._encoding = [face.get_name_index(name)
                                  for name in _parse_enc(psfont.encoding)]
            else:
                self._encoding = face._get_type1_encoding_vector()
        return self._encoding[idx]


class Vf(Dvi):
    r"""
    A virtual font (\*.vf file) containing subroutines for dvi files.

    Parameters
    ----------
    filename : str or path-like