I have a basic question that probably refers more to design field, but still it is a web programming.
Let say I need to use Palatino-Linotype font in my web application. How do I better embed it in to my web page application?
My known way:
1) Go to font.com and buy all kinds of palatino-linotype: normal, bold, italic, italic-bold. 4 different files.
2) Then I load fonts via fontface style
#font-face {
font-family: "Palatino-Linotype-normal";
src: "..."
}
#font-face {
font-family: "Palatino-Linotype-italic";
src: "..."
}
3) A I have 4 different fonts, in HTML markup I need explicitly set font of the element to make it bold, or italic, or italic-bold (that what I don't like the most).
Question:
1) is that workflow of using custom web fonts?
2) Maybe there is a way to treat this fonts as usual fonts in term of setting only one font on parent element, and for inner set only style="font-style: italic;" if I want them to be italic.
3) question about performance, does web font rendering speed differs from rendering of usual fonts?
The logical way, generally supported by browsers, is to declare each typeface in a separate rule, as in
#font-face {
font-family: foobar;
src: url("foobar-regular.woff");
}
#font-face {
font-family: foobar;
font-style: italic;
src: url("foobar-italic.woff");
}
and then just declare font-family: foobar and use font-style: italic directly or indirectely via <i>, <em>, and other markup that causes default rendering in italic.
I have simplified the code in an obvious way; naturally you should normally make the font available in different formats, as recognized by browsers.
Services like FontSquirrel generate different code, but it is fairly straightforward to fix the code they produce, or write the code from scratch.
I have intentionally used “foobar” and not “Palatino Linotype”, since the latter is not legally available for use as a downloadable font; at least this is what presume until proven otherwise. (There are many sites on the web that distribute or sell fonts illegally.)
Check out Fontsquirrel http://www.fontsquirrel.com/ it helped me to generate fonts and css:s compatible for multiple browsers.
If you only use Palatino Linotype Normal, and then change it to bold in CSS you won't get the same results as Palatino Linotype Bold. The thing here is that the browser rendering will be used to achieve that and it will suck a lot. I mean, for me and probably for you it will look the same - but not for designers :)
Also there are a lot more to one font than normal, bold and italic. There are light, semi light, black and so on. And designers tend to use those a lot.
So in general, for the first and second question: use different font faces for different styles and no way to use different faces for different styles, another font family indication is needed.
As for the 3rd one: performance is an issue with embedded fonts. But mostly not because of rendering, but because the font files are heavy to download. So be sure to cache them and use only those needed. For example http://www.fontsquirrel.com/ in the previous answer actually by default adds too many files that are all downloaded, so make a little research to know about different formats and what you need to embed.
You use Palatino-Linotype font in your web application use web font from google.
https://developers.google.com/webfonts/docs/webfont_loader
The Web Font Loader is a JavaScript library that gives you more control over font loading than the Google Web Fonts API provides. The Web Font Loader also lets you use multiple web-font providers. It was co-developed by Google and Type kit.
More inforamtion follow this link to my blog:
http://webtemplatesmonster.blogspot.in/2013/02/how-to-use-font-face.html
#font-face { font-family: 'Awesome Font'; src:
url('awesome-font.eot'); /* IE9 Compat Modes */ src:
url('awesome-font.eot?#iefix') format('embedded-opentype'), /*
IE6-IE8 */
url('awesome-font.woff') format('woff'), /* Modern Browsers */
url('awesome-font.ttf') format('truetype'), /* Safari, Android, iOS */
url('awesome-font.svg#svgFontName') format('svg'); /* Legacy iOS */ }
Related
I ask out to the community if anybody has ever had any issues embedding fonts on their website and it being rendered terrible as the outcome? This is the case across all latest browsers not tied to a specific browser...
Tried adding certain css rules to change the fonts weight, style, smoothness etc but doesn't seem to effect the font by any means, any ideas?
You will notice that the letter 'A' is not as it should be but the correct font types are loaded with no issues.
Font can be found here
Screenshots
Embedded font CSS
#font-face {
font-family: 'Linotte Semi Bold';
src: url('/fonts/linotte-semi-bold.eot');
src: url('/fonts/linotte-semi-bold.eot?#iefix') format('embedded-opentype'),
url('/fonts/linotte-semi-bold.woff2') format('woff2'),
url('/fonts/linotte-semi-bold.woff') format('woff'),
url('/fonts/linotte-semi-bold.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
As we speak I've just received confirmation from MyFonts that sometimes fonts are configured slightly different depending on the font used and may need some tweaking to the Hinting settings when downloading a webfont kit.
The following steps fixed the issue regarding the letter 'A' and now displays correctly as expected:
You may want to try downloading a webfont kit configured to use a different Hinting setting.
Simply log into your MyFonts order history at: https://www.myfonts.com/my/orders/kitbuild.html
Select the webfont you would like to use.
Under the 'Hinting' sub-head, select 'Smooth', 'Native', or 'None' (Best was the default). It may take a couple of tries, depending on the font and how it's used.
The custom Webfont Kit Builder will select a CSS script by default. If you would prefer to use JS, simply change this option at the bottom of the page.
Download the new kit and replace the existing webfonts/stylesheet in your server.
Try this, it fixed some of my font appearance in the past, but it's kind of a shot in the dark. That "A" really looks strange, does it look the same if you install the font on your system and use it in photoshop or word or anything else?
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
I was wondering if the San Basic Sans Light SF font be used with CSS? I'm not sure what font family this font belongs too and can't seem to get it to work with CSS. The closest I've got so far is using the sans-serif font family. I was wondering if anyone could guide me on how I could use Basic Sans Light SF in my CSS code.
Thanks, Grant
#follower-alert .text {
text-shadow: 5px 0px 5px black;
font-family: sans-serif;
}
The CSS font-family property tells the browser to load a font from the operating system. If the browser can't find the font requested, it tries the next one on the list. It it reaches the end of the list, it uses the browser's default font.
What that means is that, when specifying a specific font using the font-family property, you are simply requesting that the client use that font if the client has that font installed. If you request Helvetica, but the person visiting your site hasn't installed Helvetica, the browser will fall back to the next option.
There are a few keywords that don't specify a specific font, but rather tell the browser to load which ever font it thinks best fits the category. Most browsers load the operating system's default for the specified category. Those keywords (called generic family names) are as follows:
serif - any fairly neutral font that has serifs.
sans-serif - any fairly neutral font that does not have serifs.
monospace - any font in which all characters are the same width.
cursive - any font which simulates handwriting (this is loosely defined).
fantasy - any decorative font with artistic flourishes (this is loosely defined).
Outside of the generic family names, you can specify a specific font in quotes. If you have a font installed on your computer called "Basic Sans Light SF", you can use the following CSS property:
font-family: "Basic Sans Light SF", sans-serif;
On your computer (and any other computer that has the Basic Sans Light SF font installed), the text will be displayed in that font. On a computer that doesn't have the font installed, some other sans-serif font will be used installed (whatever the OS default is).
You can get around this limitation using a CSS technique called #font-face to embed a web font in your page.
Embedding fonts in your page slows down load times but increases consistency. Because web fonts are a new technology, there are competing file formats which have different levels of support on different devices. For full coverage, the font you use should be optimized for the web, and you should include multiple formats of the same font on your server. You also need to be sure the font you are using is open source or is licensed to you for use on the web.
Google Fonts offers a large repository of open-source web-ready fonts, hosted through fast CDNs and easily embeddable in any webpage. You may consider using a font available through this service.
If you have a web-ready and licensed font, you can host it on your own web server and use the #font-face property manually. Assuming your font files are in a subfolder named "fonts", an example (from CSS Tricks) is below. This includes all the file formats needed for the maximum possible level of browser coverage. This page goes into great detail about the different types of web-font file formats available and the advantages / disadvantages of each.
#font-face {
font-family: 'Basic Sans Light SF';
src: url('fonts/BasicSansLightSF.eot'); /* IE9 Compat Modes */
src: url('fonts/BasicSansLightSF.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('fonts/BasicSansLightSF.woff2') format('woff2'), /* Super Modern Browsers */
url('fonts/BasicSansLightSF.woff') format('woff'), /* Pretty Modern Browsers */
url('fonts/BasicSansLightSF.ttf') format('truetype'), /* Safari, Android, iOS */
url('fonts/BasicSansLightSF.svg#basicSansLightSF') format('svg'); /* Legacy iOS */
}
I've had this problem in a lot of different webs. You have a font which has different anti-aliasing options, the designer uses the same font with different anti-aliasing options on different parts of the text on the web. So there is a difference between some elements.
In this case I have sharp, crisp, strong and smooth. I've used a font generator to get the code to access it via #font-face. Even so, I also have the original .otf if important to know. Is there a method to access this?
I upload a picture of what I mean and my actual code:
#font-face {
font-family: 'light';
src: url('../_fnt/light/gothamrnd-light.eot');
src: url('../_fnt/light/gothamrnd-light.eot?#iefix') format('embedded-opentype'),
url('../_fnt/light/gothamrnd-light.woff') format('woff'),
url('../_fnt/light/gothamrnd-light.ttf') format('truetype'),
url('../_fnt/light/gothamrnd-light.svg#../_fnt/light/gothamrnd-light') format('svg');
font-weight: normal;
font-style: normal;
}
No, there is no way to control the rendering of text in that way. Those are Photoshop specific settings as it has its own rendering engine, they aren't even available to other programs.
Actually, different browsers will render the text in different ways, and even the same browser on different computers will render it differently depending on the system settings.
If you make the page look exactly like the design in one browser, it will look rather different in another browser. You should normally test it in different browsers and try to make it look as close as possible to the design in most of them, and make sure that it's not too far from the design in any of them.
Only WebKit browsers on Mac OS X have recognized a CSS property related to font smoothing, namely -webkit-font-smoothing. Even there, it’s unclear what’s happening, as they seem to be removing the antialiazed value, see webkit-font-smoothing: suddenly different results in chrome and safari
So for practical purposes, regard font smoothing as being out of your hands as an author, and test your fonts under different smoothing options to check that the results are at least tolerable.
I've seen some new websites that are using custom fonts on their sites (other than the regular Arial, Tahoma, etc.).
And they support a nice amount of browsers.
How does one do that? While also preventing people from having free access to download the font, if possible.
Generically, you can use a custom font using #font-face in your CSS. Here's a very basic example:
#font-face {
font-family: 'YourFontName'; /*a name to be used later*/
src: url('http://domain.example/fonts/font.ttf'); /*URL to font*/
}
Then, trivially, to use the font on a specific element:
.classname {
font-family: 'YourFontName';
}
(.classname is your selector).
Note that certain font-formats don't work on all browsers; you can use fontsquirrel.com's generator to avoid too much effort converting.
You can find a nice set of free web-fonts provided by Google Fonts (also has auto-generated CSS #font-face rules, so you don't have to write your own).
while also preventing people from having free access to download the font, if possible
Nope, it isn't possible to style your text with a custom font embedded via CSS, while preventing people from downloading it. You need to use images, Flash, or the HTML5 Canvas, all of which aren't very practical.
To make sure that your font is cross-browser compatible, make sure that you use this syntax:
#font-face {
font-family: 'Comfortaa Regular';
src: url('Comfortaa.eot');
src: local('Comfortaa Regular'),
local('Comfortaa'),
url('Comfortaa.ttf') format('truetype'),
url('Comfortaa.svg#font') format('svg');
}
Taken from here.
You have to download the font file and load it in your CSS.
F.e. I'm using the Yanone Kaffeesatz font in my Web Application.
I load and use it via
#font-face {
font-family: "Yanone Kaffeesatz";
src: url("../fonts/YanoneKaffeesatz-Regular.ttf");
}
in my stylesheet.
Today there are four font container formats in use on the web: EOT, TTF, WOFF,andWOFF2.
Unfortunately, despite the wide range of choices, there isn't a single universal format that works across all old and new browsers:
EOT is IE only,
TTF has partial IE support,
WOFF enjoys the widest support but is not available in some older browsers
WOFF 2.0 support is a work in progress for many browsers.
If you want your web app to have the same font across all browsers then you might want to provide all 4 font type in CSS
#font-face {
font-family: 'besom'; !important
src: url('fonts/besom/besom.eot');
src: url('fonts/besom/besom.eot?#iefix') format('embedded-opentype'),
url('fonts/besom/besom.woff2') format('woff2'),
url('fonts/besom/besom.woff') format('woff'),
url('fonts/besom/besom.ttf') format('truetype'),
url('fonts/besom/besom.svg#besom_2regular') format('svg');
font-weight: normal;
font-style: normal;
}
If you dont find any fonts that you like from Google.com/webfonts or fontsquirrel.com you can always make your own web font with a font you made.
here's a nice tutorial: Make your own font face web font kit
Although im not sure about preventing someone from downloading your font.
Hope this helps,
there's also an interesting tool called CUFON. There's a demonstration of how to use it in this blog
It's really simple and interesting. Also, it doesn't allow people to ctrl+c/ctrl+v the generated content.
I am working on Win 8, use this code. It works for IE and FF, Opera, etc.
What I understood are : woff font is light et common on Google fonts.
Go here to convert your ttf font to woff before.
#font-face
{
font-family:'Open Sans';
src:url('OpenSans-Regular.woff');
}
First of all, you can't prevent people from downloading fonts except if it is yours and that usually takes months.
And it makes no sense to prevent people from using fonts.
A lot of fonts that you see on websites can be found on free platforms like the one I mentioned below.
But if you want to implement a font into your website read this:
There is a pretty simple and free way to implement fonts into your website.
I would recommend Google fonts because it is free and easy to use.
For example, I'll use the Bangers font from Google.(https://fonts.google.com/specimen/Bangers?query=bangers&sidebar.open&selection.family=Bangers)
This is how it would look like:
HTML
<head>
<link href="https://fonts.googleapis.com/css2?family=Bangers&display=swap" rel="stylesheet">
</head>
CSS
body {
font-family: 'Bangers', cursive;
}
I'm developing a website for someone but they want (insist) that the title be in a non-standard font. (The customer is always right.) I have the TrueType (.ttf) font but how do I bundle this with the website so that it uses it?
I tried putting it in the Images folder and tried to access it with the style sheet:
font-family:URL(Images/Arial_Rounded_MT_Bold.ttf)
But that didn't work. How do I include a non-standard font in a way which will render?
In case it's useful, this is an ASP.NET 2.0 site.
There is currently no standard way to do this. You could use #font-face, but it's not supported in all browsers. As Lance mentioned, this is a great place to find a support reference for the major browsers.
There is an effort to standardize this type of thing. The Web Open Font Format (WOFF) is such an effort. It looks like this may even be adopted by the major browsers in the future. We will have to wait and see.
For now, the best you can do is to reference your font like you normally would, but add a default (standard) font after that.
font-family: "Arial Rounded MT Bold", "Times New Roman", Serif
You have two options:
Create an image instead of using text
Use sifr to convert your text to the .ttf font
You have lots of options, none of them perfect. Smashing Magazine has a great article about rich fonts - most of them involve flash / image replacement.
http://www.smashingmagazine.com/2009/10/22/rich-typography-on-the-web-techniques-and-tools/
Convert your TrueType font into an Embedded OpenType font (it's easy!) so that you have two font files:
Arial_Rounded_MT_Bold.ttf
Arial_Rounded_MT_Bold.eot
Then make your CSS look like this:
#font-face {
font-family: 'Arial Rounded Bold';
src: url('Arial_Rounded_MT_Bold.eot');
}
#font-face {
font-family: 'Arial Rounded Bold';
src: url('Arial_Rounded_MT_Bold.ttf') format('truetype');
}
h1.title {
font-family: 'Arial Rounded Bold', serif;
}
Thanks to Internet Explorer, the EOT specification needs to be first, in a separate #font-face block and without the format attribute. More info here.
Enjoy!
There is a fair amount of activity on the subject of distributing fonts along with websites, but it's generally in the experimental stage, and won't work for the vast majority of browsers in use. In a few years you may be able to do this, but for the moment you would have to use an image or sIFR.