module MapPrint::PngHandlers::Texts

Public Instance Methods

draw_text(png, text, position, options) click to toggle source
# File lib/map_print/png_handlers/texts.rb, line 12
def draw_text(png, text, position, options)
  png.combine_options do |c|
    c.density 300
    sanitize_options(options).each do |option, value|
      c.send option, value
    end
    c.draw "text #{position} '#{text}'"
  end
end
print_texts(texts, png) click to toggle source
sanitize_options(options) click to toggle source
# File lib/map_print/png_handlers/texts.rb, line 22
def sanitize_options(options)
  return {} unless options.is_a?(Hash)
  options[:stroke] = options.delete :color if options[:color]
  options[:fill] = options.delete :fill_color if options[:fill_color]
  options[:gravity] ||= 'NorthWest'
  options[:font] ||= 'Arial'
  options
end