123456789_123456789_123456789_123456789_123456789_

Class: Layout::FormattedText

Relationships
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Entity
Instance Chain:
self, Entity
Inherits: Layout::Entity

Overview

A formatted text entity.

Version:

  • LayOut 2018

Constant Summary

Class Method Summary

Instance Attribute Summary

Entity - Inherited

#locked=

The #locked= method sets the Entity as locked or unlocked.

#locked?

The #locked? method returns whether the Entity is locked or unlocked.

#on_shared_layer?

The #on_shared_layer? method returns whether or not the Entity is on a shared Layer.

#style

The #style method returns the Style of the Entity.

#style=

The #style= method sets the Style of the Entity.

#untransformed_bounds

The #untransformed_bounds method returns the untransformed bounds of the Entity.

#untransformed_bounds=

The #untransformed_bounds= method sets the untransformed bounds of the Entity.

Instance Method Summary

Entity - Inherited

#==

The #== method checks to see if the two Entitys are equal.

#bounds

The #bounds method returns the 2D rectangular bounds of the Entity.

#document

The #document method returns the Document that the Entity belongs to, or nil if it is not in a Document.

#drawing_bounds

The #drawing_bounds method returns the 2D rectangular drawing bounds of the Entity.

#group

The #group method returns the Group the Entity belongs to, or nil if it is not in a Group.

#layer_instance

The #layer_instance method returns the LayerInstance that the Entity is on, or nil if it is not associated with a LayerInstance.

#move_to_group

The #move_to_group method moves the Entity into a Group.

#move_to_layer

The #move_to_layer method moves the Entity to the given Layer.

#page

The #page method returns the Page that the Entity belongs to, or nil if it is on a shared Layer or not in a Document.

#transform!

The #transform! method transforms the Entity with a given ::Geom::Transformation2d.

#transformation

The #transformation method returns the explicit ::Geom::Transformation2d.

Constructor Details

.new(text, bounds) ⇒ FormattedText .new(text, anchor_point, anchor_type) ⇒ FormattedText

The #initialize method creates a new FormattedText.

The anchor type can be one of the following values:

ANCHOR_TYPE_TOP_LEFT
ANCHOR_TYPE_CENTER_LEFT
ANCHOR_TYPE_BOTTOM_LEFT
ANCHOR_TYPE_TOP_RIGHT
ANCHOR_TYPE_CENTER_RIGHT
ANCHOR_TYPE_BOTTOM_RIGHT
ANCHOR_TYPE_TOP_CENTER
ANCHOR_TYPE_CENTER_CENTER
ANCHOR_TYPE_BOTTOM_CENTER

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Test", anchor, Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)

Overloads:

  • .new(text, bounds) ⇒ FormattedText

    Parameters:

  • .new(text, anchor_point, anchor_type) ⇒ FormattedText

    Parameters:

    • text (String)
    • anchor_point (Geom::Point2d)

      The anchor point for the FormattedText‘s position.

    • anchor_type (Integer)

      Defines which point of the FormattedText is set by anchor_point.

Raises:

  • (ArgumentError)

    if the passed in string is empty

  • (ArgumentError)

    if bounds is zero size

Version:

  • LayOut 2018

Class Method Details

.new_from_file(path, bounds) ⇒ FormattedText .new_from_file(path, anchor_point, anchor_type) ⇒ FormattedText

The .new_from_file method creates a new FormattedText from a text file.

The anchor type can be one of the following values:

ANCHOR_TYPE_TOP_LEFT
ANCHOR_TYPE_CENTER_LEFT
ANCHOR_TYPE_BOTTOM_LEFT
ANCHOR_TYPE_TOP_RIGHT
ANCHOR_TYPE_CENTER_RIGHT
ANCHOR_TYPE_BOTTOM_RIGHT
ANCHOR_TYPE_TOP_CENTER
ANCHOR_TYPE_CENTER_CENTER
ANCHOR_TYPE_BOTTOM_CENTER

Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("C:/Test.txt", anchor,

Overloads:

  • .new_from_file(path, bounds) ⇒ FormattedText

    Parameters:

  • .new_from_file(path, anchor_point, anchor_type) ⇒ FormattedText

    Parameters:

    • path (String)
    • anchor_point (Geom::Point2d)

      The anchor point for the FormattedText‘s position.

    • anchor_type (Integer)

      Defines which point of the FormattedText is set by anchor_point.

Raises:

  • (ArgumentError)

    if the passed in string is empty

  • (ArgumentError)

    if bounds is zero size

  • (ArgumentError)

    if path does not refer to a valid file

Version:

  • LayOut 2018

Instance Attribute Details

#grow_modeInteger (rw)

The #grow_mode method returns the mode for how the FormattedText sizes itself.

The grow mode can be one of the following values:

Layout::FormattedText::GROW_MODE_BOUNDED
Layout::FormattedText::GROW_MODE_UNBOUNDED

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Test", anchor, Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)
mode = text.grow_mode

Returns:

  • (Integer)

    grow_mode

Version:

  • LayOut 2018

#grow_mode=(grow_mode) ⇒ Integer (rw)

The #grow_mode= method sets the mode for how the FormattedText sizes itself.

The grow mode can be one of the following values:

Layout::FormattedText::GROW_MODE_BOUNDED
Layout::FormattedText::GROW_MODE_UNBOUNDED

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Test", anchor, Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)
text.grow_mode = GROW_MODE_UNBOUNDED

Returns:

  • (Integer)

    grow_mode

Raises:

Version:

  • LayOut 2018

#plain_textString (rw)

The #plain_text method returns the plain text representation of the FormattedText.

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Test", anchor, Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)
text = text.plain_text

Version:

  • LayOut 2018

#plain_text=(plain_text) (rw)

The #plain_text= method sets the plain text representation of the FormattedText.

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Test", anchor, Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)
text.plain_text = "foo"

Parameters:

Raises:

Version:

  • LayOut 2018

Instance Method Details

#append_plain_text(plain_text, style)

Note:

This method does not support more than two different style runs in a single text string.

The #append_plain_text method appends new text with a given style to the end of the existing plain text of the FormattedText.

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Test", anchor, Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)
style = text.style(0)
text.append_plain_text("foo", style)

Parameters:

Raises:

Version:

  • LayOut 2018

#apply_style(style, index = 0, length = length_to_end_of_text)

The #apply_style method sets the Style for the text starting at the given character index, and running for the given number of characters.

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Test", anchor, Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)
style = text.style(0)
style.text_bold = true
text.apply_style(style, 2, 4)

Parameters:

  • style (Layout::Style)
  • index (Integer) (defaults to: 0)
  • length (Integer) (defaults to: length_to_end_of_text)

Raises:

  • (IndexError)

    if index is out of range

  • (ArgumentError)

    if length is not greater than zero

  • (RangeError)

    if the range specified by index and length is not valid for this FormattedText

  • (LockedLayerError)

    if the FormattedText is on a locked Layer

  • (LockedEntityError)

    if the FormattedText is locked

Version:

  • LayOut 2018

#display_text(page = nil) ⇒ String

Note:

Passing an invalid Page will prevent an auto-text tag from being substituted with its display representation.

The #display_text method returns the display text representation of the FormattedText.

Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT) doc.add_entity(text, doc.layers.first, doc.pages.first) text = text.display_text(doc.pages.first)

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("<PageNumber>", anchor,

Parameters:

  • page (Layout::Page) (defaults to: nil)

    The Page to use to convert an auto-text tag to display text

Raises:

  • (ArgumentError)

    if page is not in the same Document as the FormattedText

Version:

  • LayOut 2018

#rtfString #rtf(page) ⇒ String

Note:

Passing an invalid Page will prevent an auto-text tag from being substituted with its display representation.

The #rtf method returns the raw RTF representation of the FormattedText.

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Test", anchor, Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)
rtf_text = text.rtf

Overloads:

  • #rtfString

    Returns:

    • (String)

      The RTF text string. If the FormattedText is auto-text, this will be an auto-text tag.

  • #rtf(page) ⇒ String

    Parameters:

    • page (Layout::Page)

      The Page to use to convert an auto text tag to display text

    Returns:

    • (String)

      The RTF text string. If the FormattedText is auto-text, this will be the display text.

Raises:

  • (ArgumentError)

    if page is not in the same Document as the FormattedText

Version:

  • LayOut 2018

#rtf=(rtf_text)

The #rtf= method sets the raw RTF representation of the FormattedText.

text.par}“

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Test", anchor, Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)
text.rtf = "{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard This is some {\b bold}

Parameters:

Raises:

Version:

  • LayOut 2018

#style(index = 0, length = 1) ⇒ Layout::Style

The #style method returns a Style for the text starting at the given character index, and running for the given length.

Examples:

anchor = Geom::Point2d.new(1, 1)
text = Layout::FormattedText.new("Test", anchor, Layout::FormattedText::ANCHOR_TYPE_TOP_LEFT)
style = text.style(0)

Parameters:

  • index (Integer) (defaults to: 0)
  • length (Integer) (defaults to: 1)

Raises:

  • (IndexError)

    if index is out of range

  • (ArgumentError)

    if length is not greater than zero

  • (RangeError)

    if the range specified by index and length is not valid for this FormattedText

Version:

  • LayOut 2018