Sha256: d24e65e4d1334fb8b70c4db228d31ecbd72cb68fb42268929783970cff5a6267
Contents?: true
Size: 1.71 KB
Versions: 2
Compression:
Stored size: 1.71 KB
Contents
module Compass::Core::SassExtensions::Functions::FontFiles FONT_TYPES = { :woff => 'woff', :otf => 'opentype', :opentype => 'opentype', :ttf => 'truetype', :truetype => 'truetype', :svg => 'svg', :eot => 'embedded-opentype' } def font_formats(*args) formats = [] with_each_font_file(*args) do |path, type| formats << Sass::Script::String.new(type) end return Sass::Script::List.new(formats, :comma) end def font_files(*args) files = [] with_each_font_file(*args) do |path, type| files << "#{font_url(path)} format('#{type}')" end Sass::Script::String.new(files.join(", ")) end protected def with_each_font_file(*args) skip_next = false args.each_with_index do |path, index| assert_type path, :String path = unquote(path) # if we were told to skip this iteration, do so... if skip_next skip_next = false next end # back-compat support for passing the font type e.g. # font-files('path/to/file.ttf', truetype, 'path/to/file.otf', opentype); type = args[index + 1] type = type.nil? ? :wrong : type.value.to_sym # if the type is valid, keep it, and skip the next index (as it was the type) if FONT_TYPES.key? type skip_next = true # otherwise, we need to look at the file extension to derive the type... else # let pass url like font.type?thing#stuff type = path.to_s.split('.').last.gsub(/(\?(.*))?(#(.*))?\"?/, '').to_sym end if FONT_TYPES.key? type yield(path, FONT_TYPES[type]) if block_given? else raise Sass::SyntaxError, "Could not determine font type for #{path}" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
compass-core-1.0.0.alpha.15 | lib/compass/core/sass_extensions/functions/font_files.rb |
compass-core-1.0.0.alpha.14 | lib/compass/core/sass_extensions/functions/font_files.rb |