TextSpanner

class spannertools.TextSpanner(overrides=None)

Text spanner.

>>> import abjad

Text spanner with no grob overrides:

>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> text_spanner = abjad.TextSpanner()
>>> abjad.attach(text_spanner, staff[:])
>>> show(staff) 

This is (notationally unlikely) default behavior.

Text spanner with grob override for left text:

>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> text_spanner = abjad.TextSpanner()
>>> markup = abjad.Markup('foo').italic().bold()
>>> abjad.override(text_spanner).text_spanner.bound_details__left__text = markup
>>> abjad.override(text_spanner).text_spanner.bound_details__left__stencil_align_dir_y = 0
>>> abjad.attach(text_spanner, staff[:])
>>> show(staff) 

Text spanner interacting with piecewise markup. At beginning of spanner:

>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> spanner = abjad.TextSpanner()
>>> abjad.attach(spanner, staff[:])
>>> spanner.attach(abjad.Markup('pont.'), staff[0])
>>> show(staff) 

Text spanner is suppresssed and only the markup appears.

Text spanner interacting with piecewise markup. At end of spanner:

>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> spanner = abjad.TextSpanner()
>>> abjad.attach(spanner, staff[:])
>>> spanner.attach(abjad.Markup('tasto'), staff[-1])
>>> show(staff) 

Text spanner is suppresssed and only the markup appears.

Text spanner interacting with piecewise markup. At beginning and end of spanner:

>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> spanner = abjad.TextSpanner()
>>> abjad.attach(spanner, staff[:])
>>> spanner.attach(abjad.Markup('pont.'), staff[0])
>>> spanner.attach(abjad.Markup('tasto'), staff[-1])
>>> show(staff) 

Text spanner is suppresssed and only the markup appear.

Text spanner interacting with piecewise indicators:

>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> spanner = abjad.TextSpanner()
>>> abjad.attach(spanner, staff[:])
>>> spanner.attach(abjad.Markup('one'), staff[0])
>>> spanner.attach(abjad.LineSegment(), staff[0])
>>> spanner.attach(abjad.Markup('two'), staff[1])
>>> spanner.attach(abjad.ArrowLineSegment(), staff[1])
>>> spanner.attach(abjad.Markup('three'), staff[-1])
>>> show(staff) 

Text spanner interacting with piecewise and nonpiecewise indicators:

>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> spanner = abjad.TextSpanner()
>>> abjad.attach(spanner, staff[:])
>>> spanner.attach(abjad.Markup('ord.'), staff[0])
>>> spanner.attach(abjad.ArrowLineSegment(), staff[0])
>>> spanner.attach(abjad.Markup('pont.'), staff[-1])
>>> abjad.attach(abjad.Markup('leggieriss.'), staff[0])
>>> abjad.override(staff).text_spanner.staff_padding = 2.5
>>> abjad.override(staff).text_script.staff_padding = 2
>>> show(staff) 

Raises exception on fewer than two leaves:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> spanner = abjad.TextSpanner()
>>> abjad.attach(spanner, staff[:1])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/joberholtzer/Abjad/abjad/abjad/tools/topleveltools/attach.py", line 105, in attach
    raise Exception(message)
Exception: TextSpanner() attachment test fails for Selection([Note("c'4")]).

Lineage

digraph InheritanceGraph { graph [background=transparent, bgcolor=transparent, color=lightslategrey, fontname=Arial, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, root="__builtin__.object", splines=spline, style="dotted, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=12, penwidth=2, style="filled, rounded"]; edge [color=lightsteelblue2, penwidth=2]; subgraph cluster_abctools { graph [label=abctools]; "abjad.tools.abctools.AbjadObject.AbjadObject" [color=1, group=0, label=AbjadObject, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" [color=1, group=0, label=AbstractBase, shape=box]; "abjad.tools.abctools.AbjadObject.AbstractBase" -> "abjad.tools.abctools.AbjadObject.AbjadObject"; } subgraph cluster_spannertools { graph [label=spannertools]; "abjad.tools.spannertools.Spanner.Spanner" [color=3, group=2, label=Spanner, shape=box]; "abjad.tools.spannertools.TextSpanner.TextSpanner" [color=black, fontcolor=white, group=2, label=<<B>TextSpanner</B>>, shape=box, style="filled, rounded"]; "abjad.tools.spannertools.Spanner.Spanner" -> "abjad.tools.spannertools.TextSpanner.TextSpanner"; } subgraph cluster_builtins { graph [label=builtins]; "builtins.object" [color=2, group=1, label=object, shape=box]; } "abjad.tools.abctools.AbjadObject.AbjadObject" -> "abjad.tools.spannertools.Spanner.Spanner"; "builtins.object" -> "abjad.tools.abctools.AbjadObject.AbstractBase"; }

Bases

Attribute summary

attach(indicator, leaf) Attaches indicator to leaf in spanner.
components Gets leaves in spanner.
name Gets spanner name.
overrides Gets text spanner overrides.
__contains__(argument) Is true when spanner contains argument.
__copy__(*arguments) Copies spanner.
__eq__(argument) Is true when ID of argument equals ID of Abjad object.
__format__([format_specification]) Formats Abjad object.
__getitem__(argument) Gets item or slice identified by argument.
__hash__() Hashes Abjad object.
__len__() Gets number of components in spanner.
__lt__(argument) Is true when spanner is less than argument.
__ne__(argument) Is true when Abjad object does not equal argument.
__repr__() Gets interpreter representation of Abjad object.

Read-only properties

(Spanner).components

Gets leaves in spanner.

Returns selection of leaves.

(Spanner).name

Gets spanner name.

Returns string.

TextSpanner.overrides

Gets text spanner overrides.

Overlapping spanner regression test. Red spanner reverts color before default spanner begins:

>>> staff = abjad.Staff("c'4 d' e' f' c' d' e' f'")
>>> text_spanner_1 = abjad.TextSpanner()
>>> markup = abjad.Markup('red').italic().bold()
>>> abjad.override(text_spanner_1).text_spanner.bound_details__left__text = markup
>>> abjad.override(text_spanner_1).text_spanner.bound_details__left__stencil_align_dir_y = 0
>>> abjad.override(text_spanner_1).text_spanner.bound_details__right__padding = 1
>>> abjad.override(text_spanner_1).text_spanner.color = 'red'
>>> abjad.attach(text_spanner_1, staff[:4])
>>> text_spanner_2 = abjad.TextSpanner()
>>> markup = abjad.Markup('default').italic().bold()
>>> abjad.override(text_spanner_2).text_spanner.bound_details__left__text = markup
>>> abjad.override(text_spanner_2).text_spanner.bound_details__left__stencil_align_dir_y = 0
>>> abjad.attach(text_spanner_2, staff[-5:])
>>> show(staff) 

Methods

TextSpanner.attach(indicator, leaf)

Attaches indicator to leaf in spanner.

Returns none.

Special methods

(Spanner).__contains__(argument)

Is true when spanner contains argument. Otherwise false.

Returns true or false.

(Spanner).__copy__(*arguments)

Copies spanner.

Does not copy spanner components.

Returns new spanner.

(AbjadObject).__eq__(argument)

Is true when ID of argument equals ID of Abjad object. Otherwise false.

Returns true or false.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to ‘’ or ‘storage’. Interprets ‘’ equal to ‘storage’.

Returns string.

(Spanner).__getitem__(argument)

Gets item or slice identified by argument.

Returns component.

(AbjadObject).__hash__()

Hashes Abjad object.

Required to be explicitly redefined on Python 3 if __eq__ changes.

Returns integer.

(Spanner).__len__()

Gets number of components in spanner.

Returns nonnegative integer.

(Spanner).__lt__(argument)

Is true when spanner is less than argument. Otherwise false.

Trivial comparison to allow doctests to work.

Returns true or false.

(AbjadObject).__ne__(argument)

Is true when Abjad object does not equal argument. Otherwise false.

Returns true or false.

(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.