简体   繁体   English

如何使全角字符恰好是单角字符的两倍?

[英]How to make double-width chars exactly twice of single-width chars?

In terminal, many fonts supporting double-width chars display them exactly twice the width of single-width chars. 在终端中,许多支持全角字符的字体显示的宽度恰好是单角字符宽度的两倍。 For example, these two lines should have exactly the same width: 例如,这两行的宽度应完全相同:

あああ
aaaaaa

However, this is not true in browsers, no matter Chrome, Firefox, or whatever GUI browser. 但是,无论是Chrome,Firefox还是其他GUI浏览器,在浏览器中都不是这样。 I tried some monospace fonts, but they still don't necessarily display exactly twice width of a . 我尝试了一些等宽字体,但他们仍然不一定显示的准确宽度的两倍a

My question is: Can we fix this problem using CSS, or there are fonts satisfying this condition without any help from CSS, or this problem is simply not solvable? 我的问题是:我们可以使用CSS来解决此问题,还是可以在没有CSS的任何帮助下满足此条件的字体,或者根本无法解决此问题?

Your problem is fonts. 您的问题是字体。 Most monospace fonts don't contain any CJK characters. 大多数等宽字体不包含任何CJK字符。 The browser has to substitute in another font for those characters, and that font will usually have different metrics from the monospace font. 浏览器必须用其他字体替代这些字符,并且该字体通常具有与等宽字体不同的度量。

If you're on a Mac, the Osaka-Mono font contains both Japanese and monospaced Latin characters, and the example below will be laid out with exactly two Latin characters to each Japanese character: 如果您使用的是Mac,则Osaka-Mono字体同时包含日语和等宽拉丁字符,并且下面的示例将在每个日语字符的正好两个拉丁字符的情况下进行布局:

 body { font-family: Osaka-Mono; } 
 abcdefghijklmn <br>いろはにほへと 

On other platforms… you're on your own, sorry. 在其他平台上…对不起,您自己一个人。 CJK web fonts aren't standardized in the same sort of way as Latin web fonts. CJK网络字体的标准化方式与拉丁网络字体不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM