Module: Compass::Core::SassExtensions::Functions::FontFiles

### Home Classes Methods

### In Files

- lib/compass/core/sass_extensions/functions/font_files.rb

### Methods

- #font_files
- #font_formats
- #with_each_font_file

### Class/Module Index

Quicksearch

- Compass
- Compass::BrowserSupport
- Compass::Configuration
- Compass::Configuration::Adapters
- Compass::Configuration::Data
- Compass::Configuration::Defaults
- Compass::Configuration::Inheritance
- Compass::Configuration::Inheritance::ClassMethods
- Compass::Configuration::Inheritance::ClassMethods::ArrayProxy
- Compass::Configuration::Inheritance::InstanceMethods
- Compass::Configuration::Paths
- Compass::Configuration::Watch
- Compass::Core
- Compass::Core::CanIUse
- Compass::Core::SassExtensions
- Compass::Core::SassExtensions::Functions
- Compass::Core::SassExtensions::Functions::Colors
- Compass::Core::SassExtensions::Functions::Configuration
- Compass::Core::SassExtensions::Functions::Constants
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport
- Compass::Core::SassExtensions::Functions::CrossBrowserSupport::CSS2FallbackValue
- Compass::Core::SassExtensions::Functions::Display
- Compass::Core::SassExtensions::Functions::Enumerate
- Compass::Core::SassExtensions::Functions::Env
- Compass::Core::SassExtensions::Functions::Files
- Compass::Core::SassExtensions::Functions::FontFiles
- Compass::Core::SassExtensions::Functions::GradientSupport
- Compass::Core::SassExtensions::Functions::GradientSupport::Assertions
- Compass::Core::SassExtensions::Functions::GradientSupport::CSS3AngleToSVGConverter
- Compass::Core::SassExtensions::Functions::GradientSupport::ColorStop
- Compass::Core::SassExtensions::Functions::GradientSupport::Functions
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient
- Compass::Core::SassExtensions::Functions::GradientSupport::Gradient::ClassMethods
- Compass::Core::SassExtensions::Functions::GradientSupport::LinearGradient
- Compass::Core::SassExtensions::Functions::GradientSupport::RadialGradient
- Compass::Core::SassExtensions::Functions::ImageSize
- Compass::Core::SassExtensions::Functions::ImageSize::ImageProperties
- Compass::Core::SassExtensions::Functions::ImageSize::JPEG
- Compass::Core::SassExtensions::Functions::InlineImage
- Compass::Core::SassExtensions::Functions::Lists
- Compass::Core::SassExtensions::Functions::Math
- Compass::Core::SassExtensions::Functions::SassDeclarationHelper
- Compass::Core::SassExtensions::Functions::Selectors
- Compass::Core::SassExtensions::Functions::Urls
- Compass::Core::SassExtensions::Functions::Urls::FontUrl
- Compass::Core::SassExtensions::Functions::Urls::GeneratedImageUrl
- Compass::Core::SassExtensions::Functions::Urls::ImageUrl
- Compass::Core::SassExtensions::Functions::Urls::StylesheetUrl
- Compass::Error
- Compass::Frameworks
- Compass::Frameworks::Framework
- Compass::HasDeprecatedConstantsFromCore
- Compass::SassExtensions
- Compass::SassExtensions::Functions
- Compass::Util
- Sass
- Sass::Script
- Sass::Script::CrossBrowserFunctionCall
- Sass::Script::Funcall
- Sass::Script::Functions
- Sass::Script::Functions::EvaluationContext
- Sass::Script::HasSimpleCrossBrowserFunctionSupport
- Sass::Script::List
- Sass::Script::Value
- Sass::Script::Value::ArgList
- Sass::Script::Value::Base
- Sass::Script::Value::List
- Sass::Script::Value::Map
- Sass::Tree
- Sass::Tree::Node

No matching classes.

# Compass::Core::SassExtensions::Functions::FontFiles

### Constants

FONT_TYPES

### Public Instance Methods

font_files(*args) click to toggle source

    # File lib/compass/core/sass_extensions/functions/font_files.rb, line 21
    def font_files(*args)
      return null unless args.any?
      files = []
      with_each_font_file(*args) do |path, type|
        files << list(font_url(path), identifier("format('#{type}')"), :space)
      end
      list(files, :comma)
    end

font_formats(*args) click to toggle source

    # File lib/compass/core/sass_extensions/functions/font_files.rb, line 13
    def font_formats(*args)
      formats = []
      with_each_font_file(*args) do |path, type|
        formats << identifier(type)
      end
      return list(formats, :comma)
    end

### Protected Instance Methods

with_each_font_file(*args) click to toggle source

    # File lib/compass/core/sass_extensions/functions/font_files.rb, line 31
    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

[Validate]

Generated with the Darkfish Rdoc Generator 2.