Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safari font rendering issues

As you can see below, the Texta-Light font in Chrome appears completely different with Safari. Chrome displays the font as I like but Safari's rendering on OS X and iOS looks too thin. The Safari image below is taken on iOS and as you can see for some reason the font appears as if there is two bits of text present.

I've looked for a solution but found nothing which works. I tried using -webkit-font-smoothing: subpixel-antialiased; but according to this question, the code isn't working anymore.

Chrome:

Chrome font-rendering

Safari on iOS:

Safari font-rendering

Here is the code for the images above:

h2 {     font-family: 'Texta-Light', sans-serif;     font-size: 3.5em;     line-height: 1.2em; } 

Is there any solution to this?

like image 526
Pav Sidhu Avatar asked Jun 25 '15 17:06

Pav Sidhu


People also ask

How do I fix rendering font?

Go to Control Panel > Appearance and Personalization > Display > Adjust ClearType text (on the left). Check the box entitled “Turn on ClearType.” After going through a short wizard, this will fix some of the text rendering issues in Chrome.

What fonts does Safari use?

The default Safari font is now Helvetica Extra Light.


2 Answers

There is a CSS property, text-rendering, which in Safari is by default set to optimizeSpeed. What you want to change is:

text-rendering:optimizeLegibility; 

enter image description here

From https://css-tricks.com/almanac/properties/t/text-rendering/

There are four possible values:

• auto (default) - The browser makes educated guesses about when to optimize for speed, legibility, and geometric precision while drawing text. Be aware that different browsers interpret this value differently.

• optimizeSpeed - The browser emphasizes rendering speed over legibility and geometric precision when drawing text. It disables kerning and ligatures.

• optimizeLegibility - The browser emphasizes legibility over rendering speed and geometric precision. This enables the use of special kerning and optional ligature information that may be contained in the font file for certain fonts.

• geometricPrecision - The browser emphasizes geometric precision over rendering speed and legibility. Certain aspects of fonts—such as kerning—don't scale linearly, so geometricPrecision can make text using those fonts look good. When SVG font is scaled, the browser calculates pixel size, then rounds to the nearest integer. The geometricPrecision property allows for more fluid scaling. Note: Only WebKit browsers apply this fluid value, Gecko treats the value just like optimizeLegibility.

There is an additional setting -webkit-font-feature-settings, of which one of them is kerning:

-webkit-font-feature-settings

h2 {      -webkit-font-feature-settings: "kern" 1; } 
like image 85
empedocle Avatar answered Sep 21 '22 17:09

empedocle


If, as per your comment, you are only serving .otf, you will need to serve the other file types too.

This could be causing an issue to do with iOs as until iOs 4.2, SVG was the only format to use custom fonts on the ipad or iphone.

@font-face {   font-family: 'MyWebFont';   src: url('webfont.eot'); /* IE9 Compat Modes */   src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */        url('webfont.woff2') format('woff2'), /* Super Modern Browsers */        url('webfont.woff') format('woff'), /* Pretty Modern Browsers */        url('webfont.ttf')  format('truetype'), /* Safari, Android, iOS */        url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */ } 

A great tool to use is Font Squirrel's Webfont Generator

Edit: Also as mentioned in the comments the font-weight is set to bold by default and you are loading a light font.

like image 27
Guy Avatar answered Sep 19 '22 17:09

Guy