Class Prawn::Format::TextObject
In: lib/prawn/format/text_object.rb
lib/prawn/format/text_object.rb
Parent: Object

Methods

add_content   add_content   character_space   character_space   close   close   font   font   leading   leading   move_by   move_by   move_to   move_to   new   new   next_line   next_line   open   open   render   render   rise   rise   rotate   rotate   show   show   to_s   to_s   to_str   to_str   word_space   word_space  

Included Modules

Prawn::Graphics::Color Prawn::Graphics::Color

Constants

RENDER_MODES = { :fill => 0, :stroke => 1, :fill_stroke => 2, :invisible => 3, :fill_clip => 4, :stroke_clip => 5, :fill_stroke_clip => 6, :clip => 7
RENDER_MODES = { :fill => 0, :stroke => 1, :fill_stroke => 2, :invisible => 3, :fill_clip => 4, :stroke_clip => 5, :fill_stroke_clip => 6, :clip => 7

Public Class methods

[Source]

    # File lib/prawn/format/text_object.rb, line 21
21:       def initialize
22:         @content = nil
23:         @last_x = @last_y = 0
24:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 21
21:       def initialize
22:         @content = nil
23:         @last_x = @last_y = 0
24:       end

Public Instance methods

[Source]

     # File lib/prawn/format/text_object.rb, line 102
102:       def add_content(string)
103:         @content << string << "\n"
104:       end

[Source]

     # File lib/prawn/format/text_object.rb, line 102
102:       def add_content(string)
103:         @content << string << "\n"
104:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 56
56:       def character_space(dc)
57:         @content << "#{dc} Tc\n"
58:         self
59:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 56
56:       def character_space(dc)
57:         @content << "#{dc} Tc\n"
58:         self
59:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 31
31:       def close
32:         @content << "ET"
33:         self
34:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 31
31:       def close
32:         @content << "ET"
33:         self
34:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 71
71:       def font(identifier, size)
72:         @content << "/#{identifier} #{size} Tf\n"
73:         self
74:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 71
71:       def font(identifier, size)
72:         @content << "/#{identifier} #{size} Tf\n"
73:         self
74:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 66
66:       def leading(dl)
67:         @content << "#{dl} TL\n"
68:         self
69:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 66
66:       def leading(dl)
67:         @content << "#{dl} TL\n"
68:         self
69:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 40
40:       def move_by(dx,dy)
41:         @last_x += dx
42:         @last_y += dy
43:         @content << "#{dx} #{dy} Td\n"
44:         self
45:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 40
40:       def move_by(dx,dy)
41:         @last_x += dx
42:         @last_y += dy
43:         @content << "#{dx} #{dy} Td\n"
44:         self
45:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 36
36:       def move_to(x, y)
37:         move_by(x - @last_x, y - @last_y)
38:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 36
36:       def move_to(x, y)
37:         move_by(x - @last_x, y - @last_y)
38:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 47
47:       def next_line(dy)
48:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 47
47:       def next_line(dy)
48:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 26
26:       def open
27:         @content = "BT\n"
28:         self
29:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 26
26:       def open
27:         @content = "BT\n"
28:         self
29:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 76
76:       def render(mode)
77:         mode_value = RENDER_MODES[mode] || raise(ArgumentError, "unsupported render mode #{mode.inspect}, should be one of #{RENDER_MODES.keys.inspect}")
78:         @content << "#{mode_value} Tr\n"
79:         self
80:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 76
76:       def render(mode)
77:         mode_value = RENDER_MODES[mode] || raise(ArgumentError, "unsupported render mode #{mode.inspect}, should be one of #{RENDER_MODES.keys.inspect}")
78:         @content << "#{mode_value} Tr\n"
79:         self
80:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 82
82:       def rise(value)
83:         @content << "#{value} Ts\n"
84:         self
85:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 82
82:       def rise(value)
83:         @content << "#{value} Ts\n"
84:         self
85:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 87
87:       def rotate(x, y, theta)
88:         radians = theta * Math::PI / 180
89:         cos, sin = Math.cos(radians), Math.sin(radians)
90:         arr = [cos, sin, -sin, cos, x, y]
91:         add_content "%.3f %.3f %.3f %.3f %.3f %.3f Tm" % arr
92:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 87
87:       def rotate(x, y, theta)
88:         radians = theta * Math::PI / 180
89:         cos, sin = Math.cos(radians), Math.sin(radians)
90:         arr = [cos, sin, -sin, cos, x, y]
91:         add_content "%.3f %.3f %.3f %.3f %.3f %.3f Tm" % arr
92:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 50
50:       def show(argument)
51:         instruction = argument.is_a?(Array) ? "TJ" : "Tj"
52:         @content << "#{Prawn::PdfObject(argument, true)} #{instruction}\n"
53:         self
54:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 50
50:       def show(argument)
51:         instruction = argument.is_a?(Array) ? "TJ" : "Tj"
52:         @content << "#{Prawn::PdfObject(argument, true)} #{instruction}\n"
53:         self
54:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 94
94:       def to_s
95:         @content
96:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 94
94:       def to_s
95:         @content
96:       end

[Source]

     # File lib/prawn/format/text_object.rb, line 98
 98:       def to_str
 99:         @content
100:       end

[Source]

     # File lib/prawn/format/text_object.rb, line 98
 98:       def to_str
 99:         @content
100:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 61
61:       def word_space(dw)
62:         @content << "#{dw} Tw\n"
63:         self
64:       end

[Source]

    # File lib/prawn/format/text_object.rb, line 61
61:       def word_space(dw)
62:         @content << "#{dw} Tw\n"
63:         self
64:       end

[Validate]