Prawn Oval Text

Provides capacity for drawing ellipse and circle shaped text.

Usage

require 'prawn/text/oval'

then

text_oval(string, 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, :shrink_to_fit, or :ellipses, denoting 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, or :right. 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

Example

mindlev.wordpress.com/files/2009/10/oval_text.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