Mixing English and Arabic content with the same @font-face

When constructing a bilingual website, the utilization of localization services integrated within CMS platforms can prove to be valuable. In this context, it is often possible to establish distinct asset folders for each language. This approach prevents the simultaneous loading of all assets, including images, fonts, and CSS files, which is a logical strategy. However, complications arise when the website features user-generated content such as blogs or discussion forums, where the content might deviate from the primary language. An instance of this would be a user posting an article or topic in Arabic within an English-styled discussion forum.

Consider the following example: The main master font “Helvetica Neue” has been designated for the primary body tag, with all other elements inheriting this font. Notably, a client expressed a strong preference for a font like “Druid Kufi” for Arabic content. Addressing this requirement presents challenges, as allowing visitors to select styles and fonts or implementing an HTML editor is not viable, considering the varying degrees of HTML proficiency among users.

To overcome this obstacle, a strategy was conceived to supersede the “Helvetica Neue” font by incorporating a distinct font-face attribute known as “unicode-range”:

@font-face { font-family: 'Helvetica Neue'; src: url('fonts/DroidKufi-Regular.ttf') format('truetype'); font-weight: normal; font-style: normal; unicode-range: U+0600-06FF; }

This code segment effectively delineates the Arabic character range using the “unicode-range” property. Given that the content adheres to UTF-8 encoding, the specified range corresponds to the Unicode table’s Arabic characters. Implementation of this code ensures that the browser renders content in English using the “Helvetica Neue” font, while seamlessly rendering Arabic content using the “DroidKufi Regular” font.

This solution successfully accomplishes the objective at hand.