Skip to content

yex.box.CharBox

yex.box.CharBox(font, ch, from_ligature=None) #

Bases: yex.box.box.Box

A Box containing a single character from a font.

Attributes:

Name Type Description
ch str

the character

font yex.font.Font

the font

from_ligature str

the ligature that produced this character, or None if there wasn't one. Usually this is None. It's only used for diagnostics.

Source code in yex/box/box.py
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
def __init__(self, font: 'yex.font.Font', ch: str,
             from_ligature: Union[str,None]=None,
             ):

    try:
        metric = font.charset[ch]
    except KeyError:
        raise yex.exception.NoSuchCharInFontError(
                char = ch,
                font = font,
                )

    super().__init__(
            height = Dimen.from_another(metric.height),
            width = Dimen.from_another(metric.width),
            depth = Dimen.from_another(metric.depth),
            )

    self.font = font
    self.ch = ch
    self.from_ligature = None