Why does my custom font have a positional offset in some browsers?

余生颓废 提交于 2019-12-01 19:43:44

I have figured it out and it is rather strange and consists of two things.

1) The .ttf and .eot I got from the font-squirrel were no good. Getting the original .ttf back from the font-site and converting it to .eot myself was necessary for proper rendition. I do not know whether this is actually font-squirrel's fault because the differences in rendition seem very arbitrary and strange, also see point 2).

2) Removing the .woff entry from the css. The .woff was only added for safety, I was not sure whether this was used by any, but it seems all browsers still render it correctly.

It seems very bizarre, because the browsers involved all use the same .ttf (except IE8 and less which use the .eot) but render it differently. Also the .woff has to be removed, why? ALthough I have solved my problem it still seems a rather random and strange problem. If anyone knows more about this stuff I would love to know.

I hope this question will be of use to others to come. font-face has still a long way to go in being easy to use, and browsers should be more wary of proper compliance regarding it.

The problem is caused by the browser negating to compute exact glyph bounds (Done for the sake of performance.)

The solution to this problem is to add a single line of text into your CSS:

text-rendering:optimizeLegibility;

this line can be added to the CSS of the div that requires it, and that way there's no extra processing done to the rest of the page.

You need to specify a line-height. Try

body,html
{
    line-height: 18px; /* or whatever height you want */
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!