MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / AutoWidthChar

Class AutoWidthChar

site-packages/matplotlib/mathtext.py:2010–2034  ·  view source on GitHub ↗

:class:`AutoWidthChar` will create a character as close to the given width as possible. When using a font with multiple width versions of some characters (such as the BaKoMa fonts), the correct glyph will be selected, otherwise this will always just return a scaled version of t

Source from the content-addressed store, hash-verified

2008 self.shift_amount = shift
2009
2010class AutoWidthChar(Hlist):
2011 """
2012 :class:`AutoWidthChar` will create a character as close to the
2013 given width as possible. When using a font with multiple width
2014 versions of some characters (such as the BaKoMa fonts), the
2015 correct glyph will be selected, otherwise this will always just
2016 return a scaled version of the glyph.
2017 """
2018 def __init__(self, c, width, state, always=False, char_class=Char):
2019 alternatives = state.font_output.get_sized_alternatives_for_symbol(
2020 state.font, c)
2021
2022 state = state.copy()
2023 for fontname, sym in alternatives:
2024 state.font = fontname
2025 char = char_class(sym, state)
2026 if char.width >= width:
2027 break
2028
2029 factor = width / char.width
2030 state.fontsize *= factor
2031 char = char_class(sym, state)
2032
2033 Hlist.__init__(self, [char])
2034 self.width = char.width
2035
2036
2037class Ship(object):

Callers 1

accentMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected