neoscore.western.instrument_name
- class neoscore.western.instrument_name.InstrumentName[source]
Bases:
PaintedObject
,StaffObject
A simple instrument name written in staff fringes
When created, this causes a given string to be printed in the fringe of each staff system. The given position is relative to the top left corner of the staff in the fringe, and the text is right-aligned and vertically centered at this point.
Instrument name changes within a staff are not currently supported.
- __init__(relative_fringe_pos: Union[Point, Tuple[Unit, Unit]], staff: AbstractStaff, first_line_text: str, later_lines_text: Optional[str] = None, font: Optional[Font] = None, brush: Optional[Union[Brush, str]] = None, pen: Optional[Union[Pen, str]] = None)[source]
- Parameters
relative_fringe_pos – The position of the text in the fringe. This is relative to the top left corner of the staff in the fringe, and the text is right-aligned and vertically centered at this point.
staff – The parent staff
first_line_text – The text to write in the first line’s fringe
later_lines_text – Optional different text to write in lines after the first. This is useful for writing short-form instrument names. If
None
, the first line text is used everywhere. Set to an empty string to make later lines blank.font – The font used. Defaults to the document-wide default font.
brush – The brush to fill in text shapes with.
pen – The pen to trace text outlines with. This defaults to no pen.
- property first_line_text: str
The text to write in the first line’s fringe
- property later_lines_text: Optional[str]
Optional different text to write in lines after the first.
This is useful for writing short-form instrument names. If
None
, the first line text is used everywhere. Set to an empty string to make later lines blank.
- render_complete(pos: Point, flowable_line: Optional[NewLine] = None, flowable_x: Optional[Unit] = None)[source]
Render the entire object.
This is used to render all objects outside flowables, as well as those inside flowables when they fit completely in one line of the flowable.
By default, this is a no-op. Subclasses with rendered appearances should override this.
This method behaves differently inside and outside of flowables. Whether this object is inside a flowable can be determined by whether a
flowable_line
is given. When inside a flowable, the given position is in global document coordinates, and created interfaces (or higher level classes) must not be assigned a parent. When not inside a flowable, the given position is relative toself.parent
and created interfaces (or higher level classes) must be assigned a parent. In this case, created interfaces should useself.parent.interface_for_children
as their parent.This and other render methods should generally not be called directly.
- Parameters
pos – The rendering position. If outside a flowable, this is relative to the parent. Otherwise, it is in document coordinates.
flowable_line – If in a
Flowable
, the line in which this object appearsflowable_x – If in a
Flowable
, the flowable x position of this render
- render_before_break(pos: Point, flowable_line: NewLine, flowable_x: Unit)[source]
Render the beginning of the object up to a stopping point.
For use in flowable containers when rendering an object that crosses a line or page break. This function should render the beginning portion of the object up to the break.
By default, this is a no-op. Subclasses with rendered appearances should override this.
Created interfaces and higher level objects should not be assigned a parent.
This and other render methods should generally not be called directly.
- Parameters
pos – The rendering position in document space for drawing.
flowable_line – The line in which this object appears
flowable_x – The flowable x position of this render
- render_spanning_continuation(pos: Point, flowable_line: NewLine, object_x: Unit)[source]
Render the continuation of an object after a break and before another.
For use in flowable containers when rendering an object that crosses two breaks. This function should render the portion of the object surrounded by breaks on either side.
By default, this is a no-op. Subclasses with rendered appearances should override this.
Created interfaces and higher level objects should not be assigned a parent.
This and other render methods should generally not be called directly.
- Parameters
pos – The rendering position in document space for drawing.
flowable_line – The line in which this object appears
object_x – The local object x position of the line’s start.
- render_after_break(pos: Point, flowable_line: NewLine, object_x: Unit)[source]
Render the continuation of an object after a break.
For use in flowable containers when rendering an object that crosses a line or page break. This function should render the ending portion of an object after a break.
By default, this is a no-op. Subclasses with rendered appearances should override this.
Created interfaces and higher level objects should not be assigned a parent.
This and other render methods should generally not be called directly.
- Parameters
pos – The rendering position in document space for drawing.
flowable_line – The line in which this object appears
object_x – The local object x position of the line’s start.