字体Awesome& Unicode [英] Font Awesome & Unicode

查看:280
本文介绍了字体Awesome& Unicode的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站使用(优秀)Font-Awesome,它的工作正常,如果我这样使用:

I'm using (the excellent) Font-Awesome in my site, and it's working fine, if I use it this way:

<i class="icon-home"></i>

但是(由于某些原因)我想以Unicode方式使用它,如:

But (for some reasons) I want to use it in the Unicode way, like:

<i>&#xf015;</i>

字体Awesome的骗子

但它不工作 - 浏览器显示一个正方形。

But it doesn't work - the browser shows a square instead.

我如何解决这个问题?
CSS路径是正确的(作为使用Font Awesome工作的第一种方式)。

How do I solve this? The CSS path is correct (as the first way of using Font Awesome works).

编辑:我安装了FontAwesome.otf。

I do have the FontAwesome.otf installed.

推荐答案

它不起作用,因为< i>&#xf015;< / i& code>简单地要求浏览器使用斜体字体显示私人使用代码点U + F015。 Font Awesome CSS代码没有什么会影响这一点。如果你添加 class = icon-home 到标签,你会得到分配给U + F015 FontAwesome字体的字形,但你会得到它两次,由于方式字体Awesome诡计工作。

It does not work, because <i>&#xf015;</i> simply asks the browser to display the Private Use code point U+F015 using an italic typeface. The Font Awesome CSS code has nothing that would affect this. If you add class=icon-home to the tag, you will get the glyph assigned to U+F015 in the FontAwesome font, but you will get it twice, due to the way the Font Awesome trickery works.

要获得字形一次,你需要使用CSS,要求使用FontAwesome字体,而不触发规则添加通过生成的内容。一个简单的诀窍是使用以 icon - 开头的类名,但不匹配Font Awesome中的任何预定义名称,或者在CSS或JavaScript代码中使用的任何名称。例如

To get the glyph just once, you need to use CSS that asks for the use of the FontAwesome font without triggering the rules that add a glyph via generated content. A simple trick is to use a class name that starts with icon- but does not match any of the predefined names in Font Awesome or any name otherwise used in your CSS or JavaScript code. E.g.,

<i class=icon-foo>&#xf015;</i>

或者,使用设置 font-family:FontAwesome font-style:normal

PS。请注意,私人使用的代码点,如U + F015,根据定义,没有互操作的意义。因此,当样式表被禁用时,&#xf015; 将不会显示为任何字符;浏览器将使用其传送未定义数据的存在的方式,例如可能包含代码点号码的小框。

PS. Note that Private Use code points such as U+F015 have, by definition, no interoperable meaning. Consequently, when style sheets are disabled, &#xf015; will not be displayed as any character; the browser will use its way of communicating the presence of undefined data, such as a small box, possibly containing the code point number.

这篇关于字体Awesome&amp; Unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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