I used font-face, and it is not working. I used the following code in internal CSS:
#font-face {
font-family: acme;
src: url(https://s3.ap-south-1.amazonaws.com/mailer-reach-on-time/ACMESecretAgentBB_BoldItal.otf);
}
My html code is below:
<p style="text-align:center; font-family: acme; font-size:28px; color: #4D4B4B;">TYPICAL MEETING ROOM</p>
When I use this in local it works fine, but when upload the fonts to the server and when I get the fonts from the server it won't work. Please anyone give a solution for this.
Retrieving the font from that Amazon S3 URL results in the CORS error below. Note that the null is just there because I'm testing from a stack snippet. In your case, it will most likely be replaced with your domain.
Access to Font at
'https://s3.ap-south-1.amazonaws.com/mailer-reach-on-time/ACMESecretAgentBB_BoldItal.otf'
from origin 'null' has been blocked by CORS policy: No
'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'null' is therefore not allowed access.
To be able to retrieve your font, you need to configure cross-origin resource sharing on your S3 bucket, as described here in the Amazon S3 documentation.
The following configuration allows GET requests to all origins (which might be too liberal, depending on the contents of your bucket):
<CORSConfiguration>
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
</CORSRule>
</CORSConfiguration>
Use this code. It should work perfectly
#font-face {
font-family: 'acme';
src: url('https://s3.ap-south-1.amazonaws.com/mailer-reach-on-time/ACMESecretAgentBB_BoldItal.otf');
}
<p style="text-align:center; font-family: 'acme', arial; font-size:28px; color: #4D4B4B;">TYPICAL MEETING ROOM</p>
Related
I am creating some text in html and I've tried using #fontface, which of course work.
The problem is how could I import fonts from my ftp server. I don't really get what path or something like this should be in url in #fontface
The simplest way is to add your fonts somewhere in the path of your web server (where html pages are located) so your font-face will be something like:
#font-face {
font-family: "Open Sans";
src: url("/path/to/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
url("/path/to/fonts/OpenSans-Regular-webfont.woff") format("woff");
}
Just tried to use a new font, put it in a folder and linked to it, but I am getting this:
GET http://localhost/mywebsite/fonts/garamond/EBGaramond12-Regular.ttf
403 (Forbidden)
I implemented it like so:
#font-face {
font-family: Garamond;
src: url(../fonts/garamond/EBGaramond12-Regular.ttf);
text-rendering: optimizeLegibility;
}
The path is correct, but I'm not sure why I get a 403. I am using XXAMP on OSX, other fonts work fine.
GET http://localhost/mywebsite/fonts/garamond/EBGaramond12-Regular.ttf 403 (Forbidden)
Is a sign for a file permission problem.
You can get the file permissions by ls -l in the terminal. Changing them by chmod to 777 should work. Later on you can change them back to a lower permission for security.
Try by removing the starting double dots and slash in the font path.
Like this:
#font-face {
font-family: Garamond;
src: url(fonts/garamond/EBGaramond12-Regular.ttf);
text-rendering: optimizeLegibility;
}
The ../ needed only if your fonts directory is outside of the project directory or your styles file is located in a subdirectory instead of project root.
On other hands, it might be the mime types issue.
See this help for that: Why is #font-face throwing a 404 error on woff files?
I've published my ASP.NET MVC5 website to my server and noticed the font is incorrect.
On my local host it works as expected. On every HTML page, I have the following in head head tags
<link href='https://fonts.googleapis.com/css?family=Lato:400,300italic,700,300' rel='stylesheet' type='text/css'>
And in my CSS I have
body {
letter-spacing: .05em;
font-weight: 300;
font-size: 1em;
line-height: 1.8em;
font-family: 'Lato', sans-serif;
color: #4f4f4f;
}
A quick search within the project shows this is the only time I use font.
I'm also aware there is no 'back up font', but that is not relevant.
Font looks different when site is server over https didn't help as I'm already using https
When I try the font in typecast I can see that the localhost is rendering the font correctly where as my server is not.
The website is not using SSL
Within Chrome, I open the dev tools and in Network I can see
css?family=Lato:400,300italic,700,300 GET 200 stylesheet MyPage:13 920 B 263 ms
I've also checked the rendered HTML and CSS, and although there is some minification, the syntax looks the same.
Why will this font not render on my web server.
I am trying to use a custom font on my website that I have uploaded in a google drive. The reason I have to take this route is, the particular site is blogger which does not allow me to upload custom font. I have read articles where they had suggested to use pro version of dropbox, but at this moment I am not planning to invest in a pro account. The Code I am trying to use as follows
<!DOCTYPE html>
<html>
<head>
<style>
#font-face {
font-family: keycapsflf1-webfont;
src: url(https://docs.google.com/uc?authuser=0&id=0B80wMxxnziQZQ09hdVFTZWo1NFE&export=download);
}
#font-face {
font-family: keycapsflf1-webfont;
src: url(https://docs.google.com/uc?authuser=0&id=0B80wMxxnziQZQ09hdVFTZWo1NFE&export=download);
font-weight: bold;
}
div {
font-family: keycapsflf1-webfont;
}
</style>
</head>
<body>
<div>Testing</div>
</body>
</html>
But, this does not work. Any idea, what might be wrong?
Its not working because docs.google.com is sending a No 'Access-Control-Allow-Origin' header on the resource.
Here is the error from the console:
"Redirect at origin 'https://docs.google.com' has been blocked from loading by
Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access."
I tried removing the &export=download param on the url https://docs.google.com/uc?authuser=0&id=0B80wMxxnziQZQ09hdVFTZWo1NFE&export=download but this didn't work either so its definitely the resource sharing policy at fault.
edit based on Spencer Wieczorek's feedback
After disabling same origin policy in my chrome as follows the font loaded correctly confirming that the Cross-Origin Resource Sharing policy is the only issue that I'm facing with loading the font: Disable same origin policy in Chrome
See screenshot below:
You can upload custom font to your blog via google sites.
First create a new site by using Google account at http://sites.google.com.
Then create a directory name as "fonts" or whatever you want to choose.
Upload the font and then you will get the url of the font which you upload.
Add the font css source url to blogger header
Eg:
#font-face {
font-family: keycapsflf1-webfont;
src: url(https://sites.google.com/site/yoursitename/fonts/fontname.ttf);
}
I'm having trouble getting a custom, non-websafe font to work in Firefox. I have it working in Chrome, Opera and Safari using the following code:
#import url(http://fonts.googleapis.com/css?family=Antic+Slab);
#font-face {
font-family: 'BadgerFont';
src: url('http://www.vectorthatfox.co.uk/badgerandkingdom/fonts/oratorstd-webfont.eot');
src: url('http://www.vectorthatfox.co.uk/badgerandkingdom/fonts/oratorstd-webfont.eot?#iefix') format('embedded-opentype'),
url('http://www.vectorthatfox.co.uk/badgerandkingdom/fonts/oratorstd-webfont.woff') format('woff'),
url('http://www.vectorthatfox.co.uk/badgerandkingdom/fonts/oratorstd-webfont.ttf') format('truetype'),
url('http://www.vectorthatfox.co.uk/badgerandkingdom/fonts/oratorstd-webfont.svg#orator_stdregular') format('svg');
font-weight: normal;
font-style: normal;
}
body{
font-family: BadgerFont, 'Antic Slab', Serif;
letter-spacing: 1px;
}
What am i missing here?
Heres a link to the site incase you want to see for yourself.
By default, Firefox will only accept relative links. Firefox (which supports #font-face from v3.5) does not allow cross-domain fonts by default. This means the font must be served up from the same domain (and sub-domain) unless you can add an “Access-Control-Allow-Origin” header to the font.
Or, just load the font some other way (locally or with a CDN)
https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS#Access-Control-Allow-Origin
You should learn to use your developer tools in Firefox. Fifth console message is this:
[08:28:41.886] Unrecognized at-rule or error parsing at-rule '#import'. # http://cdn.bigcartel.com/theme_stylesheets/19013562/2771282761/theme.css:474
From MDN:
The #import CSS at-rule allows to import style rules from other style
sheets. These rules must precede all other types of rules, except
#charset rules; as it is not a nested statement, it cannot be used
inside conditional group at-rules.
EDIT
Please look in your console, it gives you all the answers
[11:00:17.697] downloadable font: download failed (font-family: "BadgerFont" style:normal weight:normal stretch:normal src index:1): bad URI or cross-site access not allowed
source: http://www.vectorthatfox.co.uk/badgerandkingdom/fonts/oratorstd-webfont.woff # http://cdn.bigcartel.com/theme_stylesheets/19013568/2771283940/theme.css
As the message says, Firefox will not allow you to embed cross-domain fonts. If you want to use that font, then download them from that website, if you are allowed, and upload them to your own domain and link to them yourself.