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

Method __init__

lib/matplotlib/_mathtext.py:1651–1677  ·  view source on GitHub ↗
(self, c: str, height: float, depth: float, state: ParserState,
                 factor: float | None = None)

Source from the content-addressed store, hash-verified

1649 """
1650
1651 def __init__(self, c: str, height: float, depth: float, state: ParserState,
1652 factor: float | None = None):
1653 alternatives = state.fontset.get_sized_alternatives_for_symbol(state.font, c)
1654
1655 x_height = state.fontset.get_xheight(state.font, state.fontsize, state.dpi)
1656
1657 state = state.copy()
1658 target_total = height + depth
1659 for fontname, sym in alternatives:
1660 state.font = fontname
1661 char = Char(sym, state)
1662 # Ensure that size 0 is chosen when the text is regular sized but
1663 # with descender glyphs by subtracting 0.2 * x_height
1664 if char.height + char.depth >= target_total - 0.2 * x_height:
1665 break
1666
1667 shift = 0.0
1668 if state.font != '0' or len(alternatives) == 1:
1669 if factor is None:
1670 factor = target_total / (char.height + char.depth)
1671 state.fontsize *= factor
1672 char = Char(sym, state)
1673
1674 shift = (depth - char.depth)
1675
1676 super().__init__([char])
1677 self.shift_amount = shift
1678
1679
1680class AutoWidthChar(Hlist):

Callers

nothing calls this directly

Calls 5

CharClass · 0.85
get_xheightMethod · 0.45
copyMethod · 0.45
__init__Method · 0.45

Tested by

no test coverage detected