Argument specifying SMuFL MusicText strings.

This supports several forms for different use-cases. The most commonly used form is a simple SMuFL canonical glyph name.

  • A canonical SMuFL glyph name. This may be an empty string to indicate 0-length text.

  • A tuple of a glyph name and a SMuFL alternate number.

  • A fully defined MusicChar.

  • A list of any of these, including an empty list.

alias of Union[MusicChar, str, Tuple[str, int], List[Union[MusicChar, str, Tuple[str, int]]]]

class neoscore.core.music_text.MusicText[source]

Bases: Text, HasMusicFont

Text written in SMuFL compliant music fonts.

For many use-cases, MusicText strings will consist of a single character, but longer strings are supported too.

__init__(pos: PointDef, parent: Optional[PositionedObject], text: MusicStringDef, font: Optional[MusicFont] = None, brush: Optional[BrushDef] = None, pen: Optional[PenDef] = None, scale: float = 1, rotation: float = 0, background_brush: Optional[BrushDef] = None, z_index: int = 0, breakable: bool = True, alignment_x: AlignmentX = AlignmentX.LEFT, alignment_y: AlignmentY = AlignmentY.BASELINE)[source]
  • pos – The position of the text.

  • parent – The parent of the glyph. If no font is given, this or one of its ancestors must implement HasMusicFont.

  • text – The text to display. Can be given as a SMuFL glyph name or other shorthand forms. See MusicStringDef.

  • font – The music font to be used. If not specified, parent must implement HasMusicFont or have an ancestor which does.

  • brush – The brush to fill in text shapes with.

  • pen – The pen to trace text outlines with. This defaults to no pen.

  • scale – A scaling factor to be applied in addition to the size of the music font.

  • rotation – Angle in degrees. Note that breakable rotated text is not currently supported.

  • background_brush – Optional brush used to paint the text’s bounding rect behind it.

  • z_index – Controls draw order with lower values drawn first.

  • breakable – Whether this object should break across lines in Flowable containers.

  • alignment_x – The text’s horizontal alignment relative to pos. Note that text which is not LEFT aligned does not currently display correctly when breaking across flowable lines.

  • alignment_y – The text’s vertical alignment relative to pos.

property music_chars: List[MusicChar]

A list of the SMuFL characters in the string including metadata.

If set, this will also update text.

property text: str

The raw unicode representation of the SMuFL text.

If set, this will also update music_chars.

property music_font: MusicFont

The SMuFL font used in this text.

This is an expressive synonym for font.

property unit: Type[Unit]

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