Sha256: 8d49a12769850164087e66f8e7254e8322bcdc6c4ded3c0a03798ec2ef81da0d
Contents?: true
Size: 1.97 KB
Versions: 1
Compression:
Stored size: 1.97 KB
Contents
module Fontana class Font def initialize(original_font_path) raise Errno::ENOENT.new("No such file #{original_font_path}") unless File.file?(original_font_path) @original_font_path = original_font_path @original_font_type = File.extname(@original_font_path) File.open(@original_font_path) { |file| @original_font_file_contents = file.read } self end def to_eot return @eot_string unless @eot_string.nil? case @original_font_type when '.eot' @eot_string = @original_font_file_contents when '.ttf' @eot_string = TTF2EOT.convert(@original_font_file_contents) else @eot_string = TTF2EOT.convert(to_ttf) end @eot_string end def to_otf return @otf_string unless @otf_string.nil? case @original_font_type when '.otf' @otf_string = @original_font_file_contents else @otf_string = Fontforge.convert(@original_font_type, @original_font_file_contents, '.otf') end @otf_string end def to_svg return @svg_string unless @svg_string.nil? case @original_font_type when '.svg' @svg_string = @original_font_file_contents else @svg_string = Fontforge.convert(@original_font_type, @original_font_file_contents, '.svg') end @svg_string end def to_ttf return @ttf_string unless @ttf_string.nil? case @original_font_type when '.ttf' @ttf_string = @original_font_file_contents else @ttf_string = Fontforge.convert(@original_font_type, @original_font_file_contents, '.ttf') end @ttf_string end def to_woff return @woff_string unless @woff_string.nil? case @original_font_type when '.woff' @woff_string = @original_font_file_contents else @woff_string = Fontforge.convert(@original_font_type, @original_font_file_contents, '.woff') end @woff_string end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fontana-0.0.1.rc1 | lib/fontana/font.rb |