### Home Classes Methods

### In Files

- lib/prawn/text/formatted/parser.rb
- lib/prawn/text/formatted/box.rb
- lib/prawn/text/formatted/fragment.rb

### Namespace

- CLASS Prawn::Text::Formatted::Box
- CLASS Prawn::Text::Formatted::Fragment
- CLASS Prawn::Text::Formatted::Parser

### Methods

- #formatted_text_box

### Files

- COPYING
- GPLv2
- GPLv3
- LICENSE

### Class/Module Index

Quicksearch

- Prawn
- Prawn::Core
- Prawn::Core::Page
- Prawn::Core::Page::GraphicsState
- Prawn::Core::Reference
- Prawn::Document
- Prawn::Document::BoundingBox
- Prawn::Document::ColumnBox
- Prawn::Document::GraphicsState
- Prawn::Document::Grid
- Prawn::Document::Internals
- Prawn::Document::PageGeometry
- Prawn::Document::Security
- Prawn::Document::Snapshot
- Prawn::Encoding
- Prawn::Errors
- Prawn::Font
- Prawn::Font::AFM
- Prawn::Font::DFont
- Prawn::Font::TTF
- Prawn::GraphicState
- Prawn::GraphicStateStack
- Prawn::Graphics
- Prawn::Graphics::CapStyle
- Prawn::Graphics::Color
- Prawn::Graphics::Dash
- Prawn::Graphics::Gradient
- Prawn::Graphics::JoinStyle
- Prawn::Graphics::Transformation
- Prawn::Graphics::Transparency
- Prawn::Images
- Prawn::Images::JPG
- Prawn::Images::PNG
- Prawn::Layout
- Prawn::Measurements
- Prawn::Outline
- Prawn::Stamp
- Prawn::Table
- Prawn::Table::Cell
- Prawn::Table::Cell::InTable
- Prawn::Table::Cell::Subtable
- Prawn::Table::Cell::Text
- Prawn::Table::Cells
- Prawn::Text
- Prawn::Text::Box
- Prawn::Text::Formatted
- Prawn::Text::Formatted::Box
- Prawn::Text::Formatted::Fragment
- Prawn::Text::Formatted::Parser
- Arcfour
- Numeric

No matching classes.

# Prawn::Text::Formatted

### Public Instance Methods

formatted_text_box(array, options={}) click to toggle source

Draws the requested formatted text into a box. When the text overflows the rectangle shrink to fit or truncate the text. Text boxes are independent of the document y position.

## Formatted Text Array

Formatted text is comprised of an array of hashes, where each hash defines text and format information. As of the time of writing, the following hash options are supported:

`:text` | the text to format according to the other hash options
`:styles` | an array of styles to apply to this text. Available styles include :bold, :italic, :underline, :strikethrough, :subscript, and :superscript
`:size` | a number denoting the font size to apply to this text
`:character_spacing` | a number denoting how much to increase or decrease the default spacing between characters
`:font` | the name of a font. The name must be an AFM font with the desired faces or must be a font that is already registered using Prawn::Document#font_families
`:color` | anything compatible with Prawn::Graphics::Color#fill_color and Prawn::Graphics::Color#stroke_color
`:link` | a URL to which to create a link. A clickable link will be created to that URL. Note that you must explicitly underline and color using the appropriate tags if you which to draw attention to the link
`:anchor` | a destination that has already been or will be registered using Prawn::Core::Destinations#add_dest. A clickable link will be created to that destination. Note that you must explicitly underline and color using the appropriate tags if you which to draw attention to the link
`:callback` | an object (or array of such objects) with two methods: render_behind and render_in_front, which are called immediately prior to and immediately after rendring the text fragment and which are passed the fragment as an argument

## Example

    formatted_text_box([{ :text => "hello" },
                        { :text => "world",
                          :size => 24,
                          :styles => [:bold, :italic] }])

## Options

Accepts the same options as Text::Box with the below exceptions

## Returns

Returns a formatted text array representing any text that did not print under the current settings.

## Exceptions

Raises "Bad font family" if no font family is defined for the current font

Raises `Prawn::Errrors::CannotFit` if not wide enough to print any text

    # File lib/prawn/text/formatted/box.rb, line 80
    def formatted_text_box(array, options={})
      Text::Formatted::Box.new(array, options.merge(:document => self)).render
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.