#font-face working in localhost not in live server - html

I am using a font for my site which is stored under my project folder as fonts
and i used this code in css.
my css
#font-face
{
font-family: buddys;
src: url('/fonts/Kristen-ITC-Regular.ttf'),
url('/fonts/Kristen-ITC-Regular.eot'); /* IE9 */
}
its working on localhost while its uploaded to live the font style not apply on my site. How to make it work on live site.
Thanks.

As you're using Visual Studio, you need to set the Build Action for each of your webfonts to 'Content' under properties. If you don't do this, your font files do not get included in the deployment package and never make it to your server.
Also, I would suggest improving your #font-face code in your CSS to include all formats (you can use font squirrel to help with this: http://www.fontsquirrel.com/fontface/generator). Also worth a read is this article on the most compatible code to use: http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/

Are you sure the actual font is uploaded to your webserver and the path is correct?
I'd suggest specifying all of the image files:
#font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff') format('woff'), /* Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
To generate them all from the font-face file, just use a tool like this

Your font path is absolute. Check it.

If your css file is in the folder named: 'css' and fonts dir and css dir is in the same folder named 'assets'.
Then:I think your css code should be:
#font-face
{
font-family: buddys;
src: url('../fonts/Kristen-ITC-Regular.ttf'),
url('../fonts/Kristen-ITC-Regular.eot'); /* IE9 */
}

Related

Can you embed a font in HTML without linking to an external source? [duplicate]

This question already has answers here:
Downloading a Google font and setting up an offline site that uses it
(12 answers)
Converting and rendering web fonts to base64 - keep original look
(3 answers)
Closed 4 years ago.
I need to use a font in an HTML page but I also need it to work offline, when I have the project on my PC without internet connection. Since I can download the .ttf file from Google Fonts, is there a way to actually include the font without importing it from fonts.googleapis.com?
I believe you can include the font on your server/ local storage and use a local link, instead of the url.
#font-face{
font-family: /*name here*/
font-style: normal
font-weight: 250
src: url('') /* replace with local link/ format*/
}
See: https://www.w3schools.com/cssref/css3_pr_font-face_rule.asp for more detail
You can certainly do that. Use the #font-face in your .css file
#font-face {
font-family: 'FontName';
src: url('FontName.eot'); /* IE9 Compat Modes */
src: url('FontName.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('FontName.woff2') format('woff2'), /* Super Modern Browsers */
url('FontName.woff') format('woff'), /* Pretty Modern Browsers */
url('FontName.ttf') format('truetype'), /* Safari, Android, iOS */
url('FontName.svg#svgFontName') format('svg'); /* Legacy iOS */
}
the URL would be specified accordingly, depending on what folder you have the font in, relative to the CSS file.

What is better for using a custom font for my website?

I'm using a font called "DejaVu Sans" that does not exist in google fonts
body{
font-family:'DejaVu Sans' , tahoma;
}
I uploaded the font with different extensions to my website but it takes time to execute on the text on my website, I think it waits for the whole website to load first.
Is it better to upload the font files to a CDN or a files cloud and then use it on my website, or there is a better way?
you should use font face like this :
#font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff2') format('woff2'), /* Super Modern Browsers */
url('webfont.woff') format('woff'), /* Pretty Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
then you can use the font wherever you want
The font load time depends on the font file size. You can use font face kit provided by font-squirrel : https://www.fontsquirrel.com/fonts/dejavu-sans
To improve loading time you can wisely choose the required font formats to bind with your website font face.
To get more information about loading time you can refer below link, which will helps a lot.
https://www.smashingmagazine.com/2011/03/the-font-face-rule-revisited-and-useful-tricks/
use #font-face instead.
Upload your .ttf files and convert them to .woff, .woof2 etc that is needed for font face.
Here is the link for standard #font-face example :
#font-face
Use online converter here: webfont converter

Angular 2 Font to server

I have a problem with the font on the server. Localhost works, but the server has a different directory and does not read. With Logo is the same.
#font-face
font-family: BankGothic;
src: url('/assets/fonts/BankGothic.eot'); /* IE9 Compat Modes */
src: url('/assets/fonts/BankGothic.woff') format("woff"), /* Pretty Modern Browsers */
url('/assets/fonts/BankGothic.ttf') format('truetype'); /* Safari, Android, iOS */
The logo is made as a component
Is it possible to integrate this font and logo?
Try using absolute path for linking your font.
e.g
#font-face
font-family: BankGothic;
src: url('http://www.example.com/assets/fonts/BankGothic.eot'); /* IE9 Compat Modes */
src: url('http://www.example.com/assets/fonts/BankGothic.woff') format("woff"), /* Pretty Modern Browsers */
url('http://www.example.com/assets/fonts/BankGothic.ttf') format('truetype'); /* Safari, Android, iOS */
Maybe it helps you out. But if it's working on your localhost than it should be working on your server also. Unless and until you are following different directory structure on server. But this is obvious that your issue is regarding src path
I thought maybe something with
environment.apiUrl
But I do not know if it has the right to do it

Cusom font with CSS - ONLY works with Internet Explorer

I am making a website for a friend of mine. He is very specific about the font on the page.
I have downloaded a custom font from the Internet, but the weird thing; it's only working in Internet Explorer (what a suprise).
This is my code:
#font-face
{
font-family: eurostile;
src: url(../font/eurostile.ttf);
}
#font-face
{
font-family: eurostile;
src: url(../font/eurostile.eot);
}
And this is how I am calling the font-family:
p
{
font-family: eurostile;
}
etc... What am I doing wrong?
You'll need to format it in a cross platform style. Look here.
The problem is that different browsers support different font styles.
Something like:
#font-face {
font-family: 'fontMN';
src: url('/fonts/font_font-webfont.eot'); /* IE9 Compat Modes */
src: url('/fonts/font_font-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('/fonts/font_font-webfont.woff') format('woff'), /* Modern Browsers */
url('/fonts/font_font-webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('/fonts/font_font-webfont.svg#fontMN') format('svg'); /* Legacy iOS */
}
Would work.
You will need to acquire the formats that are valid for the browsers you're looking to support, as seen above.
Browser use different formats. IE uses the eot format, most use woff, but some use svg or ttf/otf.
Check this out:
http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax
You can create all these fonts by uploading a ttf/otf to fontsquirrel and using it's converter:
http://www.fontsquirrel.com/tools/webfont-generator
http://jasonlau.biz/home/css/embedding-custom-fonts-with-css
If you ever need to embed custom fonts in your website, this bit of CSS will accomplish the task. Follow the steps below to embed custom fonts in your website.
Use this tool to generate the font-face rule - http://www.fontsquirrel.com/tools/webfont-generator.

Change Website font style

I m using one of the Font for my website i.e. "Aparajita". Which is not required to be available in every system through which my site is getting accessed.
My problem is it look's different when this font is installed on the browsing PC and some horrible when the same font is not getting installed.
How should i resolve this issue.
Should i install "Aparajita" Font on my hosting Server or what else...
Thanks in advance..
Make sure you have legal rights to the font.
Make the font available on your web server (i.e. put it in a directory from which it can be served in response to an HTTP request, the same way you would an image or stylesheet).
Reference it in your CSS using #font-face.
See: https://developer.mozilla.org/en-US/docs/CSS/#font-face
Font Squirrel has many free fonts and font-related tools. Google Fonts abstracts the whole process is makes it quite easy.
Now that you (hopefully) know what terms to search for, you can find many examples on SO of using custom fonts.
You can use CSS3 #font-face property for use custom font in your website and with the help of this your font will look same on all computers wheather they have insallted that font or not....
You can write like this :-
#font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff') format('woff'), /* Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
Or Read More About how to use custom fonts for our websites.....
<font face="Your font_family">
Here it is for font style.
<FONT SIZE=7 COLOR=RED>word</FONT></U></B>