Sha256: fcb81a74241bb0e4381ba6dd5450e3f20fcbcceb85a14256026bfafb5486262b

Contents?: true

Size: 614 Bytes

Versions: 4

Compression:

Stored size: 614 Bytes

Contents

# frozen_string_literal: true

require 'yaml'
require_relative 'unicode'

module Prawn
  module Emoji
    class Image
      STORE = Emoji.root.join 'emoji', 'images'

      attr_reader :unicode, :font_size

      def initialize(unicode, font_size)
        @unicode = unicode
        @font_size = font_size
      end

      def path
        STORE.join("#{unicode.codepoint}.png").to_s
      end

      def adjust_x(base_x)
        base_x + (font_size - width) / 2
      end

      def adjust_y(base_y)
        base_y + font_size * 0.8
      end

      def width
        font_size * 0.85
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
prawn-emoji-3.3.0 lib/prawn/emoji/image.rb
prawn-emoji-3.2.0 lib/prawn/emoji/image.rb
prawn-emoji-3.1.0 lib/prawn/emoji/image.rb
prawn-emoji-3.0.0 lib/prawn/emoji/image.rb