Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply font-face only to a certain range of Unicode characters

Tags:

css

unicode

A string queried from database look like this អាស័យដ្ឋានបច្ចុប្បន្ន 123, Street: National Road 3, ភូមិ ១, អូរឫស្សីទី ២, ៧មករា, ភ្នំពេញ តទៅនេះហៅថាភាគី«ក»។

I used font face font-family: 'Battambang', cursive;. The ASCII characters look good using that font, but the other characters inside the string look a bit cumbersome.

Rendering on browser, it looks like this:

View on Browser

If I remove font-face the non-Unicode characters look good, but the Unicode characters don’t.

Removing font-face

Therefore, is there any CSS trick I can use to apply the font only to certain Unicode characters but not to others?

like image 334
Houy Narun Avatar asked Mar 08 '23 07:03

Houy Narun


1 Answers

Since the Battambang typeface doesn’t contain those characters, they’re falling back to what you specified: cursive. Use the one that would normally be inherited instead.

font-family: Battambang, Roboto; /* or whatever it would be normally */

For typefaces that do contain characters you want excluded, you’ll also need to specify a unicode-range:

@font-face {
    src: /* … */;
    font-family: Battambang;
    unicode-range: U+1780-17FF, U+200B-200C, U+25CC;
}
like image 189
Ry- Avatar answered Apr 06 '23 09:04

Ry-