Some fonts only work for one language
If you want to use multiple languages and multiple fonts on the same page, things get tricky. I have looked into different approaches, and below I describe the most effective one I found. I know there are easier methods, but not every browser understands them. So the method I'm describing should be the most reliable — if you know a better one, you're welcome to leave a comment.
First, we need to understand what UTF-8 is.
Next, we need to know which languages we want to style with different fonts.
Take Chinese for example: the Unicode range for Chinese) (CJK Unified Ideographs) is:
List of CJK Unified Ideographs, part 1 of 4 (U+4E00..U+62FF) List of CJK Unified Ideographs, part 2 of 4 (U+6300..U+77FF) List of CJK Unified Ideographs, part 3 of 4 (U+7800..U+8CFF) List of CJK Unified Ideographs, part 4 of 4 (U+8D00..U+9FFF)
We need to add the following CSS:
@font-face {
font-family: 'noto_serif_scregular' !important;
src: url('your-font-file.woff2') format('woff2'),
url('your-font-file.woff') format('woff');
font-weight: normal;
font-style: normal;
unicode-range: U+4E00-62FF, U+6300-77FF, U+7800-8CFF, U+8D00-9FFF !important;
}
We add !important to give it higher priority than the original font.
The Unicode ranges in the CSS above are the ones listed in the CJK Unified Ideographs section.
For the Unicode ranges of other scripts, look them up on Google / Wikipedia yourself.
Quantum Responses (0)