How to install fonts (.ttf) on CentOS 6 web server?

General support questions
Post Reply
suaswe
Posts: 6
Joined: 2012/02/21 17:19:32

How to install fonts (.ttf) on CentOS 6 web server?

Post by suaswe » 2012/10/07 18:45:09

Hi all,

I'm not sure if I'm gonna come across like a complete pleb here, but I've server on which I run a couple of websites, and I have been unable to figure out how to install/add a font (specifically [url=http://www.fontspace.com/typesetit/great-vibes]GreatVibes[/url]) without installing the complete X server. Is this possible? All I want is to have this font available to use and display on my website. Various websites advise to mkdir /usr/share/fonts/TTF and add the font in there, then do a 'service xfs reload', but XFS seems to be tied to the X server package which I haven't got.

Cheers!

SuaSwe

CrayXMP
Posts: 15
Joined: 2009/04/02 16:51:28
Location: France

How to install fonts (.ttf) on CentOS 6 web server?

Post by CrayXMP » 2012/10/07 19:19:14

Some may have a better way to do it, but this is the only one I know ...

Install the fontconfig package (no X deps).
According to man fc-cache :
"fc-cache scans the font directories on the system and builds font information cache files for applications using fontconfig for their font handling."

Create any subdir for your fonts in /usr/share/fonts (not mandatory but useful)
System-wide : # mkdir -p /usr/share/fonts/greatvibes
User only : mkdir ~/.fonts

Copy your font files in the appropriate folder and "register" them in the system with :
# fc-cache -f -v

Hope it helped. :-D

suaswe
Posts: 6
Joined: 2012/02/21 17:19:32

Re: How to install fonts (.ttf) on CentOS 6 web server?

Post by suaswe » 2012/10/07 19:48:42

That is exactly what I need, thanks! :D

I'm still not able to get it to work after running the fc-cache command as suggested though, maybe you can advise further? This is what I've got in my stylesheet:

[code]
@font-face {
font-family: 'GreatVibes-Regular';
src: url('/usr/share/fonts/TTF/GreatVibes-Regular.ttf');
}

h1, h2, h3, h4, h5, h6 {
color: #fff;
font-family: 'GreatVibes-Regular';
}
[/code]

This just displays the default font. Any ideas/suggestions would be most appreciated!

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to install fonts (.ttf) on CentOS 6 web server?

Post by TrevorH » 2012/10/07 20:06:05

I many be completely wrong here but surely the presence or absence of the font on the [u]web server[/u] has nothing to do with whether the web [u]browser[/u] can display it or not. That's down to whether or not the client computer has the font installed - all the web server does is send it the css file that tells the browser to display the output in the font you choose.

CrayXMP
Posts: 15
Joined: 2009/04/02 16:51:28
Location: France

Re: How to install fonts (.ttf) on CentOS 6 web server?

Post by CrayXMP » 2012/10/07 20:48:56

This may be font embedding !
Get your "@font-face" CSS script to embed your font in at [url=http://www.fontsquirrel.com/fontface/generator]Create Your Own @font-face Kits | Font Squirrel[/url]
Upload your font and download the webfontkit to use on your webserver.
Your TTF will be "translated" into various file formats for several browsers.

Post Reply