Rotation works better now!!
This commit is contained in:
@@ -34,7 +34,7 @@ module Squib
|
||||
# @option opts justify [Boolean] (false) toggles whether or not the text is justified or not.
|
||||
# @option opts valign [:top, :middle, :bottom] (:top) When width and height are set, align text vertically according to the ink extents of the text.
|
||||
# @option opts ellipsize [:none, :start, :middle, :end, true, false] (:end) When width and height are set, determines the behavior of overflowing text. Also: `true` maps to `:end` and `false` maps to `:none`. Default `:end`
|
||||
# @option opts angle [FixNum] (0) Rotation of the text in radians.
|
||||
# @option opts angle [FixNum] (0) Rotation of the text in radians. Note that this rotates around the upper-left corner of the text box, making the placement of x-y coordinates slightly tricky.
|
||||
# @option opts hint [String] (:nil) draw a rectangle around the text with the given color. Overrides global hints (see {Deck#hint}).
|
||||
# @return [nil] Returns nothing
|
||||
# @api public
|
||||
|
||||
+11
-11
@@ -13,8 +13,6 @@ 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
|
||||
|
||||
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)
|
||||
@@ -40,19 +38,19 @@ module Squib
|
||||
# @api private
|
||||
def set_wrap!(layout, wrap)
|
||||
case wrap.to_s.downcase
|
||||
when 'word'
|
||||
layout.wrap = Pango::Layout::WRAP_WORD
|
||||
when 'char'
|
||||
layout.wrap = Pango::Layout::WRAP_CHAR
|
||||
when 'word_char', 'true'
|
||||
layout.wrap = Pango::Layout::WRAP_WORD_CHAR
|
||||
end
|
||||
when 'word'
|
||||
layout.wrap = Pango::Layout::WRAP_WORD
|
||||
when 'char'
|
||||
layout.wrap = Pango::Layout::WRAP_CHAR
|
||||
when 'word_char', 'true'
|
||||
layout.wrap = Pango::Layout::WRAP_WORD_CHAR
|
||||
end
|
||||
end
|
||||
|
||||
# :nodoc:
|
||||
# @api private
|
||||
def set_align!(layout, align)
|
||||
case align.to_s
|
||||
case align.to_s.downcase
|
||||
when 'left'
|
||||
layout.alignment = Pango::ALIGN_LEFT
|
||||
when 'right'
|
||||
@@ -93,8 +91,10 @@ module Squib
|
||||
Squib.logger.debug {"Placing '#{str}'' with font '#{font}' @ #{x}, #{y}, color: #{color}, angle: #{angle} etc."}
|
||||
use_cairo do |cc|
|
||||
cc.set_source_color(color)
|
||||
cc.move_to(x,y)
|
||||
cc.translate(x,y)
|
||||
cc.rotate(angle)
|
||||
cc.translate(-1*x,-1*y)
|
||||
cc.move_to(x,y)
|
||||
|
||||
layout = cc.create_pango_layout
|
||||
font_desc = Pango::FontDescription.new(font)
|
||||
|
||||
Reference in New Issue
Block a user