In Less, it seems almost impossible to use @font-face
selector. Less gives errors when I try to use
font-family: my_font
Here is how I try to use it:
@font-face {
font-family: my_font;
src: url('http://contest-bg.net/lg.ttf');
}
p {
font-family: my_font, "Lucida Grande", sans-serif;
}
There is simple escape in Less using ~"..."
but can't come up with working code.
Had someone used it successfully?
I think it's because you are missing the font format. Which for
ttf
istruetype
, if it's missing or incorrect the font might not be loaded.Have you tried putting the font family name in single quotes? The following works just fine for me.
To use font as a mixin, try:
then within a style declaration:
One other note to the voted answer above; make sure that your mixin does not have parenthesis so that it is parsed when compiled into CSS.
Full Example:
** In Your Variables LESS File:**
// Declare the path to your fonts that you can change in the variables less file
** In Your Mixins LESS File:**
** In Your Nested Rules LESS File:**
Note: That the ".font-names" definition does not have the () behind it.