Skip to content

Bluejade/prawn-oval-text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prawn Oval Text

Provides capacity for drawing ellipse and circle shaped text.

Usage

Install the prawn_oval_text gem, then:

require 'prawn_oval_text'

And:

text_oval(string, options)

Or:

formatted_text_oval(formatted_text_array, options)

Where acceptable options are:

  • :width and :height are the width and height of the ellipse, respectively. If they are equal, then the shape is a circle.

  • :at is a two element array denoting the upper left corner of the bounding box around the ellipse.

  • :center is a two element array denoting the center of the ellipse. If :center is present, then its value overrides that provided by :at.

  • :overflow is :truncate or :shrink_to_fit, and denotes the behavior when the amount of text exceeds the available space. Defaults to :truncate. If :shrink_to_fit, then the font size is decreased

  • :crop denotes the space between top of the oval and the first line. It is used to push the starting line lower in the circle when the combination of oval size and font size result in only a few characters being displayable on the very top line.

  • :leading is the amount of space between lines. Defaults to 0.

  • :kerning is a boolean. Defaults to true. Note that if kerning is on, it will result in slower width computations

  • :align is :center, :left, :right, or :justify. Defaults to :center.

  • :min_font_size is the minimum font-size to use when :overflow is set to :shrink_to_fit (ie: the font size will not be reduced to less than this value, even if it means that some text will be cut off). Defaults to 5

  • see Prawn::Text::Formatted#formatted_text_box developer documentation for details on the formatted text array structure

Example

github.com/downloads/Bluejade/prawn-oval-text/text_oval.pdf

Changelog

0.3 - added shrink_to_fit overflow option. fixed so can work with new lines in the text

0.3.2 - changed default kerning to true to match Prawn default

0.4.0 - rewrote as descendent of newly rewritten Prawn::Text::Box. notice change of oval_text method to text_oval

0.10.0 - updated to reflect changes in Prawn::Text developer API

0.10.2 - added :justify as align option

2011-02-14 - incorporated Bundler. I must have been linked to master when I produced this (now avoided by use of Bundler) because this was failing at Prawn 0.10.2 because @character_spacing was not set by Text::Box. updated license to MIT license

2011-04-05 - updated for Prawn 0.11.1. added support for formatted text via Prawn::Text::Formatted::Oval and formatted_text_oval. added gemspec and published as prawn_oval_text

About

Prawn extension for generating ellipse and circle shaped text

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages