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:
Chris Eppstein 2011-09-16 15:49:49 -07:00
commit 155834b341
4 changed files with 8 additions and 1 deletions

View File

@ -12,7 +12,7 @@ module Compass::SassExtensions::Functions::InlineImage
while args.size > 0 while args.size > 0
path = args.shift.value path = args.shift.value
real_path = File.join(Compass.configuration.fonts_path, path) 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}')" files << "#{url} format('#{args.shift}')"
end end
Sass::Script::String.new(files.join(", ")) Sass::Script::String.new(files.join(", "))

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

Binary file not shown.

View File

@ -137,6 +137,12 @@ class SassExtensionsTest < Test::Unit::TestCase
} }
end 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 protected
def evaluate(value) def evaluate(value)
Sass::Script::Parser.parse(value, 0, 0).perform(Sass::Environment.new).to_s Sass::Script::Parser.parse(value, 0, 0).perform(Sass::Environment.new).to_s