neoscore.core.font

class neoscore.core.font.Font[source]

Bases: object

A text font.

All fonts are immutable. To get a modified version of a font, use Font.modified

__init__(family_name: str, size: Union[Unit, float], weight: Optional[int] = None, italic: bool = False)[source]
Parameters
  • family_name – The font family name

  • size – The size (height) of the font

  • weight – The font weight on a 0-100 scale, where 50 is normal, lower numbers are lighter, and higher are darker. If None (the default), a normal weight will be used.

  • italic – Whether the font is italicized

property family_name: str
property size: Unit
property weight: Optional[int]
property italic: bool
property ascent: Unit

The ascent of the font.

The ascent is the vertical distance between the font baseline and the highest any font characters reach.

property descent: Unit

The descent of the font.

The ascent is the vertical distance between the font baseline and the lowest any font characters reach.

property x_height: Unit

The x-height for the font.

property interface: FontInterface

The backing low-level font interface

modified(family_name: Optional[str] = None, size: Optional[Union[Unit, float]] = None, weight: Optional[int] = None, italic: Optional[bool] = None) Font[source]

Derive a font from this one.

All properties not specified will be taken from the existing font.

bounding_rect_of(string: str) Rect[source]

Approximate the bounding rect of a string in this font.