I'm using some Unicode symbols on a webpage I'm making. For purposes of this example, let's say it's this guy: '☺'.
As I understand it, under the correct implementation of CSS, you can set any font you want, and if it runs into a character that is not present in that font, it will start falling back through the font-family backup choices until it finds one that works.
In light of that, I have my font-family set up like this in css:
font-family: Tahoma, Helvetica, "Arial Unicode MS", sans-serif
My rationale is that Tahoma comes bundled with Windows. However, I found out online that only some versions of Windows' bundled Tahoma had Unicode support. Helvetica is a font that is similar to Tahoma for Macs. "Arial Unicode MS" comes bundled with Office 2000 and up and definitely support Unicode. San-serif is the fallback in all cases that should also hopefully support Unicode.
For the most part, this works well. However, as it is wont to do, Internet Explorer seems to be ruining my well-laid plan. I can't figure out what the pattern is, as I'm seeing it on one computer running Vista with IE8, and another on Windows XP with IE7, but it works fine on my development machine with Win7 with IE8/IE7 Tester/IE6 Tester. I have found the claim on some obscure webpages that on old versions of IE, it will only look for the first font that it has, and then use that for everything, even if that font is missing a given symbol, but this doesn't explain why it's happening on Vista/IE8. Thus, my lovely Unicode symbols turn up as boxes to some, but not all IE users.
What's the recommended way to be handling Unicode symbols on the web? Are they just not usable for projects where wide browser compatibility is needed? Should I be looking to include code specifically to handle old IE? Are there any other gotcha situations or platforms I should be worrying about?
Edit: Updated with new information on systems this is failing on.
only some versions of Windows' bundled Tahoma had Unicode support
It's not really “Unicode support”. Tahoma supports Unicode in as much as it has Unicode code point lookup tables. That doesn't mean you get a glyph for every character defined by Unicode... actually almost no font has glyphs for every character.
No version of Tahoma includes a glyph for U+263A White Smiling Face, so your code is a test of font fallback capabilities, something IE (especially IE6) is bad at, compared to other browsers. A more common Windows-bundled font that does include U+26A3 is plain Arial (not “Arial Unicode”), since version 3.00 (included in WinXP).
You can use IE overrides in your CSS file to create different behavior for older versions of internet explorer. The over-rides are # and _ before each statement depending on the version of internet explorer.
Put an _ before each statement in your css for internet explorer 6.0 and earlier
Put a # before each statement in your css for internet explorer only
Example:
//Normal
font-family: Tahoma, Helvetica, "Arial Unicode MS", sans-serif;
// IE 6.0 Earlier
_font-family: Tahoma, Helvetica, sans-serif;
// IE Only
#font-family: Tahoma, Helvetica, "Arial Unicode MS", sans-serif;
As I understand it, under the correct implementation of CSS, you can set any font you want, and if it runs into a character that is not present in that font, it will start falling back through the font-family backup choices until it finds one that works.
Unfortunately, that's not how it works in Internet Explorer, at least not in older versions. These browsers only use the first font family available on a system. One approach I sometimes use is to add a separate CSS class for Unicode characters:
<span class="unicode">[Unicode character]</span>
.unicode { font-family: "Lucida Sans Unicode", ..., sans-serif; }
I found Lucida Sans Unicode to be a good choice as it's preinstalled on all Windows versions since Windows 98. Its Unicode support isn't as complete as you'd expect, though.
But I started to prefer icon fonts. They have the advantage that the glyphs always look the same regardless of the font actually used. As John Slegers mentions in his answer, there are great online tools to create your own customized icon font.
Related
I'm looking for any possibility to specify more than one font in ImageFont.truetype(), as it works in browsers (font-family, fallback fonts etc). If it isn't realized in the library, working workaround will be appreciated.
After a recent IOS 13 update a Ruble currency symbol disappeared from all my WordPress sites that use woocommerce when browsing from Iphones. It just shows an empty rectangle. I tried to fix that with adding a custom symbol through functions.php but with no luck so far. Is there a way to fix that? Thank you for your answers!
EDIT
Well i ve just found a solution. The issue is that this Ruble symbol is in the latin extended set of google fonts. When i changed my standard body fonts from wordpress options to google roboto font with latin extended set - all is back to normal. Thanks to everyone!)))
The issue was that this Ruble symbol is in the Latin extended set of Google fonts.
When I changed my standard body fonts from Wordpress options to Google Roboto font with Latin extended set, all was back to normal.
I've searching some answer, like this but nothing works.
How can I insert custom fonts (for me is Proxima Nova that I use until with typekit) in a newsletter?
Like as Jukely use in their email hat works on any email client!
Please someone can help me?
Thanks, Enri
Unfortunately Typekit requires Javascript to work, which is a big no-no in emails. You have two options:
You can download and host the font on your own domain, and use #import to link to it (detailed instructions are the same as option 2):
#import url('https://www.mydomain.com/fonts/proxima-nova.css');
You can find a somewhat similar font in the Google Fonts library (such as 'Montserrat'), and use CSS #import, as described in the Campaign Monitor link. You can use it like this:
<style>
#import url(http://fonts.googleapis.com/css?family=Montserrat);
h4 {
font-family: Montserrat, Arial, sans-serif;
color: #444444;
font-size: 24px;
}
</style>
You will still see your back-up font (Arial, sans-serif in the example) in a lot of email clients, so make sure you're prepared for that, but you should be looking pretty good in iOS Mail, Outlook, Apple Mail, Android (default client) and Thunderbird.
#font-face support is much worse in emails, with only the Apple Mail app seeming to support it, FYI.
Sources:
http://css-tricks.com/custom-fonts-in-emails/
http://www.campaignmonitor.com/blog/post/3897/using-web-fonts-in-email
I see they are included in the HTML5 Boilerplate but I don't know what They are or why they may be useful. I searched on google but could not find any explanation to what they are
search
They're special classes to help you author conditional styles. For instance, rgba isn't supported in some older versions of Internet Explorer, so you may want to load a .png background image instead:
article {
background-image: rgba(255, 0, 0, .25);
}
.oldIE article {
background-image: url( 'faintRed.png' );
}
This is a contrived example, but it illustrates the intent behind these classes. Due to conditional comments around tags like <html>, you can conditionally place a class like .oldIE in the ancestral tree of elements, thus allowing you to create fallbacks for older versions of IE.
Conditional Comments no longer work in IE as of version 10. They're not longer needed given the parity of standards support found between Internet Explorer and other modern browsers.
These conditional classes were removed from the HTML5 Boilerplate in September of 2013.
I'm trying to find out how character sets/encoding are implemented in browsers, specifically Unicode.
Are sets/encodings implemented separately in each browser or is it OS specific?
Is it possible to find out what version of the Unicode Character Db (UCD) is being used?
How are UCD updates pushed to each browser/OS? (Is it ever pushed out via automatic updates or is it just set for whatever version browser/OS you're using?)
Links to character sets/encoding information for each browser/OS manufacturer would be nice.
Thanks
I don't believe the browsers worry about the UCD at all.
A wellformed page will have a charset defined for it. Example: <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
Any text that is being displayed will have a list of fonts defined for it (in preferred order). Example:
p { font-family: Verdana, Arial, sans-serif; }
For any character on the page the browser simply looks up the glyph in the font definition. If there isn't one it moves to the next font in the list. If it lucks out completely it probably just uses whatever uber-font the OS provides (Arial).