Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

roboto font not working in css

I've CSS and XHTML files. I've downloaded all the ROBOTO fonts and put it in my "webapps/fonts/" folder.

In my XHTML i mentioned the CSS Path,

'<link href="../css/tab_ux.css" rel="stylesheet" type="text/css" />'

AND my CSS file have styles like,

@font-face {
   font-family:roboto-bold;
   src: url('../fonts/Roboto-Bold.tff') @ttf;
}

.UX_FontClass {
   font-family: roboto-bolditalic !important;
   font-size : 25px !important;
}

also mentioned XHTML in OutputText as styleClass="UX_FontClass "

Even though font is not working in any browser. What i did wrong with my code? OR Anything i missed out?

like image 934
user3114967 Avatar asked May 06 '15 10:05

user3114967


2 Answers

You should use google fonts, its really easy to use.

https://www.google.com/fonts#UsePlace:use/Collection:Robot

example

<head>
 <link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
</head>
<body>
<p style="font-family: 'Roboto', sans-serif;">Hello World</p>
</body>
like image 63
r33drum Avatar answered Sep 25 '22 05:09

r33drum


You are using custom font so you need to add a few font type format as well; like ttf, eot and svg for iphone, ipad devices.

Note: Some browsers supports different font type that's why you need ttf,svg or eot.

@font-face {
    font-family: 'Roboto';
    src: url('Roboto-ThinItalic-webfont.eot');
    src: url('Roboto-ThinItalic-webfont.eot?#iefix') format('embedded-opentype'),
         url('Roboto-ThinItalic-webfont.woff') format('woff'),
         url('Roboto-ThinItalic-webfont.ttf') format('truetype'),
         url('Roboto-ThinItalic-webfont.svg#RobotoThinItalic') format('svg'); (under the Apache Software License). 
    font-weight: 200;
    font-style: italic;
}

Remember after that you need to add this code in class UX_FontClass

.UX_FontClass {font-family: 'Roboto', Arial, Helevtica, sans-serif; }
like image 26
Kheema Pandey Avatar answered Sep 25 '22 05:09

Kheema Pandey