neoscore.core.has_music_font

class neoscore.core.has_music_font.HasMusicFont[source]

Bases: object

A mixin for classes which have an associated staff measurement.

This is useful for integration with SMuFL fonts, where glyphs and their metadata are measured relative to a staff space.

A naive and slow implementation of the music_font property is provided which returns the nearest music found in the object’s ancestors. Subclasses will often want to override this.

property music_font: MusicFont

The music font used by this object.

property unit: Type[Unit]

A unit type where unit(1) is the size of a staff space in the font.

static find_music_font(obj: PositionedObject) MusicFont[source]

Return the music font from obj or its nearest ancestor with one.

This checks obj and then its ancestors for whether they have a music_font attribute, returning the first value found. If no font is found, this raises a NoAncestorWithMusicFontError.