lib/prawn/text/box.rb in prawn-0.15.0 vs lib/prawn/text/box.rb in prawn-1.0.0.rc1

- old
+ new

@@ -5,31 +5,28 @@ # Copyright November 2009, Daniel Nelson. All Rights Reserved. # # This is free software. Please see the LICENSE and COPYING files for details. # -require_relative "formatted/box" - module Prawn module Text - # @group Stable API # Draws the requested text into a box. When the text overflows # the rectangle, you shrink to fit, or truncate the text. Text # boxes are independent of the document y position. # # == Encoding # # Note that strings passed to this function should be encoded as UTF-8. - # If you get unexpected characters appearing in your rendered document, + # If you get unexpected characters appearing in your rendered document, # check this. # # If the current font is a built-in one, although the string must be # encoded as UTF-8, only characters that are available in WinAnsi # are allowed. # - # If an empty box is rendered to your PDF instead of the character you + # If an empty box is rendered to your PDF instead of the character you # wanted it usually means the current font doesn't include that character. # # == Options (default values marked in []) # # <tt>:kerning</tt>:: <tt>boolean</tt>. Whether or not to use kerning (if it @@ -68,11 +65,11 @@ # <tt>:justify</tt> Alignment within the bounding box # [:left if direction is :ltr, :right if direction is :rtl] # <tt>:valign</tt>:: # <tt>:top</tt>, <tt>:center</tt>, or <tt>:bottom</tt>. Vertical # alignment within the bounding box [:top] - # + # # <tt>:rotate</tt>:: # <tt>number</tt>. The angle to rotate the text # <tt>:rotate_around</tt>:: # <tt>:center</tt>, <tt>:upper_left</tt>, <tt>:upper_right</tt>, # <tt>:lower_right</tt>, or <tt>:lower_left</tt>. The point around which @@ -109,24 +106,21 @@ # def text_box(string, options={}) options = options.dup options[:document] = self - box = if p = options.delete(:inline_format) - p = [] unless p.is_a?(Array) - array = self.text_formatter.format(string, *p) + box = if options.delete(:inline_format) + array = Text::Formatted::Parser.to_array(string) Text::Formatted::Box.new(array, options) else Text::Box.new(string, options) end box.render end - # @group Experimental API - # Generally, one would use the Prawn::Text#text_box convenience - # method. However, using Text::Box.new in conjunction with + # method. However, using Text::Box.new in conjunction with # #render(:dry_run=> true) enables one to do look-ahead calculations prior # to placing text on the page, or to determine how much vertical space was # consumed by the printed text # class Box < Prawn::Text::Formatted::Box