Class: Krill::TextBox
- Inherits:
-
Object
- Object
- Krill::TextBox
- Defined in:
- lib/krill/text_box.rb
Instance Attribute Summary collapse
-
#ascender ⇒ Object
readonly
The height of the ascender of the last line printed.
-
#at ⇒ Object
readonly
The upper left corner of the text box.
-
#descender ⇒ Object
readonly
The height of the descender of the last line printed.
-
#leading ⇒ Object
readonly
The leading used during printing.
-
#line_height ⇒ Object
readonly
The line height of the last line printed.
-
#printed_lines ⇒ Object
readonly
Returns the value of attribute printed_lines.
-
#text ⇒ Object
readonly
The text that was successfully printed (or, if
dry_runwas used, the text that would have been successfully printed).
Instance Method Summary collapse
-
#everything_printed? ⇒ Boolean
True if everything printed (or, if
dry_runwas used, everything would have been successfully printed). -
#height ⇒ Object
The height actually used during the previous
render. -
#initialize(formatted_text, options = {}) ⇒ TextBox
constructor
A new instance of TextBox.
- #line_gap ⇒ Object
-
#nothing_printed? ⇒ Boolean
True if nothing printed (or, if
dry_runwas used, nothing would have been successfully printed). - #render ⇒ Object
Constructor Details
#initialize(formatted_text, options = {}) ⇒ TextBox
Returns a new instance of TextBox.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/krill/text_box.rb', line 9 def initialize(formatted_text, ={}) @original_array = formatted_text @text = nil @at = [0, 720.0] # was [ @document.bounds.left, @document.bounds.top ] @width = .fetch(:width) @height = .fetch(:height, @at[1]) @direction = .fetch(:direction, :ltr) @align = .fetch(:align, @direction == :rtl ? :right : :left) @leading = .fetch(:leading, 0) @kerning = .fetch(:kerning, true) @disable_wrap_by_char = [:disable_wrap_by_char] @line_wrap = Krill::LineWrap.new @arranger = Krill::Arranger.new(kerning: @kerning) end |
Instance Attribute Details
#ascender ⇒ Object (readonly)
The height of the ascender of the last line printed
51 52 53 |
# File 'lib/krill/text_box.rb', line 51 def ascender @ascender end |
#at ⇒ Object (readonly)
The upper left corner of the text box
45 46 47 |
# File 'lib/krill/text_box.rb', line 45 def at @at end |
#descender ⇒ Object (readonly)
The height of the descender of the last line printed
54 55 56 |
# File 'lib/krill/text_box.rb', line 54 def descender @descender end |
#leading ⇒ Object (readonly)
The leading used during printing
57 58 59 |
# File 'lib/krill/text_box.rb', line 57 def leading @leading end |
#line_height ⇒ Object (readonly)
The line height of the last line printed
48 49 50 |
# File 'lib/krill/text_box.rb', line 48 def line_height @line_height end |
#printed_lines ⇒ Object (readonly)
Returns the value of attribute printed_lines.
7 8 9 |
# File 'lib/krill/text_box.rb', line 7 def printed_lines @printed_lines end |
#text ⇒ Object (readonly)
The text that was successfully printed (or, if dry_run was used, the text that would have been successfully printed)
30 31 32 |
# File 'lib/krill/text_box.rb', line 30 def text @text end |
Instance Method Details
#everything_printed? ⇒ Boolean
True if everything printed (or, if dry_run was used, everything would have been successfully printed)
40 41 42 |
# File 'lib/krill/text_box.rb', line 40 def everything_printed? @everything_printed end |
#height ⇒ Object
The height actually used during the previous render
64 65 66 67 |
# File 'lib/krill/text_box.rb', line 64 def height return 0 if @baseline_y.nil? || @descender.nil? (@baseline_y - @descender).abs end |
#line_gap ⇒ Object
59 60 61 |
# File 'lib/krill/text_box.rb', line 59 def line_gap line_height - (ascender + descender) end |
#nothing_printed? ⇒ Boolean
True if nothing printed (or, if dry_run was used, nothing would have been successfully printed)
34 35 36 |
# File 'lib/krill/text_box.rb', line 34 def nothing_printed? @nothing_printed end |
#render ⇒ Object
24 25 26 |
# File 'lib/krill/text_box.rb', line 24 def render wrap(normalize_encoding(original_text)) end |