aligning and valigning based on ink, not logical
parent
fad0f93e4a
commit
77755cf150
|
|
@ -63,13 +63,14 @@ module Squib
|
||||||
|
|
||||||
# :nodoc:
|
# :nodoc:
|
||||||
# @api private
|
# @api private
|
||||||
def valign(cc, layout, extents, x, y, valign)
|
def valign(cc, layout, x, y, valign)
|
||||||
if layout.height > 0
|
if layout.height > 0
|
||||||
|
ink_extents = layout.extents[1]
|
||||||
case valign
|
case valign
|
||||||
when :middle
|
when :middle
|
||||||
cc.move_to(x, y + (layout.height - extents.height) / (2 * Pango::SCALE))
|
cc.move_to(x, y + (layout.height - ink_extents.height) / (2 * Pango::SCALE))
|
||||||
when :bottom
|
when :bottom
|
||||||
cc.move_to(x, y + (layout.height - extents.height) / Pango::SCALE)
|
cc.move_to(x, y + (layout.height - ink_extents.height) / Pango::SCALE)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -97,9 +98,8 @@ module Squib
|
||||||
layout = ellipsize(layout, options)
|
layout = ellipsize(layout, options)
|
||||||
layout = align(layout, options)
|
layout = align(layout, options)
|
||||||
layout.justify = options[:justify] unless options[:justify].nil?
|
layout.justify = options[:justify] unless options[:justify].nil?
|
||||||
logical_extents = layout.extents[0]
|
|
||||||
cc.update_pango_layout(layout)
|
cc.update_pango_layout(layout)
|
||||||
valign(cc, layout, logical_extents, x,y, options[:valign])
|
valign(cc, layout, x,y, options[:valign])
|
||||||
cc.update_pango_layout(layout) ; cc.show_pango_layout(layout)
|
cc.update_pango_layout(layout) ; cc.show_pango_layout(layout)
|
||||||
draw_text_hint(x,y,layout,options[:hint])
|
draw_text_hint(x,y,layout,options[:hint])
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue