neoscore.core.rich_text

class neoscore.core.rich_text.RichText[source]

Bases: PositionedObject

A graphical rich text object.

Unlike its simpler counterpart in Text, this supports rich formatting with HTML input. As neoscore is currently backed by Qt, this input supports Qt’s HTML subset documented at https://doc.qt.io/qt-5/richtext-html-subset.html

__init__(pos: PointDef, parent: Optional[PositionedObject], html_text: str, width: Optional[Unit] = None, font: Optional[Font] = None, scale: float = 1, rotation: float = 0, transform_origin: PointDef = ORIGIN)[source]
Parameters
  • pos – Position relative to the parent

  • parent – The parent (core-level) object or None

  • html_text – The text to be displayed, written in HTML.

  • width – The maximum width for the displayed text. If omitted, lines will only break when explicitly called for by the HTML.

  • font – The default font to display the text in.

  • scale – A scaling factor relative to the font size.

  • rotation – Rotation angle in degrees.

  • transform_origin – The origin point for rotation and scaling transforms

property breakable_length: Unit

The breakable length of the object.

This is always 0, meaning RichText objects cannot be broken across Flowable lines.

property html_text: str

The text to be displayed, written in HTML.

property width: Optional[Unit]

The maximum width for the displayed text.

If omitted, lines will only break when explicitly called for by the HTML.

property font: Font

The default font used to display the text.

HTML markup can override this to different styles and famililes.

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 to self.parent and created interfaces (or higher level classes) must be assigned a parent. In this case, created interfaces should use self.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 appears

  • flowable_x – If in a Flowable, the flowable x position of this render