Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using a custom (ttf) font in CSS

I have a mac, and have installed a font called "7 Segment" (it shows up in Font Book). When I use font-family: "7 Segment"; I get Helvetica (or similar) rather than the browser's default font, but it still isn't showing the correct font. The page only needs to be shown on this computer. How would I use the font on this page? Thanks.

like image 447
JJJollyjim Avatar asked Sep 22 '11 09:09

JJJollyjim


People also ask

Can you use custom fonts in CSS?

Nope, it isn't possible to style your text with a custom font embedded via CSS, while preventing people from downloading it. You need to use images, Flash, or the HTML5 Canvas, all of which aren't very practical.


1 Answers

You need to use the css-property font-face to declare your font. Have a look at this fancy site: http://www.font-face.com/

Example:

@font-face {   font-family: MyHelvetica;   src: local("Helvetica Neue Bold"),        local("HelveticaNeue-Bold"),        url(MgOpenModernaBold.ttf);   font-weight: bold; } 

See also: MDN @font-face

like image 170
JNDPNT Avatar answered Sep 29 '22 11:09

JNDPNT