Sha256: 7e713cf612c4067fe6c58b61895b787098d8392289ba2fa2376931c885694280

Contents?: true

Size: 666 Bytes

Versions: 1

Compression:

Stored size: 666 Bytes

Contents

#
# Font helper
#

require 'mini_magick'

module VCSRuby
  class Font
    attr_reader :name, :path, :size

    def initialize name, size
      @name = name
      @path = find_path
      @size = size
    end

    def find_path
      if Tools::windows?
        Dir.entries File.join(ENV['windir'], 'fonts')
        ''
      else 
        font = `fc-list | grep #{name}`
        font.split(':').first.strip
      end
    end

    def line_height
      MiniMagick::Tool::Convert.new do |convert|
        convert.font path
        convert.pointsize size
        convert << 'label:F'
        convert.format '%h'
        convert << 'info:'
      end.to_i
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vcs_ruby-0.8.4 lib/font.rb