Sha256: 9376866f38a6df83efb3e364db2eb79c1c7d056b5cc5ac802f18ecd97ea8ce9c
Contents?: true
Size: 822 Bytes
Versions: 4
Compression:
Stored size: 822 Bytes
Contents
require 'forwardable' module Prawn module Emoji class Substitution extend Forwardable FULL_SIZE_SPACE = ' '.freeze HALF_SIZE_SPACE = Prawn::Text::NBSP def_delegator :@document, :width_of def initialize(document) @document = document @font = document.font @font_size = document.font_size end def to_s emoji_width == full_size_space_width ? FULL_SIZE_SPACE : half_size_spaces end private def emoji_width @emoji_width ||= @font_size + @document.character_spacing end def full_size_space_width width_of @font.normalize_encoding(FULL_SIZE_SPACE) end def half_size_spaces HALF_SIZE_SPACE * (emoji_width.to_f / width_of(HALF_SIZE_SPACE)).round end end end end
Version data entries
4 entries across 4 versions & 1 rubygems