I am using Nunito Sans for the English version of a website and saw here: https://localfonts.eu/?s=Nunito+Sans&post_type=product
that there is also a Bulgarian version of the font, which is exactly what I need.
I tried downloading and adding it into my project folder.
#font-face {
font-family: NunitoSans;
src: url('fonts/NunitoSans-Light.ttf');
}
body {
font-family: NunitoSans;
}
Unfortunately that did not have any effect.
Replace the existing source URL with the new URL you created by
uploading each file.
By default, the source URL location is set within the downloaded Web
Font Kit. It needs to be replaced by the location on your server.
Ref:
https://www.pagecloud.com/blog/how-to-add-custom-fonts-to-any-website
Related
A specific font with format .ttf is not loading on the webserver. Its an adobe font called Edwardian Script that ive been using from the adobe typekit.
I have tried to load this font on the live website but it doesn't seem to want to load.
I have tried changing file paths, i have added the format("truetype") as suggested answer in another SO Question but this didn't work either.
I had thought about loading it from google fonts but it costs money here and we already have this font in our libraries.
Ive been emptying caches and retrying on a separate computer.
I might note that it does show in Dreamweaver so I've been using a separate computer to confirm if its corrected.
I feel its a file path issue but i don't seem to be getting the right path.
Its hosted with cPanel in a public_html folder within a folder called fonts
public_html > fonts > Edwardian-Script > Edwardian-Script-ITC.ttf
CSS
#font-face {
font-family: Edwardian Script ITC;
src: url('/fonts/Edwardian-Script/Edwardian-Script-ITC.ttf') format("truetype");
}
.logo-text {
font-family: Edwardian Script ITC;
text-transform: none;
font-weight: 100;
font-kerning: none;
font-stretch: normal;
letter-spacing: normal;
}
HTML
<h3 class="logo-text"> Header Title </h3>
Expected to see loaded font from the server fonts folder
Maybe you need to add MIME Types on your server.
Log in to cPanel.
In the ADVANCED section of the cPanel home screen, click MIME Types
How do I add octicons as font similar to the way atom did it?
Whilst inspecting the atom codebase I discovered that they are using the octicon icon set as font (font-family: 'Octicons Regular' & content: "\f0a4"). How would I implement the set in such a way to my own project? Is there a public release?
The following picture is a screenshot of the atom src showing the styles. (Ctrl+Shift+I)
There are no available CDNs for Octicons Regular so you have to get your own WebFontkit. Then you have to add the fonts using #font-face parameter.
Follow the below steps to add custom fonts to your HTML:-
1. Download the Octicons font:- The Octicons Regular fonts are available in this link. Download the TrueType Font file format (.ttf).
2. Create a WebFont Kit:- Upload the downloaded (.ttf) file to WebFontkit Generator.. Then download the optimal WebFontkit.
3. Extract and Upload the font files to your hosted site:- Edit the stylesheet.css file to update the url. For instance if you have url like, www.example.com. So your .css file after update woluld look like:-
#font-face {
font-family: "Octicons";
src: url("https://example.com/css/fonts/Octicons.woff") format("woff"),
url("https://example.com/css/fonts/Octicons.woff2") format("woff2")
}
4. Use Octicons font in your CSS declarations:- As you have added css fonts to your site you can use this in your CSS declarations. For e.g,
p {
font-family: Octicons;
font-weight:normal;
font-style:normal;
}
I have never used a custom font before and have been trying to add it into my application. I have downloaded this font onto my computer and have made a separate file called 'Font' and in that i have put the font file.
I went into my CSS and have wrote this code:
#font-face {
font-family:'Open Sans';
src: url('../Font/OpenSans-Light.ttf');
}
The font isn't working at all and I'm wondering why it is not working?
Any ideas?
I am applying it to different sections, I should of said:
.title {
font-family: 'Open Sans';
font-size: 25px;
margin: 0 auto;
color: #52a3cc;
text-align: center;
}
I get this error message in IE Developer Tools:
"#font-face failed OpenType embedding permission check. Permission must be Installable."
You code should work if you can download http://www.yoursite.com/CorrectPath/OpenSans-Light.ttf in a browser.
If you cannot download it, you need to add at MIME types like SethG suggested.
Other thought
Open Sans is available via Google Fonts, so you do not have to host it by yourself.
I've had issues with this in the past. If you're using IIS Express to test this, you might have issues. For some reason, when IIS doesn't have a MIME type with which to serve content, it won't serve it. Make sure that whatever version of IIS you're using, be it IIS Express or IIS, has a MIME type for .ttf files.
I'm currently developing a browser extension for Chrome and Safari. To be more specific, a tooltip appears when the user hovers over certain keywords. Currently, i'm using #font-face with a link to certain fonts hosted on my website. The problem is - they take a long time to load. Is it possible to include fonts locally in the browser extensions instead of linking to them externally? Can you just package the fonts (or even images?) with the other extension files?
Yes you can, it is quite common. Just make sure you have permissions to distribute all fonts/images that you did not author. Owning a personal license doesn't count.
Every extension is saved locally, whether the code that makes it function requires internet access and server-side scripting or not. A Chrome extension is just a directory saved as a crx archive, which is literally a renamed zip file. The directory, along with the necessary Developer info and metadata, is just like that of any other site, with html, and css, javascript, fonts, images, etc. Obviously if your extension does use server-side scripts, those need to be hosted. I'm sure you know most of this if you are building extensions, but I am elaborating so beginners can follow along.
Generally speaking, fonts are tiny files (rarely over 200k unless they are grunge type, or you are embedding way more characters than necessary) and so if they are self-hosted and taking too long to load, the problem is likely with your host. If I were you, I would use Google Fonts which don't need to be self-hosted and are free.
There are several ways
to embed them, no matter which you option you choose. But here is an example of how to link to fonts stored locally within the .crx file, <style> tags go between the <head> tags:
<style>
#font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans'), local('OpenSans'), url("fonts/OpenSans-Regular-webfont.woff") format("woff");
}
#font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
src: local('Open Sans Italic'), local('OpenSans-Italic'), url("fonts/OpenSans-Italic-webfont.woff") format("woff");
}
</style>
Obviously, all paths are relative to the html file in your crx directory.
I want to use a font collection from Google Fonts directory. I selected the styles and include the CSS link tag in my project's template.
Alternatively, with Google Fonts you can also download the collection, and what you get is a zip file with all the font's styles.
I can create a CSS equivalent of the one Google gives me to include in the HTML, so I want to provide the self hosted font files as fallback, if the visitor can't access the Google Font API.
How do I setup this, and preventing both the Google font file and the self hosted font file from being downloaded? If the user does has access to Google Fonts, it's browser shouldn't download the self hosted version of the font.
I would recommend just self hosting them. This is fontsprings' "bullet-proof" font-face syntax.
#font-face {
font-family: 'MyFontFamily';
src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'),
url('myfont-webfont.woff') format('woff'),
url('myfont-webfont.ttf') format('truetype'),
url('myfont-webfont.svg#svgFontName') format('svg');
}
Having all four of these set will ensure that it works across browsers. Just make sure to have your font in all four types. Font Squirrel has great kits for fontface as well.
You have 3 options:
Use 2 sets of #font-face at-rules, using different font-family names (e.g. "Droid Sans" and "Droid Sans Local"), and then using a font stack like "Droid Sans", "Droid Sans Local", Helvetica, Arial, sans-serif. However, this will cause both fonts to be downloaded, increasing load time.
Use a single set of #font-face at-rules, but use 2 sets of src attributes. This too may increase loading time if the browser decides to download all the font files specified.
Do mirroring at the network layer via DNS, like most CDNs do. This requires network setup, but your CSS would be unchanged, and it's most transparent to the browser, requiring no extra downloads.
Google Web Fonts is already employing the 3rd option, so I personally wouldn't bother if you're already using a CDN-hosted source. But it may be worthwhile if you're using fonts from a less reliable source. But if you're going to go through the effort to set this up for your fonts, why not set it up for all of your static resources (images, stylesheets, JS, etc.)? The most logical course of action is to just get a free or paid CDN to host all of your static assets on.