Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble with @font-face and .ttf file

I'm trying to use @font-face to implement a font I downloaded online (http://www.losttype.com/font/?name=blanch) and I'm having issues getting it to work on any browser. Here's the sample code I'm using to test the font.

<html>
<head>
    <link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
    <div class = "title">
        <p>THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG</p>
    </div>
</body>
</html>

And the css file is:

@font-face {
    font-family: Blanch;
    src: url(‘BLANCH_CONDENSED.ttf’);
}
.title {
    text-align:center;
    font-family: Blanch, 'Helvetica Neue', Arial, Helvetica, sans-serif;
    color:white;
    text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}

I only have the .ttf file. Can someone explain why this isn't working?

like image 880
Cilantro Ditrek Avatar asked May 24 '13 19:05

Cilantro Ditrek


People also ask

Does TTF work on all browsers?

TrueType Font (TTF) TTF has long been the most common format for fonts on Mac and Windows operating systems. All major browsers have supported it.

Does TTF work on Chrome?

TTF/OTF - TrueType and OpenType font support is Fully Supported on Google Chrome 71. If you use TTF/OTF - TrueType and OpenType font support on your website or web app, you can double-check that by testing your website's URL on Google Chrome 71 with LambdaTest. The features should work fine.


1 Answers

In the construct url(‘BLANCH_CONDENSED.ttf’), the ‘smart’ single quotes must be replaced by Ascii quotes (single or double), e.g. url('BLANCH_CONDENSED.ttf').

You should also use FontSquirrel webfont generator or some similar tool to generate different font formats to cover all browsers.

like image 63
Jukka K. Korpela Avatar answered Sep 20 '22 08:09

Jukka K. Korpela