Anti-aliased font in HTML page

China☆狼群 提交于 2019-11-30 21:14:40

a) Of course you can use browser detection. The easiest way to do this is probably using jQuery's browser method. (jQuery is an awesome JavaScript library that makes a lot of JS-development easier in case you haven't heard)

Depending on what browser (or OS) results you get, you could present the user with different solutions, from normal text to something like a Flash solution.

However, I advise against it. Things look better on new machines than old ones. That's just the way it is, which is why I recommend against spending precious time on minor glitches in older browsers. -- Unless users with older browsers are your main demographic of course. In this case, how about you just do it in Flash altogether? No use coding up two solutions if one always works, right?

b) You can in fact create anti-aliased text via JavaScript. Have a look at my project Die Stimme Gottes ("Voice of God" -- not for the religiously squeamish) for an example. In this project, I used the excellent typeface.js for this.

c) Just use CSS, maybe?

h1.welcome {
    background: url('the-welcome-image.png') no-repeat;
    color: transparent;

}

+1 Hank's comment. You have very little to gain by doing this. Some desktop browsers (including IE7+ and Safari) turn on anti-aliasing by default even when it's off at an OS level, and modern (post-XP) OSs tend to turn it on by default anyway. By forcing AA on the rest, you'll:

(+) improve the display a little for IE6 and XP+Firefox users who unwittingly don't have AA

(-) make loading slower for everyone (but especially users of limited mobile devices)

(-) defeat preferred font sizes

(-) unnecessarily annoy the luddites who deliberately disable anti-aliasing because it's “all blurry”(*)

(*: there are limited cases where this does even make sense, particularly for old, fuzzy CRT monitors.)

By the looks of it the best methods (in no real order) are:

1) Use an image. If you rely on SEO for the site then by all means add html and hide it using css using one of these methods

2) typeface.js - JS which will work across most modern browsers. Has some bugs and glitches but works nicely. If you're going to force anti-aliasing on your users then this works. Use sparingly. Author working on Opera and IE8 compatability though...

2) sIFR - Excellent script which dynamically replaces your selected areas of text with flash movies. Again some bugs and glitches, but if you're simply interested in awesome looking font then this is perfect. Increases your page load though, so as ever more is less, use sparingly.

I tend not to go with JS heavy solutions, as I like to have lightning quick page loads, but if you HAVE to have some good looking fonts, then these seem to be the most graceful and simple methods.

Force background color, redefining it for the class or element with the same background color. It works.

span.your_class {
    writing-mode: tb-rl;
    filter: flipv fliph;
    background-color: #006cb8 !important;
}

Flash or Silverlight are your best bets for great looking font rendering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!