使用 Less,我将字体系列定义如下:
@georgia: georgia, times, 'times new roman', 'nimbus roman no9 l', serif;
然后我有了 less mixin:
.font(@family: arial, @size: 1.0em, @lineheight: 1.0, @weight: normal, @style: normal, @variant: normal) {
font: @style @variant @weight @size~"/"@lineheight @family;
} // font
最后我像这样使用它:
p {
.font(@georgia, 1.0em, 1.5)
}
但我也想用自定义字体来定义字体系列:
@something: 'custom-font', arial, ...;
但是首先我需要注册自定义字体:
@font-face {
font-family: 'custom-font';
src:url('fonts/custom-font.eot');
src:url('fonts/custom-font.eot?#iefix') format('embedded-opentype'),
url('fonts/custom-font.woff') format('woff'),
url('fonts/custom-font.ttf') format('truetype'),
url('fonts/custom-font.svg#icon') format('svg');
font-weight: normal;
font-style: normal;
}
是否可以创建一个 LESS mixin 用于 @font-face
,这样我就可以传递字体名称和路径并注册字体而不必重复所有这些代码了?
我不确定如何将其与我的字体 mixin 集成...
或者是否有更好的方法来实现这一点...
谢谢, 米格尔