开发者

Generating images: Alternate font by User Agent (OS)

开发者 https://www.devze.com 2023-01-02 07:26 出处:网络
I need to generate small images for certain parts of text. Those will have to fit into the text seamlessly. I know I can not make up for every browser font settings available, but how do I have to che

I need to generate small images for certain parts of text. Those will have to fit into the text seamlessly. I know I can not make up for every browser font settings available, but how do I have to check for Linux, Mac and Windows users depending on the user agent? I want to use the right font (of the three "Verdana, Arial, Helvetiva") for the right user agent OS.

So:

  1. How do I check for the OS? What do I have to compare to in the user agent?
  2. Where can I get the other two fonts. Does the Windows-included Verdana look the same as the one used on Linux (or, is it free anyway? I don't know much about fonts)? Where do I get Helvetica? Is 开发者_如何学运维it Mac OS licensed?

Any code examples can be in either c# or VB.NET. I can read both.

Thank you in advance.


For client side, have a look at http://www.w3schools.com/js/js_browser.asp

For server side, look at Request.Browser.Platform.

As for the fonts, I can't tell you much, except to make sure that you have a (virtual) machine that matches each platform you want to target. In my opinion, it's the only way to be really sure that whatever you end up doing actually works.


If you use @font-face in your css and specify the font-size in pixels, you will get the same font on all platforms at a predictable size. Then you can create one set of images for all platforms.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号