Skip to content

yex.font.Default

yex.font.Default(name='tenrm') #

Bases: yex.font.tfm.Tfm

The metrics for the font cmr10, hard-coded.

It exists because cmr10 is the default font, and every Document containing at least one symbol attempts to access it. So, if there's any problem loading the external file cmr10.tfm, every Document will break.

Just like the real font metrics, it doesn't contain the glyphs. If you look them up using the glyphs attribute, it will load them from cmr10.pk.

You can get hold of the singleton instance of this font using

Font.from_name(None)

If you do

Font.from_name("cmr10")
you will still get the metrics for cmr10.

At the end of this module, there is some code which loads the real cmr10.fnt and produces the values for this class. Its output will need some rearranging before it fits the actual code.

Attributes:

Name Type Description
name

the name of this font in the controls table. Defaults to "tenrm".

Source code in yex/font/default.py
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
def __init__(self,
             name:str = 'tenrm',
        ):
    self.hyphenchar = 45
    self.size = Dimen(10, 'pt')
    self.scale = None
    self.skewchar = -1
    self.used = set()
    self._glyphs = None
    self._interword = None
    self._custom_dimens = {}
    self.name = name or 'tenrm'
    self.source = 'cmr10'

    self.metrics = _DefaultMetrics(font=self)
    self.charset = _DefaultCharset(font=self)