哪个UTF-8字符最宽? [英] Which UTF-8 character is the widest?

查看:93
本文介绍了哪个UTF-8字符最宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题询问哪个字母占用最多像素时,我创建了这个问题以询问所有UTF-8字符最大?

While this question asks which letter takes up the most pixels, I created this question in order to ask which in all of the UTF-8 characters is the widest?

推荐答案

您可以使用以下代码以编程方式获取最长的字符:

You can use this code to obtain the longest character programmatically:

var capsIndex = 65;
var smallIndex = 97;
var div = document.createElement('div');
div.style.float = 'left';
document.body.appendChild(div);
var highestWidth = 0;
var elem;

for(var i = capsIndex; i < 32834; i++) {
    div.innerText = String.fromCharCode(i);
    var computedWidth = window.getComputedStyle(div, null).getPropertyValue("width");
    if(highestWidth < parseFloat(computedWidth)) {
        highestWidth = parseFloat(computedWidth);
        elem = String.fromCharCode(i);
    }
}
div.innerHTML = '<b>' + elem + '</b>' + ' won';

运行此命令并等待(和等待)后,输出为 ௌ won .
在那里,它是UTF-32中最长的字符!请注意,在大多数字体上,最长的字形是,但是某些字体(特别是等宽字体)与字符重叠,就像程序运行时使用的字体一样.

After running this and waiting (and waiting), it gives the output ௌ won.
And there you have it, the longest character in UTF-32! Note that on most fonts the longest glyph is , but some fonts (especially monospace ones) overlap the characters, as with the font that the program was run with.

这篇关于哪个UTF-8字符最宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆