4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/prez/sass_extensions.rb', line 4
def twbs_font_path(path)
assert_type path, :String
path = path.value.sub /[?#].*/, ""
contents = Prez::Files.contents path, "font"
extension = path[/\.([^.]*)$/, 1]
case extension
when "eot"
font_type = "application/vnd.ms-fontobject"
when "svg"
font_type = "image/svg+xml"
when "ttf"
font_type = "font/ttf"
when "woff"
font_type = "application/font-woff"
when "woff2"
font_type = "application/font-woff2"
else
raise Prez::Error.new("Unknown font extension '#{extension}'")
end
Sass::Script::Value::String.new Prez::DataUri.new(font_type, contents).to_s
rescue Prez::Files::MissingError => e
raise Prez::Error.new("Could not find font: '#{path}'")
end
|