I have a website that uses one Latin and one Arabic font (Adobe Typekit fonts).
The dynamically generated text (p) is in Italics and sometimes is written in Latin and sometimes in Arabic.
So I have a CSS rule:
p {
font-family: "Arno-Pro", "Athelas-Arabic", serif;
font-style: italic;
}
The problem is that the Arabic font does not have italic characters, as Arabic is a language that is written with font-style: normal; so instead of using the Arabic font, it falls back to ugly system font.
For demonstration purposes to make it simpler, imagine that I have this line of text:
<p> Lorem ipsum لكن لا بد </p>
How can I target the Latin letters to be loaded as italics and the arabic letters to be loaded normal?
Note: The text is generated dynamically and cannot use custom markup within.
You can override the actually used fonts via
@font-facerules with specific unicode ranges:In the above example we're specifying a css override for the previously declared default font mapping:
font-style:italic– otherwise text would be artificially slanted (also called "faux italic").So instead of specifying a dedicated arabic font in the
font-familyproperty, we override the font mapping like this:This css rule translates to:
For this (arabic) unicode range – take the "Athelas-Arabic" font files (so this becomes the "Arno-Pro"). By adding a
font-style:italicproperty, we circumvent a "faux-italic" slanting, since our css rule says: this is already a proprer italic font (even it's not).