From 035cd6259e076aeb2ec154298337cf7b51e47bbc Mon Sep 17 00:00:00 2001 From: Andy Meneely Date: Thu, 16 Apr 2015 21:24:21 -0400 Subject: [PATCH] Fix global hinting logic Fixes #63 --- lib/squib/constants.rb | 1 + lib/squib/graphics/text.rb | 6 +++--- spec/data/samples/custom_config.rb.txt | 4 ++++ spec/data/samples/text_options.rb.txt | 12 ++++++++++++ 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/lib/squib/constants.rb b/lib/squib/constants.rb index ded0be5..eb52d19 100644 --- a/lib/squib/constants.rb +++ b/lib/squib/constants.rb @@ -88,6 +88,7 @@ module Squib 'en_dash' => "\u2013", 'ellipsis' => "\u2026", 'smart_quotes' => true, + 'text_hint' => 'off', } #Translate the hints to the methods. diff --git a/lib/squib/graphics/text.rb b/lib/squib/graphics/text.rb index 9d91ed5..4177032 100644 --- a/lib/squib/graphics/text.rb +++ b/lib/squib/graphics/text.rb @@ -6,8 +6,8 @@ module Squib # :nodoc: # @api private - def draw_text_hint(cc,x,y,layout, color,angle) - color = @deck.text_hint if color.eql? 'off' and not @deck.text_hint.to_s.eql? 'off' + def draw_text_hint(cc, x, y, layout, color) + color = @deck.text_hint if color.to_s.eql? 'off' and not @deck.text_hint.to_s.eql? 'off' return if color.to_s.eql? 'off' or color.nil? # when w,h < 0, it was never set. extents[1] are ink extents w = layout.width / Pango::SCALE @@ -194,7 +194,7 @@ module Squib puts "==================" raise e end - draw_text_hint(cc, x, y, layout, hint, angle) + draw_text_hint(cc, x, y, layout, hint) extents = { width: layout.extents[1].width / Pango::SCALE, height: layout.extents[1].height / Pango::SCALE } end diff --git a/spec/data/samples/custom_config.rb.txt b/spec/data/samples/custom_config.rb.txt index f3d6909..96b9270 100644 --- a/spec/data/samples/custom_config.rb.txt +++ b/spec/data/samples/custom_config.rb.txt @@ -20,6 +20,10 @@ cairo: update_pango_layout([MockDouble]) cairo: move_to([0, 0]) cairo: update_pango_layout([MockDouble]) cairo: show_pango_layout([MockDouble]) +cairo: rounded_rectangle([0, 0, 0, 0, 0, 0]) +cairo: set_source_color(["#FF0000"]) +cairo: set_line_width([2.0]) +cairo: stroke([]) cairo: restore([]) cairo: save([]) cairo: translate([620, 75]) diff --git a/spec/data/samples/text_options.rb.txt b/spec/data/samples/text_options.rb.txt index 9cf7931..006bd8e 100644 --- a/spec/data/samples/text_options.rb.txt +++ b/spec/data/samples/text_options.rb.txt @@ -560,6 +560,10 @@ cairo: update_pango_layout([MockDouble]) cairo: move_to([0, 0]) cairo: update_pango_layout([MockDouble]) cairo: show_pango_layout([MockDouble]) +cairo: rounded_rectangle([0, 0, 0, 0, 0, 0]) +cairo: set_source_color([:cyan]) +cairo: set_line_width([2.0]) +cairo: stroke([]) cairo: restore([]) cairo: save([]) cairo: set_source_color([:black]) @@ -577,6 +581,10 @@ cairo: update_pango_layout([MockDouble]) cairo: move_to([0, 0]) cairo: update_pango_layout([MockDouble]) cairo: show_pango_layout([MockDouble]) +cairo: rounded_rectangle([0, 0, 0, 0, 0, 0]) +cairo: set_source_color([:cyan]) +cairo: set_line_width([2.0]) +cairo: stroke([]) cairo: restore([]) cairo: save([]) cairo: set_source_color([:black]) @@ -594,6 +602,10 @@ cairo: update_pango_layout([MockDouble]) cairo: move_to([0, 0]) cairo: update_pango_layout([MockDouble]) cairo: show_pango_layout([MockDouble]) +cairo: rounded_rectangle([0, 0, 0, 0, 0, 0]) +cairo: set_source_color([:cyan]) +cairo: set_line_width([2.0]) +cairo: stroke([]) cairo: restore([]) cairo: save([]) cairo: set_source_color([:black])