| Class | Prawn::Format::TextObject |
| In: |
lib/prawn/format/text_object.rb
lib/prawn/format/text_object.rb |
| Parent: | Object |
| 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 |
# File lib/prawn/format/text_object.rb, line 21
21: def initialize
22: @content = nil
23: @last_x = @last_y = 0
24: end
# File lib/prawn/format/text_object.rb, line 21
21: def initialize
22: @content = nil
23: @last_x = @last_y = 0
24: end
# File lib/prawn/format/text_object.rb, line 102
102: def add_content(string)
103: @content << string << "\n"
104: end
# File lib/prawn/format/text_object.rb, line 102
102: def add_content(string)
103: @content << string << "\n"
104: end
# File lib/prawn/format/text_object.rb, line 56
56: def character_space(dc)
57: @content << "#{dc} Tc\n"
58: self
59: end
# File lib/prawn/format/text_object.rb, line 56
56: def character_space(dc)
57: @content << "#{dc} Tc\n"
58: self
59: end
# File lib/prawn/format/text_object.rb, line 71
71: def font(identifier, size)
72: @content << "/#{identifier} #{size} Tf\n"
73: self
74: end
# File lib/prawn/format/text_object.rb, line 71
71: def font(identifier, size)
72: @content << "/#{identifier} #{size} Tf\n"
73: self
74: end
# File lib/prawn/format/text_object.rb, line 66
66: def leading(dl)
67: @content << "#{dl} TL\n"
68: self
69: end
# File lib/prawn/format/text_object.rb, line 66
66: def leading(dl)
67: @content << "#{dl} TL\n"
68: self
69: end
# 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
# 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
# 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
# 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
# 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
# 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
# File lib/prawn/format/text_object.rb, line 82
82: def rise(value)
83: @content << "#{value} Ts\n"
84: self
85: end
# File lib/prawn/format/text_object.rb, line 82
82: def rise(value)
83: @content << "#{value} Ts\n"
84: self
85: end
# 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
# 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
# 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
# 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
# File lib/prawn/format/text_object.rb, line 61
61: def word_space(dw)
62: @content << "#{dw} Tw\n"
63: self
64: end