lib/rabbit/theme/applier.rb in rabbit-2.2.1 vs lib/rabbit/theme/applier.rb in rabbit-3.0.0

- old
+ new

@@ -239,12 +239,12 @@ private *logger_methods def_delegators(:canvas, :make_layout) # Those constants are meaningless. :p - NORMALIZED_WIDTH = 91.0 * 96 - NORMALIZED_HEIGHT = 67.5 * 96 + NORMALIZED_WIDTH = 130.0 * 96 + NORMALIZED_HEIGHT = 97.5 * 96 def initialize(theme, &callback) super() @theme = theme @callback = callback @@ -287,23 +287,40 @@ def normalized_height NORMALIZED_HEIGHT / Canvas::INTERNAL_DPI end def normalized_size(s) - ((s / canvas.width.to_f) * normalized_width).ceil + if wide_aspect_ratio? + normalized_y(s) + else + normalized_x(s) + end end def normalized_x(sx) ((sx / canvas.width.to_f) * normalized_width).ceil end def normalized_y(sy) ((sy / canvas.height.to_f) * normalized_height).ceil end + def font_size(size) + # TODO: Convert to point from pixel + if wide_aspect_ratio? + ((canvas.height * size) / normalized_height) + else + ((canvas.width * size) / normalized_width) + end + end + def screen_size(n) - ((canvas.width * n) / normalized_width).ceil + if wide_aspect_ratio? + screen_y(n) + else + screen_x(n) + end end def screen_x(nx) ((canvas.width * nx) / normalized_width).ceil end @@ -315,10 +332,14 @@ def [](name) instance_variable_get("@#{name}") end private + def wide_aspect_ratio? + (canvas.width / 4) > (canvas.height / 3) + end + def normalize_source(src) src.gsub(/(?=^|\W)@(very_)?huge_(script_)?font_size(?=$|\W)/) do |x| x = "x" x *= 2 unless $1.nil? "@#{x}_large_#{$2}font_size" @@ -331,14 +352,10 @@ rescue ThemeExit info($!.message) if $!.have_message? end end - def to_attrs(hash) - canvas.to_attrs(hash) - end - def name @theme.name end def slides @@ -617,10 +634,10 @@ message = format % [deprecated, current] warning(message) end def tag(name, attributes, content) - "<#{name} #{to_attrs(attributes)}>#{content}</#{name}>" + PangoMarkup.new(name, attributes, content).to_s end def span(attributes, content) tag("span", attributes, content) end