Sha256: bab085561487d306880538c0cd7e7100a2f3e02bd8cb51c211c7fa7ff9141a58
Contents?: true
Size: 670 Bytes
Versions: 5
Compression:
Stored size: 670 Bytes
Contents
module Hershey class Character OFFSET = ' '.ord def initialize(character, font: :futural) @char = character.to_s[0] || ' ' @font = font @match = FONTS[@font][@char.ord - OFFSET].match(/\A(?<midpoint>[\d-]+) +(?<width>[\d-]+) ?(?<path>[\w -]*)\Z/) @path = @match['path'] @midpoint = @match['midpoint'].to_i @add_offset = @match['width'].to_i - @midpoint end def to_path(offset) %Q{<path stroke="black" fill="none" d="#{@path}" transform="translate(#{offset - @midpoint},0)"></path>} end def spacing @add_offset end def char @char end alias_method :to_s, :char end end
Version data entries
5 entries across 5 versions & 1 rubygems