Saturday, June 28, 2025
News PouroverAI
Visit PourOver.AI
No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing
News PouroverAI
No Result
View All Result

How I Solved My Font Rendering Problem

February 13, 2024
in Front-Tech
Reading Time: 4 mins read
0 0
A A
0
Share on FacebookShare on Twitter


Since I redesigned this website last year, an issue with the heading font has been bugging me. I’d noticed that, unlike in other browsers, in Safari on iOS the headings rendered poorly, slightly blurry, as if they’d been faux-bolded. Googling the problem was coming up with nothing, but I’m using a variable font, so I figured perhaps that had something to do with it not being a super-common issue.

Font rendering in iOS: Before and after fixing.

I’m happy to say, I’ve figured it out and finally implemented a fix. It involved learning a thing or two about @font-face.

The @font-face at rule is where we specify a font for use in our CSS. Most of the time I don’t give it too much thought. I specify a few things:

The font family (How you want to refer to it in the CSS font-family property. Usually the name of the font, but it can be anything you want.)
The src URL and font format. These days I tend to just go with WOFF2, as it’s well supported. Old browsers can fall back to a system font with no harm to the user.
font-display. This determines what happens during the period before the font has downloaded. I go with font-display: swap, which according to MDN, “gives the font face an extremely small block period and an infinite swap period.” In practice that means that during the font block period (before the font is downloaded) a fallback font will be used after a very short delay (up to 100ms according to the spec), which will then be swapped for the specified font once it’s downloaded.

@font-face {
font-family: ‘Urbanist’;
src: url(‘../fonts/urbanist.woff2’) format(‘woff2’);
font-display: swap;
}

There are a number of other properties that can be specified in the @font-face rule, not all of them necessary in all cases. But with variable fonts we need at least couple of things in order for our fonts to render reliably.

If our font variation is on the weight axis, we should set a range for the font-weight property. A range of 100 to 800 permits us to use any weight in that range (assuming they’re available in our font file).

@font-face {
font-family: ‘Urbanist’;
src: url(‘../fonts/urbanist.woff2’);
font-display: swap;
font-weight: 100 800;
}

Secondly, it’s recommended that we set ‘woff2-variations’ as the font format. In practice the font rendered fine with just the font-weight addition above, and MDN states that this isn’t strictly necessary. But what the hell, it’s a recommendation, so let’s add it. Now the @font-face declaration looks like this:

@font-face {
font-family: ‘Urbanist’;
src: url(‘../fonts/urbanist.woff2’) format(‘woff2-variations’);
font-display: swap;
font-weight: 100 800;
}

And now my fonts look beautiful everywhere!



Source link

Tags: cssFontfront endProblemRenderingSolvedweb designweb development
Previous Post

Knowledge Bases for Amazon Bedrock now supports Amazon Aurora PostgreSQL and Cohere embedding models

Next Post

BlackBerry aims for $100 million profit improvement By Investing.com

Related Posts

The essential principles of a good homepage
Front-Tech

The essential principles of a good homepage

June 7, 2024
How to measure and improve user retention
Front-Tech

How to measure and improve user retention

June 6, 2024
Push Animation on Grid Items
Front-Tech

Push Animation on Grid Items

June 5, 2024
How to build a Rails API with rate limiting
Front-Tech

How to build a Rails API with rate limiting

June 4, 2024
Introduction to the B.I.A.S. framework
Front-Tech

Introduction to the B.I.A.S. framework

June 3, 2024
Blue Ridge Ruby is exactly what we need
Front-Tech

Blue Ridge Ruby is exactly what we need

June 3, 2024
Next Post
BlackBerry aims for $100 million profit improvement By Investing.com

BlackBerry aims for $100 million profit improvement By Investing.com

Revolutionize Your Space: The Magic of Retractable Window Screens

Revolutionize Your Space: The Magic of Retractable Window Screens

A new way to let AI chatbots converse all day without crashing | MIT News

A new way to let AI chatbots converse all day without crashing | MIT News

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Trending
  • Comments
  • Latest
23 Plagiarism Facts and Statistics to Analyze Latest Trends

23 Plagiarism Facts and Statistics to Analyze Latest Trends

June 4, 2024
How ‘Chain of Thought’ Makes Transformers Smarter

How ‘Chain of Thought’ Makes Transformers Smarter

May 13, 2024
Amazon’s Bedrock and Titan Generative AI Services Enter General Availability

Amazon’s Bedrock and Titan Generative AI Services Enter General Availability

October 2, 2023
Is C.AI Down? Here Is What To Do Now

Is C.AI Down? Here Is What To Do Now

January 10, 2024
The Importance of Choosing a Reliable Affiliate Network and Why Olavivo is Your Ideal Partner

The Importance of Choosing a Reliable Affiliate Network and Why Olavivo is Your Ideal Partner

October 30, 2023
Managing PDFs in Node.js with pdf-lib

Managing PDFs in Node.js with pdf-lib

November 16, 2023
Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

Can You Guess What Percentage Of Their Wealth The Rich Keep In Cash?

June 10, 2024
AI Compared: Which Assistant Is the Best?

AI Compared: Which Assistant Is the Best?

June 10, 2024
How insurance companies can use synthetic data to fight bias

How insurance companies can use synthetic data to fight bias

June 10, 2024
5 SLA metrics you should be monitoring

5 SLA metrics you should be monitoring

June 10, 2024
From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

From Low-Level to High-Level Tasks: Scaling Fine-Tuning with the ANDROIDCONTROL Dataset

June 10, 2024
UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

UGRO Capital: Targeting to hit milestone of Rs 20,000 cr loan book in 8-10 quarters: Shachindra Nath

June 10, 2024
Facebook Twitter LinkedIn Pinterest RSS
News PouroverAI

The latest news and updates about the AI Technology and Latest Tech Updates around the world... PouroverAI keeps you in the loop.

CATEGORIES

  • AI Technology
  • Automation
  • Blockchain
  • Business
  • Cloud & Programming
  • Data Science & ML
  • Digital Marketing
  • Front-Tech
  • Uncategorized

SITEMAP

  • Disclaimer
  • Privacy Policy
  • DMCA
  • Cookie Privacy Policy
  • Terms and Conditions
  • Contact us

Copyright © 2023 PouroverAI News.
PouroverAI News

No Result
View All Result
  • Home
  • AI Tech
  • Business
  • Blockchain
  • Data Science & ML
  • Cloud & Programming
  • Automation
  • Front-Tech
  • Marketing

Copyright © 2023 PouroverAI News.
PouroverAI News

Welcome Back!

Login to your account below

Forgotten Password? Sign Up

Create New Account!

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In