Next: , Previous: , Up: Core object functions   [Contents][Index]


2.2.10 Text

Text fulfils two roles, as straightforward labels and notes on schematics and symbols, and as attached or floating attributes (see Attributes). A text object can be aligned in different ways relative to its anchor position, and can be displayed in different font sizes.

Any text can be set to be visible or invisible on printed output (and lepton-schematic provides ways to preview invisible text). When a text object is an attribute (i.e. its string is in a ‘name=value’ format) then the visibility settings are more fine-grained: the text can be set to display just the attribute name, just the attribute value, or both.

See Attributes.

Function: text? object

Returns ‘#t’ if and only if object is a text object.

Function: make-text anchor align angle string size visible show [color]

Creates and returns a new text object. anchor is the position of the anchor of the new text in the form (x . y), and align is a symbol determining how the text should be aligned relative to the anchor. align must be one of the following symbols:

  • lower-left
  • middle-left
  • upper-left
  • lower-center
  • middle-center
  • upper-center
  • lower-right
  • middle-right
  • upper-right

For example, if align is ‘upper-center’, the anchor will be located at the top center of the rendered text block.

angle should be an integer multiple of 90 degrees, determining the angle which the text should be displayed at. string is the string contents for the text object, and must not contain any null characters (‘#\0’ in Scheme, Unicode ‘U+0000’). size is the font size to use. If visible is ‘#f’, the text will be invisible; otherwise, it will be visible.

When the string is in an attribute format (see Attributes), the show argument determines which parts of the string will be displayed. It must be one of the following symbols:

  • name
  • value
  • both

If color is specified, it should be the integer color map index of the color with which to draw the text. If color is not specified, the default text color is used.

Function: set-text! text anchor align angle string size visible show [color]

Sets the parameters of text. The arguments are the same as to make-text. Returns text.

Function: text-info text

Returns the parameters of text as a list in the form:

((anchor-x . anchor-y) align angle string size visible show color)

See make-text for a description of all of these parameters.

Function: text-anchor text

Returns the position of the anchor of text in the form (x . y).

Function: text-align text

Returns the alignment of text as one of the following symbols:

  • lower-left
  • middle-left
  • upper-left
  • lower-center
  • middle-center
  • upper-center
  • lower-right
  • middle-right
  • upper-right
Function: text-angle text

Returns the angle that text is displayed at as an integer multiple of 90 degrees.

Function: text-string text

Returns the string content of text.

Function: set-text-string! text str

Set the string content of text to str. str must not contain any null characters (‘#\0’ in Scheme, Unicode ‘U+0000’).

Function: text-size text

Return the font size of text as an integer.

Function: text-visible? text

Returns ‘#t’ if and only if text is set to be visible.

Function: set-text-visibility! text visible?

If visible? is ‘#f’, sets text to be invisible; otherwise, sets it to be visible.

Function: text-attribute-mode text

Returns a symbol indicating which parts of text will be displayed when text is a valid attribute. The returned value will be one of the following symbols:

  • name
  • value
  • both

Next: Components, Previous: Pictures, Up: Core object functions   [Contents][Index]