且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

CSS可以根据语言选择不同的默认字体和大小

更新时间:2023-01-24 14:54:41

CSS3,这不会有助于与旧浏览器的兼容性,但它适用于我混合希腊和拉丁文字与不同的字体。这是一个从CSS字体模块工作草案中取得的例子:

This is addressed in CSS3, and that's not going to help for compatibility with old browsers, but it works for me when mixing Greek and Latin text with different fonts for each. Here's an example taken from the CSS Fonts Module Working Draft:

@font-face {
    font-family: BBCBengali;
    src: url(fonts/BBCBengali.ttf) format("opentype");
    unicode-range: U+00-FF, U+980-9FF;
}

unicode范围 bit是魔术键:它告诉浏览器使用这个font-face语句只用于这个特定的Unicode字符块。如果浏览器找到该范围内的字符,则使用此字体;对于该范围之外的字符,它会按照通常的默认模式返回下一个最具体的CSS语句。

The unicode-range bit is the magic key: that tells the browser to use this font-face statement only for this particular block of Unicode characters. If the browser finds characters in that range, it uses this font; for characters outside that range, it falls back to the next most specific CSS statement following the usual pattern of defaulting.