使用JavaScript检测单个Unicode字符支持 [英] Detecting individual Unicode character support with JavaScript

查看:114
本文介绍了使用JavaScript检测单个Unicode字符支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检测客户端是否支持特定的Unicode字符,或者是否将其显示为缺少的字形框?

Is it possible to detect if the client supports a particular Unicode character or if it will be rendered as a missing glyph box?

重要提示:支持多种浏览器尽可能

Important: Support in as many browsers as possible

不重要:效率,速度或优雅

Not important: Efficiency, speed, or elegance

我能想到的唯一方法是使用画布,所以我想我会在开始走这条路之前问。

The only method I can think of trying is using a canvas, so I figured I'd ask before I start going down that road.

谢谢!

编辑:这不是打算在公共网站上使用;我只是试图编译每个浏览器支持的字符列表。

This is not intended for use on a public web site; I am just trying to compile a list of characters supported by each browser.

推荐答案

这是一个比真实的答案:

This is more of a wild idea than a real answer:

如果你能找到一个你知道的字符总是作为一个缺少的字形框来显示,你可以使用与这个 javascript字体检测器 - 在屏幕外渲染字符和缺少的字形,并比较其宽度。如果他们不同,那么你知道字符不是作为一个丢失的字形框呈现。当然,这对固定宽度的字体根本不起作用,并且对于其他字体来说,它可能有很多固定的负值,其中许多字符的宽度相同。

If you could find a character which you knew would always render as a missing glyph box, you could use the same technique as this javascript font detector--render the character and the missing glyph box offscreen and compare their widths. If they're different, then you know the character is not rendering as a missing glyph box. Of course, this won't work at all for fixed-width fonts, and it could have a lot of fixed negatives for other fonts where a lot of the characters are the same width.

这篇关于使用JavaScript检测单个Unicode字符支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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