TextSpanner

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.spanners" { graph [label="abjad.spanners"]; node [color=1]; "abjad.spanners.Spanner.Spanner" [URL="../api/abjad/spanners/Spanner.html#abjad.spanners.Spanner.Spanner", label=Spanner, target=_top]; "abjad.spanners.TextSpanner.TextSpanner" [URL="../api/abjad/spanners/TextSpanner.html#abjad.spanners.TextSpanner.TextSpanner", color=black, fontcolor=white, label="Text\nSpanner", target=_top]; "abjad.spanners.Spanner.Spanner" -> "abjad.spanners.TextSpanner.TextSpanner"; } subgraph "cluster_abjad.system" { graph [label="abjad.system"]; node [color=2]; "abjad.system.AbjadObject.AbjadObject" [URL="../api/abjad/spanners/../system/AbjadObject.html#abjad.system.AbjadObject.AbjadObject", label="Abjad\nObject", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=3]; "builtins.object" [URL="https://docs.python.org/3.6/library/functions.html#object", label=object, target=_top]; } "abjad.system.AbjadObject.AbjadObject" -> "abjad.spanners.Spanner.Spanner"; "builtins.object" -> "abjad.system.AbjadObject.AbjadObject"; }


Classes

TextSpanner Text spanner.
class abjad.spanners.TextSpanner.TextSpanner

Text spanner.

Note

abjad.TextSpanner spanner is deprecated. Use the abjad.text_spanner() factory function instead.

>>> staff = abjad.Staff("c'4 d'4 e'4 f'4")
>>> spanner = abjad.TextSpanner()
>>> abjad.attach(spanner, staff[:])
>>> abjad.override(staff).text_spanner.staff_padding = 2.5
>>> abjad.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/josiah/Source/github.com/Abjad/abjad/abjad/top/attach.py", line 243, in attach
    raise Exception(message)
Exception: TextSpanner()._attachment_test_all():
  Requires at least two leaves.
  Not just Note("c'4").

Raises exception on noncontiguous leaves:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> spanner = abjad.TextSpanner()
>>> abjad.attach(spanner, staff[:1] + staff[-1:])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/josiah/Source/github.com/Abjad/abjad/abjad/top/attach.py", line 254, in attach
    tag=tag,
  File "/Users/josiah/Source/github.com/Abjad/abjad/abjad/spanners/Spanner.py", line 176, in _attach
    self._extend(argument)
  File "/Users/josiah/Source/github.com/Abjad/abjad/abjad/spanners/Spanner.py", line 241, in _extend
    raise Exception(message)
Exception: TextSpanner() leaves must be contiguous:
  abjad.Selection(
    [
        abjad.Note("c'4"),
        abjad.Note("f'4"),
        ]
    )

Special methods

(Spanner).__contains__(argument)

Is true when spanner contains argument.

Return type:bool
(Spanner).__copy__(*arguments)

Copies spanner.

Does not copy spanner leaves.

(AbjadObject).__format__(format_specification='')

Formats Abjad object.

Set format_specification to '' or 'storage'. Interprets '' equal to 'storage'.

Returns string.

(Spanner).__getitem__(argument)

Gets leaf or selection identified by argument.

Return type:Union[Leaf, Selection]
(Spanner).__iter__()

Iterates leaves in spanner.

Return type:Iterator[+T_co]
(Spanner).__len__()

Gets number of leaves in spanner.

Return type:int
(Spanner).__lt__(argument)

Is true when spanner is less than argument.

Trivial comparison to allow doctests to work.

Return type:bool
(AbjadObject).__repr__()

Gets interpreter representation of Abjad object.

Returns string.


Read-only properties

(Spanner).leaves

Gets leaves in spanner.

Return type:Selection
(Spanner).tweaks

Gets tweaks.

Return type:Optional[LilyPondTweakManager]

Functions

text_spanner Attaches text span indicators.
abjad.spanners.TextSpanner.text_spanner(argument, *, selector='abjad.select().leaves()', start_text_span=None, stop_text_span=None)

Attaches text span indicators.

Single spanner:

>>> staff = abjad.Staff("c'4 d' e' f'")
>>> start_text_span = abjad.StartTextSpan(
...     left_text=abjad.Markup('pont.').upright(),
...     right_text=abjad.Markup('tasto').upright(),
...     style='solid_line_with_arrow',
...     )
>>> abjad.text_spanner(staff[:], start_text_span=start_text_span)
>>> abjad.override(staff[0]).text_spanner.staff_padding = 4
>>> abjad.show(staff) 

Enchained spanners:

>>> staff = abjad.Staff("c'4 d' e' f' r")
>>> start_text_span = abjad.StartTextSpan(
...     left_text=abjad.Markup('pont.').upright(),
...     style='dashed_line_with_arrow',
...     )
>>> abjad.text_spanner(staff[:3], start_text_span=start_text_span)
>>> start_text_span = abjad.StartTextSpan(
...     left_text=abjad.Markup('tasto').upright(),
...     right_text=abjad.Markup('pont.').upright(),
...     style='dashed_line_with_arrow',
...     )
>>> abjad.text_spanner(staff[-3:], start_text_span=start_text_span)
>>> abjad.override(staff).text_spanner.staff_padding = 4
>>> abjad.show(staff) 
>>> staff = abjad.Staff("c'4 d' e' f' r")
>>> start_text_span = abjad.StartTextSpan(
...     left_text=abjad.Markup('pont.').upright(),
...     style='dashed_line_with_arrow',
...     )
>>> abjad.text_spanner(staff[:3], start_text_span=start_text_span)
>>> start_text_span = abjad.StartTextSpan(
...     left_text=abjad.Markup('tasto').upright(),
...     style='solid_line_with_hook',
...     )
>>> abjad.text_spanner(staff[-3:], start_text_span=start_text_span)
>>> abjad.override(staff).text_spanner.staff_padding = 4
>>> abjad.show(staff) 
Return type:None