如何让非标准字体在网站使用中发挥作用?
问题是,我需要在网站中获得带有效果(来自 Photoshop:Outer Glow)的非标准字体(不是每个人的计算机上都有它)。我可以使用 Javascript(包括 jQuery)和 CSS3,但该字体应该能够像 web 中的任何文本一样突出显示。有什么解决办法吗?
PS 字体:Titilium。
Problem is, that I need to get non-standard font (not everyone has it on his computer) with effect (from Photoshop: Outer Glow) in web site. I can use Javascript (including jQuery) and CSS3 for it, but that font should be able to highlight like any text in web. Any solutions?
P.S. Font: Titillium.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
嗯,这很简单,如果你可以选择不支持 IE8 及以下版本的发光部分。
转至 http://www.fontsquirrel.com/fonts/TitilliumText 并下载 @font-那里提供的面部套件。请按照有关如何为您的网站安装和使用
@font-face
的说明进行操作。接下来,对于外发光,您可以使用
text-shadow
属性来实现几乎相同的效果。例如,这将为您带来大小为 3px 的蓝色光芒:您就完成了!当然,如上所述,IE8 及更低版本不支持
text-shadow
,因此您只能忍受这一点。Well it's simple enough, if you can choose not to support IE8 and below for the glow part.
Go to http://www.fontsquirrel.com/fonts/TitilliumText and download the @font-face kit that's provided there. Follow the instruction on how to install and use
@font-face
for your website.Next, for outer glow, you can use the
text-shadow
property to achieve pretty much the same effect. This, for instance, will get you a blue glow of size 3px:And you're done! Of course, as stated above, IE8 and below don't support
text-shadow
, so you'll just have to live with that.为了能够像其他文本一样显示 Titilium 字体,您需要将该字体嵌入网页中。有许多在线服务可以帮助您做到这一点。
在嵌入之前,请确保字体的许可证允许您嵌入字体,因为少数字体不允许。
下面是使用 CSS3 嵌入字体的示例:
正如您在上面看到的,我放置了不同格式的相同字体。它们与浏览器兼容,例如:Internet Explorer 支持 eot。 WOFF 是一种很快就会被所有浏览器广泛接受的格式。
有许多在线转换器可用于转换字体。你可以google一下,选择一个最适合你自己的。
以下浏览器也支持字体嵌入:
这是我经常使用的发光效果在我的项目中:)
HTML
CSS
To be able to display Titillium font like anyother text, you need to embed the font in the webpage. There are many online services that can help you do that.
Before embedding make sure that the license of the font allows you to embed the font, as few font doesn't allow.
Here is an example for font embedding using CSS3:
As you see above there are various formats of same fonts I have put. They are there to be browser compatible eg: eot is supported by Internet Explorer. WOFF is a format soon to be widely accepted by all the browsers.
There are many online converter available for converting a font. You can google it out choose a best one for yourself.
Also font embedding is supported in following browsers:
Here is the glow effect I always use in my projects :)
HTML
CSS
你可以使用
发光字体
使用jquery插件 jQuery 文本发光效果
嵌入Titilium字体
@font-face {
字体系列: Titilium ;
src: url( /location/of/font/Titillium.ttf ) format("truetype");
}
/* 然后像使用任何其他字体一样使用它 */
.Titillium { 字体系列:Titillium 、 verdana 、 helvetica 、 sans-serif ;
}
you can use
Glowing font
use jquery plugin jQuery Text Glow Effect
Embedding Titillium font
@font-face {
font-family: Titillium ;
src: url( /location/of/font/Titillium.ttf ) format("truetype");
}
/* Then use it like you would any other font */
.Titillium { font-family: Titillium , verdana, helvetica, sans-serif;
}
尝试库丰
http://github.com/sorccu/cufon/wiki/usage
我个人的一些东西喜欢这一点的是,它会按照您想要的方式为那些禁用 js 的人优雅地降级。
Try Cufon
http://github.com/sorccu/cufon/wiki/usage
Something that I personally like about this is that it downgrades gracefully for those with js disabled in the way you want.
我的建议:
转换后将文本更改为画布
Pixastic 库)
第二点和第三点可以通过放置发光文本的图像来替换(可以动态生成,例如通过PHP)。
看起来很复杂,这只是替代方案。 (老实说,我喜欢@Yi Jiang的回答)。
My proposition:
change text to canvas
Pixastic library)
Second and third point can be replaced by putting image of glowing text (could be generated dynamicly, e.g. by PHP).
Seems complicated, it's only alternative. (Honestly, I like @Yi Jiang's answer).