class Rabbit::Renderer::Print::Cairo

Public Class Methods

new(canvas) click to toggle source
Calls superclass method Rabbit::Renderer::Print::Base.new
# File lib/rabbit/renderer/print/cairo.rb, line 32
def initialize(canvas)
  super
  init_paper
  init_color
end
priority() click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 23
def priority
  if (::Cairo::VERSION <=> [1, 2, 0]) >= 0
    100
  else
    -100
  end
end

Public Instance Methods

cairo_poppler_available?()
Alias for: poppler_available?
cairo_rsvg_available?()
Alias for: rsvg_available?
internal_clip_slide(x=0, y=0, w=width, h=height) click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 68
def internal_clip_slide(x=0, y=0, w=width, h=height)
  x, y = from_screen(x, y)
  @context.rectangle(x, y, w, h)
  @context.clip
end
internal_draw_background(x=0, y=0, w=width, h=height) click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 74
def internal_draw_background(x=0, y=0, w=width, h=height)
  draw_rectangle(true, x, y, w, h, @background)
end
internal_draw_slide(slide, simulation) { || ... } click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 63
def internal_draw_slide(slide, simulation)
  yield
  @context.show_page if !simulation and @show_page
end
poppler_available?() click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 82
def poppler_available?
  cairo_poppler_available?
end
Also aliased as: cairo_poppler_available?
post_apply_theme() click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 54
def post_apply_theme
end
post_move(old_index, index) click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 57
def post_move(old_index, index)
end
post_move_in_slide(old_index, index) click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 60
def post_move_in_slide(old_index, index)
end
post_parse() click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 51
def post_parse
end
post_print(canceled) click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 43
def post_print(canceled)
  return if canceled
  @context.target.finish
end
pre_parse() click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 48
def pre_parse
end
pre_print(slide_size) click to toggle source
Calls superclass method Rabbit::Renderer::Print::Base#pre_print
# File lib/rabbit/renderer/print/cairo.rb, line 38
def pre_print(slide_size)
  super
  init_context(create_context)
end
rsvg_available?() click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 78
def rsvg_available?
  cairo_rsvg_available?
end
Also aliased as: cairo_rsvg_available?

Private Instance Methods

create_context(output=nil) click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 106
def create_context(output=nil)
  surface = find_surface(filename, output)
  surface.set_fallback_resolution(@x_dpi, @y_dpi)
  ::Cairo::Context.new(surface)
end
create_pango_context() click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 112
def create_pango_context
  context = create_context(StringIO.new).create_pango_layout.context
  set_font_resolution(context)
  context
end
find_surface(filename, output=nil) click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 118
def find_surface(filename, output=nil)
  args = [output || filename, @page_width, @page_height]
  case File.extname(filename)
  when /\.ps/
    ::Cairo::PSSurface.new(*args)
  when /\.pdf/
    ::Cairo::PDFSurface.new(*args)
  when /\.svg/
    surface = ::Cairo::SVGSurface.new(*args)
    surface.restrict_to_version(::Cairo::SVG_VERSION_1_2)
    surface
  else
    @canvas.logger.warn(_("can't find printer for %s") % filename)
    args[0] = "default.ps"
    ::Cairo::PSSurface.new(*args)
  end
end
init_color() click to toggle source
Calls superclass method
# File lib/rabbit/renderer/print/cairo.rb, line 94
def init_color
  super
  @foreground = make_color("black")
  @background = make_color(@background_color)
end
init_dpi() click to toggle source
Calls superclass method
# File lib/rabbit/renderer/print/cairo.rb, line 100
def init_dpi
  super
  @x_dpi = 300
  @y_dpi = 300
end
init_paper() click to toggle source
# File lib/rabbit/renderer/print/cairo.rb, line 87
def init_paper
  default_width_mm = 360
  default_height_mm = 270
  @page_width = @paper_width || default_width_mm
  @page_height = @paper_height || default_height_mm
end