DEV Community

Cover image for Fix jagged fonts in Chrome/WebKit
Adam K Dean
Adam K Dean

Posted on

2

Fix jagged fonts in Chrome/WebKit

Just a quick post today, more of a reminder for myself than anything. The following is a great way to fix jagged fonts when using font kits with Chrome/WebKit based browsers.

The following is what you'd expect to see when defining a font face:

@font-face {
  font-family: 'FontName';
  src: url('../fonts/FontName.eot');
  src: url('../fonts/FontName.eot?#iefix') format('embedded-opentype'),
       url('../fonts/FontName.woff') format('woff'),
       url('../fonts/FontName.ttf') format('truetype'),
       url('../fonts/FontName.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}
Enter fullscreen mode Exit fullscreen mode

Well, apparently Chrome uses the SVG and does not like it coming last.

Append this to your CSS and you'll get much better results:

@media screen and (-webkit-min-device-pixel-ratio:0) {
  @font-face {
    font-family: 'FontName';
    src: url('../fonts/FontName.svg') format('svg');
  }
}
Enter fullscreen mode Exit fullscreen mode

Without fix, and with the fix:

Fix jagged fonts in Chrome/WebKit

Sentry blog image

Identify what makes your TTFB high so you can fix it

In the past few years in the web dev world, we’ve seen a significant push towards rendering our websites on the server. Doing so is better for SEO and performs better on low-powered devices, but one thing we had to sacrifice is TTFB.

Read more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay