Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Font Face, only download when font is non existent

I've included a custom font on my website (Segoe UI), however the font file are around 1mb, which takes a few seconds to load the first time.

I'm on a Mac, and the font is not shipped with OSX. However, as far as my knowledge goes, it's included with Windows.

How can I make CSS only load the font if it's not already existing on the client?

like image 512
Patrick Reck Avatar asked Jan 22 '13 10:01

Patrick Reck


People also ask

How do I use a downloaded OTF font in CSS?

Add a font-face section to your CSS code src: url('fonts/lovely_font. otf') format('opentype'); src: url('fonts/lovely_font. ttf') format('truetype'); As another optional efficiency measure, we can get the browser to check for a local copy of the font in case the user already has it.

How do I use non standard fonts in CSS?

The only way to ensure a non-standard font is displayed correctly is to embed the font into the . css (see Non-Standard Fonts below). The table below lists fonts that are standard to Windows and Mac systems along with the fallback font-family name used for other devices.


1 Answers

Using local('Segoe UI') worked out. Seems like it prioritizes the sources from first to last.

Here's the working code

@font-face {
    font-family: Segoe;
    src: local('Segoe UI'), url('fonts/segoeui.ttf') format('truetype'), url('fonts/segoeui.woff') format('woff');
}
like image 82
Patrick Reck Avatar answered Nov 15 '22 16:11

Patrick Reck