From 914e40e1f405d4446e51987362e02eee3d57a766 Mon Sep 17 00:00:00 2001 From: Andy Meneely Date: Mon, 20 Oct 2014 15:08:04 -0400 Subject: [PATCH] Warn about hints and angle Can't seem to get text hints working with rotating text. Just throwing a warning for now. --- lib/squib/graphics/text.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/squib/graphics/text.rb b/lib/squib/graphics/text.rb index 4bcd1c8..b2b5062 100644 --- a/lib/squib/graphics/text.rb +++ b/lib/squib/graphics/text.rb @@ -5,7 +5,7 @@ module Squib # :nodoc: # @api private - def draw_text_hint(x,y,layout, color) + def draw_text_hint(cc,x,y,layout, color,angle) 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' # when w,h < 0, it was never set. extents[1] are ink extents @@ -13,7 +13,12 @@ module Squib w = layout.extents[1].width / Pango::SCALE if w < 0 h = layout.height / Pango::SCALE h = layout.extents[1].height / Pango::SCALE if h < 0 - rect(x,y,w,h,0,0,'#0000',color, 2.0) + + Squib.logger.warn 'Text hints are broken on non-zero angles' if angle > 0 + cc.rounded_rectangle(x,y,w,h,0,0) + cc.set_source_color(color) + cc.set_line_width(2.0) + cc.stroke end # :nodoc: @@ -94,6 +99,7 @@ module Squib cc.set_source_color(color) cc.move_to(x,y) cc.rotate(angle) + layout = cc.create_pango_layout font_desc = Pango::FontDescription.new(font) font_desc.size = font_size * Pango::SCALE unless font_size.nil? @@ -109,7 +115,7 @@ module Squib cc.update_pango_layout(layout) valign(cc, layout, x,y, valign) cc.update_pango_layout(layout) ; cc.show_pango_layout(layout) - draw_text_hint(x,y,layout,hint) + draw_text_hint(cc,x,y,layout,hint,angle) end end