Merge remote branch 'botandrose/patch-4'
* botandrose/patch-4: add test for inline_font_files() Inline fonts weren't being base64 encoded.
This commit is contained in:
commit
155834b341
@ -12,7 +12,7 @@ module Compass::SassExtensions::Functions::InlineImage
|
||||
while args.size > 0
|
||||
path = args.shift.value
|
||||
real_path = File.join(Compass.configuration.fonts_path, path)
|
||||
url = "url('data:#{compute_mime_type(path)};base64,#{data(real_path)}')"
|
||||
url = inline_image_string(data(real_path), compute_mime_type(path))
|
||||
files << "#{url} format('#{args.shift}')"
|
||||
end
|
||||
Sass::Script::String.new(files.join(", "))
|
||||
|
1
test/fixtures/fonts/bgrove.base64.txt
vendored
Normal file
1
test/fixtures/fonts/bgrove.base64.txt
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
test/fixtures/fonts/bgrove.ttf
vendored
Executable file
BIN
test/fixtures/fonts/bgrove.ttf
vendored
Executable file
Binary file not shown.
@ -137,6 +137,12 @@ class SassExtensionsTest < Test::Unit::TestCase
|
||||
}
|
||||
end
|
||||
|
||||
def test_inline_font_files
|
||||
Compass.configuration.fonts_path = File.expand_path "../fixtures/fonts", File.dirname(__FILE__)
|
||||
base64_string = File.read(File.join(Compass.configuration.fonts_path, "bgrove.base64.txt")).chomp
|
||||
assert_equal "url('data:font/truetype;base64,#{base64_string}') format('truetype')", evaluate("inline_font_files('bgrove.ttf', truetype)")
|
||||
end
|
||||
|
||||
protected
|
||||
def evaluate(value)
|
||||
Sass::Script::Parser.parse(value, 0, 0).perform(Sass::Environment.new).to_s
|
||||
|
Loading…
Reference in New Issue
Block a user