列出所有字体,用户的浏览器可以显示 [英] list every font a user's browser can display

查看:175
本文介绍了列出所有字体,用户的浏览器可以显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个JavaScript的方式获取所有字体(或字体家庭)的名称,浏览器可以显示? (我想给用户提供所有可用字体的列表的下拉菜单,并允许用户选择一种字体。)
我倒是preFER不要有硬code这个名单提前或从服务器发送了下去。 (直观地看,这似乎是浏览器应该知道是什么字体它,这应该以某种方式接触到的JavaScript。)

Is there a way in javascript to obtain the names of all fonts (or font-families) that the browser can show? (I want to give the user a dropdown with a list of all available fonts, and allow the user to choose a font.) I'd prefer not to have to hardcode this list ahead of time or send it down from the server. (Intuitively, it seems like the browser should know what fonts it has and this should be exposed to javascript somehow.)

推荐答案

JavaScript版本是有点片状。它通过已知的字体和迭代测试得到的字体。

The JavaScript version is a bit flaky. It gets fonts by iterating through known fonts and testing.

最精确的方法(尽管不必使用礼插件)是<一个href=\"http://hasseg.org/blog/post/526/getting-a-list-of-installed-fonts-with-flash-and-javascript/\">use闪存。在这里,你可以得到的字体列表中,而无需测试其个人使用的尺寸。

The most accurate way (albeit having to use a propriety plugin) is to use Flash. Here you can get the list of fonts without having to test for them individually using dimensions.

您会不得不决定是否有确切的名单在不工作的一些设备的费用(的iDevices,没有浏览器Flash插件等),或一个的部分清单,通过JavaScript更好的支持仅

You are going have to decide whether to have an exact list at the expense of not working on some devices ( iDevices, browsers without Flash plugin, etc), or a partial list with better support via JavaScript only.

这篇关于列出所有字体,用户的浏览器可以显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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