function sassy_compass__inline_font_files in Sassy 7.2
Same name and namespace in other branches
- 7.3 sassy_compass/functions/inline_image.inc \sassy_compass__inline_font_files()
File
- extensions/
compass/ functions/ inline_image.inc, line 14
Code
function sassy_compass__inline_font_files($file) {
$args = func_get_args();
$files = array();
$mimes = array(
'otf' => 'font.opentype',
'ttf' => 'font.truetype',
'woff' => 'font.woff',
'off' => 'font.openfont',
);
while (count($args)) {
$path = sassy_compass__resolve_path(array_shift($args));
$data = base64_encode(file_get_contents($path));
$format = array_shift($args);
$ext = array_pop(explode('.', $file));
if (isset($mimes[$ext])) {
$mime = $mimes[$ext];
}
else {
continue;
}
$files[] = "url('data:{$mime};base64,{$data}') format('{$format}')";
}
return new SassString(implode(', ', $files));
}