Open hashworks opened 9 years ago
The url-functions issue already exists, see #20.
Does it explain why my font-face mixin didn't get compiled at all?
Propably not. In my case they came out fine, but with font-url and font-files in them.
These haven't been implemented yet, I've added them to the migration issue
Is this project abandoned? Seems weird to implement the font-face mixin and not implement the font-files mixin.
My workaround (by using compass with yeoman webapp) was to create this function:
@function font-url($path) { @return url('#{$path}'); }
And this one:
@function font-files($font-name, $path, $formats...) {
$full: '';
@for $i from 1 through length($formats) {
$full: $full + 'url("#{$path}.' + nth($formats,$i);
@if nth($formats,$i) == 'ttf' {
$full: $full + '") format("' + 'truetype")'
}@else if nth($formats,$i) == 'svg' {
$full: $full + '#' + $font-name + '") format("' + nth($formats,$i) + '")';
}@else {
$full: $full + '") format("' + nth($formats,$i) + '")';
}
@if $i!=length($formats) { $full: $full + ', ';}
}
@return unquote($full);
}
@SergiArias thanks for add helper funtions.
however font-files
function must fix $font-name
on:
$full: $full + 'url("#{$path}.' + nth($formats,$i);
so for use compass font-face
mixin:
fonts.scss
file:
@function font-url($path) {
@return url('#{$path}');
}
@function font-files($font-name, $path, $formats...) {
$full: '';
@for $i from 1 through length($formats) {
$full: $full + 'url("#{$path}/#{$font-name}.' + nth($formats,$i);
@if nth($formats,$i) == 'ttf' {
$full: $full + '") format("truetype")';
}@else if nth($formats,$i) == 'svg' {
$full: $full + '#' + $font-name + '") format("svg")';
}@else {
$full: $full + '") format("' + nth($formats,$i) + '")';
}
@if $i!=length($formats) { $full: $full + ', ';}
}
@return unquote($full);
}
$font-path: "/public/fonts/roboto";
@include font-face('Roboto',
font_files(roboto,$font-path,ttf,woff,woff2,svg), '#{$font-path}/roboto.eot',
normal,
normal
);
The regarded ruby sources are font_files.rb and urls.rb.