Sha256: 64d1ac4ad89ded9e8ed6a1ade5ecbc5600d67ca4a5c4f9e1cc900865c5e37125

Contents?: true

Size: 901 Bytes

Versions: 7

Compression:

Stored size: 901 Bytes

Contents

module Compass::SassExtensions::Functions::FontFiles
  FONT_TYPES = {
    :woff => 'woff',
    :otf => 'opentype',
    :opentype => 'opentype',
    :ttf => 'truetype',
    :truetype => 'truetype',
    :svg => 'svg'
  }

  def font_files(*args)
    files = []
    args_length = args.length
    skip_next = false

    args.each_with_index do |arg, index|
      if skip_next
        skip_next = false
        next
      end

      type = (args_length > (index + 1)) ? args[index + 1].value.to_sym : :wrong

      if FONT_TYPES.key? type
        skip_next = true
      else
        type = arg.to_s.split('.').last.gsub('"', '').to_sym
      end

      if FONT_TYPES.key? type
        files << "#{font_url(arg)} format('#{FONT_TYPES[type]}')"
      else
        raise Sass::SyntaxError, "Could not determine font type for #{arg}"
      end
    end

    Sass::Script::String.new(files.join(", "))
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
compass-0.12.0 lib/compass/sass_extensions/functions/font_files.rb
compass-0.12.rc.1 lib/compass/sass_extensions/functions/font_files.rb
compass-0.12.rc.0 lib/compass/sass_extensions/functions/font_files.rb
compass-0.12.alpha.4 lib/compass/sass_extensions/functions/font_files.rb
compass-0.12.alpha.3 lib/compass/sass_extensions/functions/font_files.rb
compass-0.12.alpha.2 lib/compass/sass_extensions/functions/font_files.rb
compass-0.12.alpha.1 lib/compass/sass_extensions/functions/font_files.rb