module Compass::Fontcustom::SassExtensions::Functions
Sass
function extensions
Constants
- FONT_TYPE_OPTIONS
Font type format mappings used in css font-face declarations. @see
glyph_font_sources
Public Instance Methods
Returns `:before` pseudo class styles for the letter at `index` of the font.
@param map [Compass::Fontcustom::GlyphMap] a glyph map @param glyph [String] glyph name @return [Sass::Script::String]
# File lib/compass/fontcustom/sass_extensions.rb, line 23 def glyph(map, glyph) # Name transform should be implemented as in FontCustom glyph = map.glyphs[Util.sanitize_symbol(glyph).to_sym] Sass::Script::String.new "'\\#{glyph[:codepoint]}'" end
Retuns the font name of `map`.
@param map [Compass::Fontcustom::GlyphMap] a glyph map @return [Sass::Script::String]
# File lib/compass/fontcustom/sass_extensions.rb, line 63 def glyph_font_name(map) Sass::Script::String.new map.name end
Returns the font name of `map in quotes
@param map [Compass::Fontcustom::GlyphMap] a glyph map @return [Sass::Script::String]
# File lib/compass/fontcustom/sass_extensions.rb, line 72 def glyph_font_name_quoted(map) Sass::Script::String.new %Q{"#{map.name}"} end
Returns all `url(…) format(…)` definitions for the font files of the `map`.
@param map [Compass::Fontcustom::GlyphMap] a glyph map @return [Sass::Script::String]
# File lib/compass/fontcustom/sass_extensions.rb, line 43 def glyph_font_sources(map) map.generate src = [] fonts = map.fonts FONT_TYPE_OPTIONS.each do |font_type, options| if font = fonts[font_type] url = glyph_font_type_url("#{font}#{options[:postfix]}" % {font_name: map.name}) src << "#{url} format('#{options[:format]}')" end end Sass::Script::String.new src.join ", " end
Helper method. Returns a `Sass::Script::Functions#font_url for the font of `type` in `map`.
@return [String]
# File lib/compass/fontcustom/sass_extensions.rb, line 80 def glyph_font_type_url(file_path) font_file = Sass::Script::String.new File.basename(file_path) font_url(font_file).value end
Returns a `GlyphMap` representing a font.
@param uri [String] the uri to glob files from @return [Compass::Fontcustom::GlyphMap] a glyph map
# File lib/compass/fontcustom/sass_extensions.rb, line 34 def glyph_map(uri) GlyphMap.from_uri uri.value, self end
# File lib/compass/fontcustom/sass_extensions.rb, line 85 def sanitize_symbol(name) Sass::Script::String.new Util.sanitize_symbol name.value end