squib 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +29 -29
  3. data/.travis.yml +6 -6
  4. data/.yardopts +7 -5
  5. data/Gemfile +2 -2
  6. data/LICENSE.txt +22 -22
  7. data/README.md +245 -92
  8. data/Rakefile +11 -11
  9. data/bin/squib +18 -18
  10. data/lib/squib.rb +31 -18
  11. data/lib/squib/api/background.rb +18 -16
  12. data/lib/squib/api/data.rb +52 -52
  13. data/lib/squib/api/image.rb +66 -48
  14. data/lib/squib/api/save.rb +43 -37
  15. data/lib/squib/api/settings.rb +38 -35
  16. data/lib/squib/api/shapes.rb +116 -106
  17. data/lib/squib/api/text.rb +50 -45
  18. data/lib/squib/api/units.rb +16 -16
  19. data/lib/squib/card.rb +42 -36
  20. data/lib/squib/commands/new.rb +43 -39
  21. data/lib/squib/constants.rb +104 -39
  22. data/lib/squib/deck.rb +116 -113
  23. data/lib/squib/graphics/background.rb +13 -12
  24. data/lib/squib/graphics/image.rb +47 -28
  25. data/lib/squib/graphics/save_doc.rb +54 -50
  26. data/lib/squib/graphics/save_images.rb +32 -10
  27. data/lib/squib/graphics/shapes.rb +59 -55
  28. data/lib/squib/graphics/text.rb +113 -107
  29. data/lib/squib/input_helpers.rb +193 -139
  30. data/lib/squib/progress.rb +38 -0
  31. data/lib/squib/project_template/.gitignore +4 -3
  32. data/lib/squib/project_template/ABOUT.md +19 -19
  33. data/lib/squib/project_template/Gemfile +2 -2
  34. data/lib/squib/project_template/PNP NOTES.md +3 -3
  35. data/lib/squib/project_template/config.yml +20 -2
  36. data/lib/squib/project_template/deck.rb +5 -5
  37. data/lib/squib/version.rb +6 -6
  38. data/samples/ball.png +0 -0
  39. data/samples/basic.rb +19 -19
  40. data/samples/colors.rb +15 -16
  41. data/samples/custom-config.yml +6 -1
  42. data/samples/custom-layout.yml +39 -34
  43. data/samples/custom_config.rb +18 -5
  44. data/samples/customconfig-imgdir/shiny-purse2.png +0 -0
  45. data/samples/customconfig-imgdir/spanner2.svg +91 -0
  46. data/samples/draw_shapes.rb +18 -18
  47. data/samples/excel.rb +19 -19
  48. data/samples/grit.png +0 -0
  49. data/samples/hello_world.rb +6 -6
  50. data/samples/load_images.rb +29 -19
  51. data/samples/offset.svg +71 -0
  52. data/samples/portrait-landscape.rb +23 -0
  53. data/samples/ranges.rb +55 -47
  54. data/samples/save_pdf.rb +14 -14
  55. data/samples/shiny-purse.png +0 -0
  56. data/samples/spanner.svg +91 -91
  57. data/samples/text_options.rb +60 -58
  58. data/samples/tgc_proofs.rb +19 -19
  59. data/samples/units.rb +12 -12
  60. data/samples/use_layout.rb +28 -28
  61. data/spec/api/api_text_spec.rb +42 -36
  62. data/spec/commands/new_spec.rb +47 -47
  63. data/spec/data/multi-extends-single-entry.yml +13 -0
  64. data/spec/data/multi-level-extends.yml +10 -0
  65. data/spec/data/no-extends.yml +5 -0
  66. data/spec/data/single-extends.yml +7 -0
  67. data/spec/data/single-level-multi-extends.yml +12 -0
  68. data/spec/deck_spec.rb +147 -49
  69. data/spec/input_helpers_spec.rb +117 -0
  70. data/spec/samples_run_spec.rb +19 -14
  71. data/spec/spec_helper.rb +3 -0
  72. data/squib.gemspec +46 -42
  73. metadata +78 -4
  74. data/API.md +0 -59
@@ -1,13 +1,14 @@
1
- module Squib
2
- class Card
3
-
4
- # :nodoc:
5
- # @api private
6
- def background(color)
7
- cc = cairo_context
8
- cc.set_source_color(color)
9
- cc.paint
10
- end
11
-
12
- end
1
+ module Squib
2
+ class Card
3
+
4
+ # :nodoc:
5
+ # @api private
6
+ def background(color)
7
+ use_cairo do |cc|
8
+ cc.set_source_color(color)
9
+ cc.paint
10
+ end
11
+ end
12
+
13
+ end
13
14
  end
@@ -1,28 +1,47 @@
1
- module Squib
2
- class Card
3
-
4
- # :nodoc:
5
- # @api private
6
- def png(file, x, y, alpha)
7
- cc = cairo_context
8
- png = Cairo::ImageSurface.from_png(file)
9
- cc.set_source(png, x, y)
10
- cc.paint(alpha)
11
- end
12
-
13
- # :nodoc:
14
- # @api private
15
- def svg(file, id, x, y, width, height)
16
- svg = RSVG::Handle.new_from_file(file)
17
- width = svg.width if width == :native
18
- height = svg.height if height == :native
19
- tmp = Cairo::ImageSurface.new(width, height)
20
- tmp_cc = Cairo::Context.new(tmp)
21
- tmp_cc.scale(width.to_f / svg.width.to_f, height.to_f / svg.height.to_f)
22
- tmp_cc.render_rsvg_handle(svg, id)
23
- cairo_context.set_source(tmp, x, y)
24
- cairo_context.paint
25
- end
26
-
27
- end
28
- end
1
+ module Squib
2
+
3
+ # Cache all pngs we've already loaded
4
+ #
5
+ # :nodoc:
6
+ # @api private
7
+ def cache_load_image(file)
8
+ @img_cache ||= {}
9
+ @img_cache[file] || @img_cache[file] = Cairo::ImageSurface.from_png(file)
10
+ end
11
+ module_function :cache_load_image
12
+
13
+ class Card
14
+
15
+ # :nodoc:
16
+ # @api private
17
+ def png(file, x, y, alpha, blend)
18
+ return if file.nil? or file.eql? ''
19
+ png = Squib.cache_load_image(file)
20
+ use_cairo do |cc|
21
+ cc.set_source(png, x, y)
22
+ cc.operator = blend unless blend == :none
23
+ cc.paint(alpha)
24
+ end
25
+ end
26
+
27
+ # :nodoc:
28
+ # @api private
29
+ def svg(file, id, x, y, width, height, alpha, blend)
30
+ Squib.logger.debug {"Rendering: #{file}, #{id} #{x}, #{y}, #{width}, #{height}, #{alpha}, #{blend}"}
31
+ return if file.nil? or file.eql? ''
32
+ svg = RSVG::Handle.new_from_file(file)
33
+ width = svg.width if width == :native
34
+ height = svg.height if height == :native
35
+ tmp = Cairo::ImageSurface.new(width, height)
36
+ tmp_cc = Cairo::Context.new(tmp)
37
+ tmp_cc.scale(width.to_f / svg.width.to_f, height.to_f / svg.height.to_f)
38
+ tmp_cc.render_rsvg_handle(svg, id)
39
+ use_cairo do |cc|
40
+ cc.set_source(tmp, x, y)
41
+ cc.operator = blend unless blend == :none
42
+ cc.paint(alpha)
43
+ end
44
+ end
45
+
46
+ end
47
+ end
@@ -1,51 +1,55 @@
1
- module Squib
2
- class Deck
3
-
4
- # Lays out the cards in range and renders a PDF
5
- #
6
- # @example
7
- # save_pdf file: 'deck.pdf', margin: 75, gap: 5, trim: 37
8
- #
9
- # @option opts file [String] the name of the PDF file to save.
10
- # @option opts dir [String] (_output) the directory to save to. Created if it doesn't exist.
11
- # @option opts margin [Integer] (75) the margin around the outside of the page
12
- # @option opts gap [Integer] (0) the space in pixels between the cards
13
- # @option opts trim [Integer] (0) the space around the edge of each card to trim (e.g. to cut off the bleed margin for print-and-play)
14
- # @return [nil]
15
- # @api public
16
- def save_pdf(opts = {})
17
- p = needs(opts, [:file_to_save, :creatable_dir, :margin, :gap, :trim])
18
- width = 11 * @dpi ; height = 8.5 * @dpi #TODO: allow this to be specified too
19
- cc = Cairo::Context.new(Cairo::PDFSurface.new("#{p[:dir]}/#{p[:file]}", width, height))
20
- x = p[:margin] ; y = p[:margin]
21
- @cards.each_with_index do |card, i|
22
- surface = trim(card.cairo_surface, p[:trim], @width, @height)
23
- cc.set_source(surface, x, y)
24
- cc.paint
25
- x += surface.width + p[:gap]
26
- if x > (width - surface.width - p[:margin])
27
- x = p[:margin]
28
- y += surface.height + p[:gap]
29
- if y > (height - surface.height - p[:margin])
30
- x = p[:margin] ; y = p[:margin]
31
- cc.show_page #next page
32
- end
33
- end
34
- end
35
- end
36
-
37
- # :nodoc:
38
- # @api private
39
- def trim(surface, trim, width, height)
40
- if trim > 0
41
- tmp = Cairo::ImageSurface.new(width-2*trim, height-2*trim)
42
- cc = Cairo::Context.new(tmp)
43
- cc.set_source(surface,-1*trim, -1*trim)
44
- cc.paint
45
- surface = tmp
46
- end
47
- surface
48
- end
49
-
50
- end
1
+ module Squib
2
+ class Deck
3
+
4
+ # Lays out the cards in range and renders a PDF
5
+ #
6
+ # @example
7
+ # save_pdf file: 'deck.pdf', margin: 75, gap: 5, trim: 37
8
+ #
9
+ # @option opts file [String] the name of the PDF file to save. See {file:README.md#Specifying_Files Specifying Files}
10
+ # @option opts dir [String] (_output) the directory to save to. Created if it doesn't exist.
11
+ # @option opts margin [Integer] (75) the margin around the outside of the page
12
+ # @option opts gap [Integer] (0) the space in pixels between the cards
13
+ # @option opts trim [Integer] (0) the space around the edge of each card to trim (e.g. to cut off the bleed margin for print-and-play)
14
+ # @return [nil]
15
+ # @api public
16
+ def save_pdf(opts = {})
17
+ p = needs(opts, [:file_to_save, :creatable_dir, :margin, :gap, :trim])
18
+ width = 11 * @dpi ; height = 8.5 * @dpi #TODO: allow this to be specified too
19
+ cc = Cairo::Context.new(Cairo::PDFSurface.new("#{p[:dir]}/#{p[:file]}", width, height))
20
+ x = p[:margin] ; y = p[:margin]
21
+
22
+ @progress_bar.start("Saving PDF to #{p[:dir]}/#{p[:file]}", p[:range].size) do |bar|
23
+ @cards.each_with_index do |card, i|
24
+ surface = trim(card.cairo_surface, p[:trim], @width, @height)
25
+ cc.set_source(surface, x, y)
26
+ cc.paint
27
+ bar.increment
28
+ x += surface.width + p[:gap]
29
+ if x > (width - surface.width - p[:margin])
30
+ x = p[:margin]
31
+ y += surface.height + p[:gap]
32
+ if y > (height - surface.height - p[:margin])
33
+ x = p[:margin] ; y = p[:margin]
34
+ cc.show_page #next page
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+
41
+ # :nodoc:
42
+ # @api private
43
+ def trim(surface, trim, width, height)
44
+ if trim > 0
45
+ tmp = Cairo::ImageSurface.new(width-2*trim, height-2*trim)
46
+ cc = Cairo::Context.new(tmp)
47
+ cc.set_source(surface,-1*trim, -1*trim)
48
+ cc.paint
49
+ surface = tmp
50
+ end
51
+ surface
52
+ end
53
+
54
+ end
51
55
  end
@@ -1,11 +1,33 @@
1
- module Squib
2
- class Card
3
-
4
- # :nodoc:
5
- # @api private
6
- def save_png(i, dir, prefix)
7
- cairo_context.target.write_to_png("#{dir}/#{prefix}#{i}.png")
8
- end
9
-
10
- end
1
+ module Squib
2
+ class Card
3
+
4
+ # :nodoc:
5
+ # @api private
6
+ def save_png(i, dir, prefix, do_rotate, angle)
7
+ if [true, :clockwise, :counterclockwise].include?(do_rotate)
8
+ surface = rotated_image(angle)
9
+ else
10
+ surface = @cairo_surface
11
+ end
12
+ write_png(surface, i, dir, prefix)
13
+ end
14
+
15
+ # :nodoc:
16
+ # @api private
17
+ def rotated_image(angle)
18
+ rotated_cc = Cairo::Context.new(Cairo::ImageSurface.new(@height, @width) )
19
+ rotated_cc.translate(@height * 0.5, @width * 0.5)
20
+ rotated_cc.rotate(angle)
21
+ rotated_cc.translate(@width * -0.5, @height * -0.5)
22
+ rotated_cc.set_source(@cairo_surface)
23
+ rotated_cc.paint
24
+ rotated_cc.target
25
+ end
26
+ # :nodoc:
27
+ # @api private
28
+ def write_png(surface, i, dir, prefix)
29
+ surface.write_to_png("#{dir}/#{prefix}#{i}.png")
30
+ end
31
+
32
+ end
11
33
  end
@@ -1,56 +1,60 @@
1
- module Squib
2
- class Card
3
-
4
- # :nodoc:
5
- # @api private
6
- def rect(x, y, width, height, x_radius, y_radius, fill_color, stroke_color, stroke_width)
7
- width=@width if width==:native; height=@height if height==:native
8
- cc = cairo_context
9
- cc.rounded_rectangle(x, y, width, height, x_radius, y_radius)
10
- cc.set_source_color(stroke_color)
11
- cc.set_line_width(stroke_width)
12
- cc.stroke
13
- cc.rounded_rectangle(x, y, width, height, x_radius, y_radius)
14
- cc.set_source_color(fill_color)
15
- cc.fill
16
- end
17
-
18
- # :nodoc:
19
- # @api private
20
- def circle(x, y, radius, fill_color, stroke_color, stroke_width)
21
- cc = cairo_context
22
- cc.circle(x, y, radius)
23
- cc.set_source_color(stroke_color)
24
- cc.set_line_width(stroke_width)
25
- cc.stroke
26
- cc.circle(x, y, radius)
27
- cc.set_source_color(fill_color)
28
- cc.fill
29
- end
30
-
31
- # :nodoc:
32
- # @api private
33
- def triangle(x1, y1, x2, y2, x3, y3, fill_color, stroke_color, stroke_width)
34
- cc = cairo_context
35
- cc.triangle(x1, y1, x2, y2, x3, y3)
36
- cc.set_source_color(stroke_color)
37
- cc.set_line_width(stroke_width)
38
- cc.stroke
39
- cc.triangle(x1, y1, x2, y2, x3, y3)
40
- cc.set_source_color(fill_color)
41
- cc.fill
42
- end
43
-
44
- # :nodoc:
45
- # @api private
46
- def line(x1, y1, x2, y2, stroke_color, stroke_width)
47
- cc = cairo_context
48
- cc.move_to(x1, y1)
49
- cc.line_to(x2, y2)
50
- cc.set_source_color(stroke_color)
51
- cc.set_line_width(stroke_width)
52
- cc.stroke
53
- end
54
-
55
- end
1
+ module Squib
2
+ class Card
3
+
4
+ # :nodoc:
5
+ # @api private
6
+ def rect(x, y, width, height, x_radius, y_radius, fill_color, stroke_color, stroke_width)
7
+ width=@width if width==:native; height=@height if height==:native
8
+ use_cairo do |cc|
9
+ cc.rounded_rectangle(x, y, width, height, x_radius, y_radius)
10
+ cc.set_source_color(stroke_color)
11
+ cc.set_line_width(stroke_width)
12
+ cc.stroke
13
+ cc.rounded_rectangle(x, y, width, height, x_radius, y_radius)
14
+ cc.set_source_color(fill_color)
15
+ cc.fill
16
+ end
17
+ end
18
+
19
+ # :nodoc:
20
+ # @api private
21
+ def circle(x, y, radius, fill_color, stroke_color, stroke_width)
22
+ use_cairo do |cc|
23
+ cc.circle(x, y, radius)
24
+ cc.set_source_color(stroke_color)
25
+ cc.set_line_width(stroke_width)
26
+ cc.stroke
27
+ cc.circle(x, y, radius)
28
+ cc.set_source_color(fill_color)
29
+ cc.fill
30
+ end
31
+ end
32
+
33
+ # :nodoc:
34
+ # @api private
35
+ def triangle(x1, y1, x2, y2, x3, y3, fill_color, stroke_color, stroke_width)
36
+ use_cairo do |cc|
37
+ cc.triangle(x1, y1, x2, y2, x3, y3)
38
+ cc.set_source_color(stroke_color)
39
+ cc.set_line_width(stroke_width)
40
+ cc.stroke
41
+ cc.triangle(x1, y1, x2, y2, x3, y3)
42
+ cc.set_source_color(fill_color)
43
+ cc.fill
44
+ end
45
+ end
46
+
47
+ # :nodoc:
48
+ # @api private
49
+ def line(x1, y1, x2, y2, stroke_color, stroke_width)
50
+ use_cairo do |cc|
51
+ cc.move_to(x1, y1)
52
+ cc.line_to(x2, y2)
53
+ cc.set_source_color(stroke_color)
54
+ cc.set_line_width(stroke_width)
55
+ cc.stroke
56
+ end
57
+ end
58
+
59
+ end
56
60
  end
@@ -1,108 +1,114 @@
1
- require 'pango'
2
-
3
- module Squib
4
- class Card
5
-
6
- # :nodoc:
7
- # @api private
8
- def draw_text_hint(x,y,layout, color)
9
- return if color.nil? && @deck.text_hint.nil?
10
- color ||= @deck.text_hint
11
- # when w,h < 0, it was never set. extents[0] are ink extents
12
- w = layout.width / Pango::SCALE
13
- w = layout.extents[1].width / Pango::SCALE if w < 0
14
- h = layout.height / Pango::SCALE
15
- h = layout.extents[1].height / Pango::SCALE if h < 0
16
- rect(x,y,w,h,0,0,'#0000',color, 2.0)
17
- end
18
-
19
- # :nodoc:
20
- # @api private
21
- def ellipsize(layout, options)
22
- unless options[:ellipsize].nil?
23
- h = { :none => Pango::Layout::ELLIPSIZE_NONE,
24
- :start => Pango::Layout::ELLIPSIZE_START,
25
- :middle => Pango::Layout::ELLIPSIZE_MIDDLE,
26
- :end => Pango::Layout::ELLIPSIZE_END,
27
- true => Pango::Layout::ELLIPSIZE_END,
28
- false => Pango::Layout::ELLIPSIZE_NONE
29
- }
30
- layout.ellipsize = h[options[:ellipsize]]
31
- end
32
- layout
33
- end
34
-
35
- # :nodoc:
36
- # @api private
37
- def wrap(layout, options)
38
- unless options[:wrap].nil?
39
- h = { :word => Pango::Layout::WRAP_WORD,
40
- :char => Pango::Layout::WRAP_CHAR,
41
- :word_char => Pango::Layout::WRAP_WORD_CHAR,
42
- true => Pango::Layout::WRAP_WORD_CHAR,
43
- false => nil,
44
- :none => nil
45
- }
46
- layout.wrap = h[options[:wrap]]
47
- end
48
- layout
49
- end
50
-
51
- # :nodoc:
52
- # @api private
53
- def align(layout, options)
54
- unless options[:align].nil?
55
- h = { :left => Pango::ALIGN_LEFT,
56
- :right => Pango::ALIGN_RIGHT,
57
- :center => Pango::ALIGN_CENTER
58
- }
59
- layout.alignment = h[options[:align]]
60
- end
61
- layout
62
- end
63
-
64
- # :nodoc:
65
- # @api private
66
- def valign(cc, layout, x, y, valign)
67
- if layout.height > 0
68
- ink_extents = layout.extents[1]
69
- case valign
70
- when :middle
71
- cc.move_to(x, y + (layout.height - ink_extents.height) / (2 * Pango::SCALE))
72
- when :bottom
73
- cc.move_to(x, y + (layout.height - ink_extents.height) / Pango::SCALE)
74
- end
75
- end
76
- end
77
-
78
- # :nodoc:
79
- # @api private
80
- def setwh(layout, options)
81
- layout.width = options[:width] * Pango::SCALE unless options[:width].nil? || options[:width] == :native
82
- layout.height = options[:height] * Pango::SCALE unless options[:height].nil? || options[:height] == :native
83
- layout
84
- end
85
-
86
- # :nodoc:
87
- # @api private
88
- def text(str, font, x, y, color, options)
89
- cc = cairo_context
90
- cc.set_source_color(color)
91
- cc.move_to(x,y)
92
- layout = cc.create_pango_layout
93
- layout.font_description = Pango::FontDescription.new(font)
94
- layout.text = str.to_s
95
- layout.markup = str.to_s if options[:markup]
96
- layout = setwh(layout, options)
97
- layout = wrap(layout, options)
98
- layout = ellipsize(layout, options)
99
- layout = align(layout, options)
100
- layout.justify = options[:justify] unless options[:justify].nil?
101
- cc.update_pango_layout(layout)
102
- valign(cc, layout, x,y, options[:valign])
103
- cc.update_pango_layout(layout) ; cc.show_pango_layout(layout)
104
- draw_text_hint(x,y,layout,options[:hint])
105
- end
106
-
107
- end
1
+ require 'pango'
2
+
3
+ module Squib
4
+ class Card
5
+
6
+ # :nodoc:
7
+ # @api private
8
+ def draw_text_hint(x,y,layout, color)
9
+ color ||= @deck.text_hint
10
+ return if color.to_s.eql? 'off'
11
+ # when w,h < 0, it was never set. extents[1] are ink extents
12
+ w = layout.width / Pango::SCALE
13
+ w = layout.extents[1].width / Pango::SCALE if w < 0
14
+ h = layout.height / Pango::SCALE
15
+ h = layout.extents[1].height / Pango::SCALE if h < 0
16
+ rect(x,y,w,h,0,0,'#0000',color, 2.0)
17
+ end
18
+
19
+ # :nodoc:
20
+ # @api private
21
+ def ellipsize(layout, ellipsize)
22
+ unless ellipsize.nil?
23
+ h = { :none => Pango::Layout::ELLIPSIZE_NONE,
24
+ :start => Pango::Layout::ELLIPSIZE_START,
25
+ :middle => Pango::Layout::ELLIPSIZE_MIDDLE,
26
+ :end => Pango::Layout::ELLIPSIZE_END,
27
+ true => Pango::Layout::ELLIPSIZE_END,
28
+ false => Pango::Layout::ELLIPSIZE_NONE
29
+ }
30
+ layout.ellipsize = h[ellipsize]
31
+ end
32
+ layout
33
+ end
34
+
35
+ # :nodoc:
36
+ # @api private
37
+ def wrap(layout, wrap)
38
+ unless wrap.nil?
39
+ h = { :word => Pango::Layout::WRAP_WORD,
40
+ :char => Pango::Layout::WRAP_CHAR,
41
+ :word_char => Pango::Layout::WRAP_WORD_CHAR,
42
+ true => Pango::Layout::WRAP_WORD_CHAR,
43
+ false => nil,
44
+ :none => nil
45
+ }
46
+ layout.wrap = h[wrap]
47
+ end
48
+ layout
49
+ end
50
+
51
+ # :nodoc:
52
+ # @api private
53
+ def align(layout, align)
54
+ unless align.nil?
55
+ h = { :left => Pango::ALIGN_LEFT,
56
+ :right => Pango::ALIGN_RIGHT,
57
+ :center => Pango::ALIGN_CENTER
58
+ }
59
+ layout.alignment = h[align]
60
+ end
61
+ layout
62
+ end
63
+
64
+ # :nodoc:
65
+ # @api private
66
+ def valign(cc, layout, x, y, valign)
67
+ if layout.height > 0
68
+ ink_extents = layout.extents[1]
69
+ case valign
70
+ when :middle
71
+ cc.move_to(x, y + (layout.height - ink_extents.height) / (2 * Pango::SCALE))
72
+ when :bottom
73
+ cc.move_to(x, y + (layout.height - ink_extents.height) / Pango::SCALE)
74
+ end
75
+ end
76
+ end
77
+
78
+ # :nodoc:
79
+ # @api private
80
+ def setwh(layout, width, height)
81
+ layout.width = width * Pango::SCALE unless width.nil? || width == :native
82
+ layout.height = height * Pango::SCALE unless height.nil? || height == :native
83
+ layout
84
+ end
85
+
86
+ # :nodoc:
87
+ # @api private
88
+ def text(str, font, color,
89
+ x, y, width, height,
90
+ markup, justify, wrap, ellipsize,
91
+ spacing, align, valign, hint)
92
+ Squib.logger.debug {"Placing '#{str}'' with font '#{font}' @ #{x}, #{y}, color: #{color}, etc."}
93
+ use_cairo do |cc|
94
+ cc.set_source_color(color)
95
+ cc.move_to(x,y)
96
+ layout = cc.create_pango_layout
97
+ layout.font_description = Pango::FontDescription.new(font)
98
+ layout.text = str.to_s
99
+ layout.markup = str.to_s if markup
100
+ layout = setwh(layout, width, height)
101
+ layout = wrap(layout, wrap)
102
+ layout = ellipsize(layout, ellipsize)
103
+ layout = align(layout, align)
104
+ layout.justify = justify unless justify.nil?
105
+ layout.spacing = spacing * Pango::SCALE unless spacing.nil?
106
+ cc.update_pango_layout(layout)
107
+ valign(cc, layout, x,y, valign)
108
+ cc.update_pango_layout(layout) ; cc.show_pango_layout(layout)
109
+ draw_text_hint(x,y,layout,hint)
110
+ end
111
+ end
112
+
113
+ end
108
114
  end