Different font showing up in Mac and Windows - apache-flex

I've flex application and am using arial font family. My problem is, arial fonts are shown up in windows while on Mac, it's been replaced with Times New Roman. (Arial font is there on both systems).
What can be the problem??

If I were you, I would embed the font in your application instead because you never know if the user have the font on his computer. Moreover, when using system fonts, the rendering can be somewhat different between a PC and a Mac

PeZ is exactly correct. You can find information about how to do it here, but I commented because I wanted to reinforce an additional pitfall of embedding fonts.
First, it will make the size of your SWF increase quite a bit, because it creates outlines of every single character in the font set you use. To resolve this, you should limit down what characters are actually embedded - if possible. You can learn more about ranges here.
Also, remember that you need to embed bold and italics as well if you are using them in your application.
In other words, something like this:
#font-face {
src: url("/style/MyriadNormal.ttf") ;
fontFamily: Myriad;
fontWeight: normal;
unicode-range: U+0021-U+007B; /* whole range of uppercase, lowercase, symbols and punctuation. */
}
#font-face {
src: url("/style/MyriadBold.ttf") ;
fontFamily: Myriad;
fontWeight: bold;
unicode-range: U+0021-U+007B; /* whole range of uppercase, lowercase, symbols and punctuation. */
}
Remember that every version of a font you embed will increase the SWF size as well - so if you embed a normal, bold, and italic font you triple up the size.

Related

Adjust dash, ndash and mdash length in the font

I'm using the Roboto Family of fonts. In general, it fits perfectly to all my needs except one. The length difference between ndash and mdash is to small. It is a very important aspect, because as a part of our services - we are helping editors, proofreaders, writers and typeseters.
To fix the issue, we adjusted the font and we hosted it on our server. Unfortunatly, this has an significant impact on page loading and rendering speed (even the preloading the font is done).
I would like to switch into CDNJS version of the Roboto font and I'm wondering if there is a CSS or CSS+JS way to fix the issue. The idea is to select all the ndashes on the site and to shorten all of them with either JS or CSS, to be exactly in the middle of the length between dash and mdash. In the origin Roboto font ndash is twice so long as dash but mdash is just a little bit longer than ndash.
An alternative is, to replace all the ndashes with an ndash from another font.
Any other ideas?
You mention replacing the ndashes and mdashes from another font.
Have you considered using the CSS font-face unicode-range property?
If you have a font that has the sort of size dashes you want you could substitute those for the dashes in Roboto.
I couldn't immediately find a font that had sufficiently different dashes to the standard ones to demonstrate, but here's the code from MDN which substitutes the ampersand in Helvetica with the slightly more flamboyant one from Times New Roman. This method saves having to do anything to your actual text.
#font-face {
font-family: 'Ampersand';
src: local('Times New Roman');
unicode-range: U+26;/* 2013-2014 ndash and mdash */
}
div {
font-size: 4em;
font-family: Ampersand, Helvetica, sans-serif;
}
<div>Me & You = Us</div>

using unicode_range to exclude numbers only

I'm using a custom font and loading it through #font-face. The text looks fine, but the numbers look screwy (only on chrome-windows, which is a very well know bug. And yes, I tried using the svg format for chrome, which solved the numbers but screwed the text). I decided to limit my own font to only [a-z][A-Z], and using this generator got this:
unicode-range: U+0041-U+005a, U+0061-U+007a;
And it seems to... not be working. Numbers are still being displayed using the font. How do I find the right range to use\some other solution? I'd love for a general solution, for example if I want to limit future fonts as well.
Thanks in advance!
P.s.
While I'm on the subject - I'm assuming there's no way to load the same font twice - using the .svg file for numbers and .otf for text, right? Because if possible that'd be awesome as well.
You can use #font-face rules to specify that a font family name (which is up to you to decide) is mapped to a specific font except for some character range, for which another font is used. This even works for local fonts, e.g. as follows:
<style>
#font-face {
font-family: foo;
src: local("Times New Roman");
}
#font-face {
font-family: foo;
src: local("Arial");
unicode-range: U+0030-0039;
}
p { font-family: foo }
</style>
<p>hello 123</p>
On supporting browsers, “hello” appears in Times New Roman (if available) but “123” in Arial (if available); the range U+0030-0039 is the common European digits 0 to 9.
You can use similar techniques for downloadable fonts.
The bad news is that unicode-range is not supported by Firefox or by IE 8 or earlier. They fail differently: for the code above, IE 8 uses Times New Roman, ignoring the latter #font-face rule, whereas current Firefox uses Arial, as if the unicode-range restriction were not there.
Finally, I used a "brute-force" method. Using Font Squirrel's webfont generator I recreated my font files, and using the advanced options > custom subsetting, I completely removed the numbers from the font.
Seems like a terrible solution, but the best I could find.

Fallback fonts on special characters

I was wondering if it's possible to, when using #font-face, have a fallback setup so that if the text on my page contains characters that are not accounted for within the font (Japanese characters for example), only those characters are presented in a basic font and every other character remains as the custom font?
I'm imagining that potentially there'd be a mix of two fonts within one paragraph on occasion.
What you described is the default behaviour of a browser - it should naturally fall back to basic font for missing characters.
However, sometimes custom fonts use blank characters, in that case you can try using the unicode-range
For example:
#font-face {
font-family: BBCBengali;
src: url(fonts/BBCBengali.ttf) format("opentype");
unicode-range: U+00-FF;
}
Taken from this interesting article: Creating Custom Font Stacks with Unicode-Range
Unfortunatelly there are browser support issues.
CSS has default fallback to the system font if the specified font doesn't contain a character.
You can also specify which font to fall back to.
Example for a serif font:
body {
font-family: "MyNiceFontWithoutJapanesChars", "common serif font", serif;
}
As long as the fallback font has those characters your default font misses, you should be all right.

Same font renders differently across FF7 and Chrome

Screenshot: http://i.imgur.com/QVBGx.png
It is pretty evident that my site renders different on Chrome and FF7 on my Win7 machine
I am using this:
h1, h2 {font-family: "Lucida Grande", "Helvetica Neue", Arial; }
Does anybody can point me how can I even these diffs? I don't want fonts with different 'feelings' on each browser.
The font, Lucida Grande is installed in my Windows machine
EDIT:
font-weight: normal !important
doesn't work either
It looks like the two browsers are rendering it with a different weight.
I can think of two possibilities, though I don't know if either are correct.
You requested a bold font, but that font is not available in bold. One browser is just showing the regular, non-bold variant unchanged, whereas the other has processed it to look bold.
You requested a particular weight of font, say "bold" or "600" but the installed fonts do not precisely match that weighting. One browser is substituting an "extra-bold" variant of font, and the other a "regular-bold", or something of this nature.
If either of these is correct you could play around with the font-weight CSS property to try and alter it. But then that may affect substitution of whichever font is chosen in the case that it is viewed on a system with no Lucida Grande font at all.
Fonts will always render slightly different from one browser to another, but that was a bit more difference than usual. Probably because the headers have font-weight: bold; as default, and the font doesn't have a bold variation so the browsers create the bold style from the regular weight in different ways.
Anyway, you might want to use more common fonts. On my Windows 7 machine there is neither Lucida Grande nor Helvetica Neue, so it would render using Arial. Still, I have the additional fonts that come with both MS Office and Photoshop, so I have a lot more fonts installed than you can expect from a standard system.
Also, you should always specify a generic font as the last resort, in this case sans serif, otherwise it would render using the default font if none of the fonts are installed, which is something like Times Roman which has a completely different look. Perhaps also adding Helvetica, which is the closest equivalent of Arial on non-Windows systems.

In Adobe Flex, why does an embedded version of a font, behave differently from the same font installed in the system

Scenario:
Flex application utilizing an #font-face declaration for embedding the font. (Embedded fonts are required to be able to rotate text.)
The application was originally developed as an English application, but during localization it became necessary to locate a unicode font capable of displaying Asian characters. The original implementation of the application uses four fonts to satisfy the various permutations of character emphasis. Bold, Bold Italic, Italic and Normal are all supplied through the corresponding Arial fonts in the Arial family.
Problem:
When trying to compile in the font as one that could be used for the bold, italic, and bold italic through something like (yes its not ideal, this was just a test to see if it could be done):
#font-face { src:url("/fonts/ArialUnicode.ttf");
fontFamily: myFamily;
fontWeight: normal;
fontStyle: normal;
advancedAntiAliasing: true; }
#font-face { src:url("/fonts/ArialUnicode.ttf");
fontFamily: myFamily;
fontWeight: bold;
fontStyle: normal;
advancedAntiAliasing: true; }
etc.
The problem is that when compiling the application Flex gets cranky and gives the following error message:
[ERROR] /dirpath/Style.css:[49,-1] exception during transcoding: Font for alias 'myFont' with italic style was not found at: file:/dirpath/fonts/ArialUnicode.ttf
So with some investigation it was determined that since Unicode supports neither Italics nor Bold, that when the Flex compiler attempts to embed the font, it gets unhappy as it cannot locate a font at the specified location that will satisfy the css requirement.
Now when the font-face declaration is taken back to its simplest form of:
#font-face { src:url("/fonts/ArialUnicode.ttf");
fontFamily: myFamily;
fontWeight: normal;
fontStyle: normal;
advancedAntiAliasing: true; }
everything compiles fine and the application displays all normal weight, normal style Asian characters fine. However when displaying things that are to be displayed in Bold or Italic in the style sheet, a box appears denoting that there is no embedded font nor any system font that can render that character in those styles.
Now here is where it gets weird.
If the exact same Unicode font is installed onto the system, it begins displaying the Asian characters in bold and italic. This makes no sense as the Bold and Italic characters are not in the font as demonstrated when Flex tried to embed that font to satisfy those css styles above. Yet it is evident that this font is being utilized to display the bold and italic characters as before they were just boxes before it was installed as a system font. Is this some kind of Flex voodoo? And if so is there some way I can programmatically invoke said voodoo as I cannot rely on the user having to go out and get the unicode font installed on their system.
Edit:
Here is some further information that may clarify the issue.
My question is not really how do we do multiple font faces and weights for roman characters, it is "How does Flex apply bolding and italics to a system font. Even more so when it says that that font does not support those when trying to embed that font."
The steps to make the issue reproducable are such:
Embed only MS Arial Unicode into the application and deploy it.
On a fresh Windows 2003 machine, open up Firefox and select Japanese language.
Navigate to the application URL and view the boxes where the bold and italics should be.
Now exit Firefox. Install the MS Arial Unicode font into the Windows 2003 system.
Open Firefox and repeat. The areas that used to be boxes, are now bold/bold italics/italics Japanese characters.
It isn't so much the how to solve this issue. There are plenty of viable solutions. However what I would really like to know is how does Flex apply bold and italics to a font that it says does not support bold or italics.
Thanks,
C
The problem is that you're specifying the same file name for all four font variants. The single ArialUnicode.ttf file contains only one variant.
Using the names from your c:\Windows\fonts directory, you want to embed arial.ttf, arialbd.ttf, arialbi.ttf, and ariali.ttf. These are the normal, bold, bold-italic and italic variants, respectively.
Beware that not all fonts can be embedded freely, both from a technical standpoint and from a legal standpoint.
The legal side is that fonts are software, and so need to be licensed just like any other third-party code you include in your program. You might want to look at the Bitstream Vera font family, as they are liberally-licensed. The family is highly capable, designed to be used as core fonts in Linux and such.
The technical side is that these rules are baked into the TTF and OTF file formats, and tools like the Flex compiler obey the license restrictions declared in the file. If the font is marked "no embed", it won't let you embed it.

Resources