lib/prawn/text/formatted/box.rb in prawn-1.3.0 vs lib/prawn/text/formatted/box.rb in prawn-2.0.0
- old
+ new
@@ -83,11 +83,11 @@
#
# == Exceptions
#
# Raises "Bad font family" if no font family is defined for the current font
#
- # Raises <tt>Prawn::Errrors::CannotFit</tt> if not wide enough to print
+ # Raises <tt>Prawn::Errors::CannotFit</tt> if not wide enough to print
# any text
#
def formatted_text_box(array, options={})
Text::Formatted::Box.new(array, options.merge(:document => self)).render
end
@@ -166,11 +166,10 @@
@document.character_spacing
@mode = options[:mode] || @document.text_rendering_mode
@rotate = options[:rotate] || 0
@rotate_around = options[:rotate_around] || :upper_left
@single_line = options[:single_line]
- @skip_encoding = options[:skip_encoding] || @document.skip_encoding
@draw_text_callback = options[:draw_text_callback]
# if the text rendering mode is :unknown, force it back to :fill
if @mode == :unknown
@mode = :fill
@@ -227,11 +226,13 @@
end
end
end
end
- unprinted_text
+ unprinted_text.map do |e|
+ e.merge(:text => @document.font.to_utf8(e[:text]))
+ end
end
# The width available at this point in the box
#
def available_width
@@ -333,25 +334,20 @@
:rotate, :rotate_around,
:overflow, :min_font_size,
:disable_wrap_by_char,
:leading, :character_spacing,
:mode, :single_line,
- :skip_encoding,
:document,
:direction,
:fallback_fonts,
:draw_text_callback]
end
private
def normalized_text(flags)
- if @skip_encoding
- text = original_text
- else
- text = normalize_encoding
- end
+ text = normalize_encoding
text.each { |t| t.delete(:color) } if flags[:dry_run]
text
end
@@ -482,17 +478,19 @@
# only run once.
return if defined?(@vertical_alignment_processed) && @vertical_alignment_processed
@vertical_alignment_processed = true
return if @vertical_align == :top
+
wrap(text)
case @vertical_align
when :center
- @at[1] = @at[1] - (@height - height) * 0.5
+ @at[1] -= (@height - height + @descender) * 0.5
when :bottom
- @at[1] = @at[1] - (@height - height) + @descender
+ @at[1] -= (@height - height)
end
+
@height = height
end
# Decrease the font size until the text fits or the min font
# size is reached