News for hackers. Stuff that matters.
Re:How to avoid layout shifts caused by web fonts by bruce343434 on Sunday January 30, 2022 @05:49AM (#30135748)
Why not just `body {font-family: sans-serif}`? Like, you don't have to explicitly enumerate all sans-serif system fonts ever. The browser will handle it.
Re:How to avoid layout shifts caused by web fonts by capableweb on Sunday January 30, 2022 @06:39AM (#30136133)
Sometimes you care a lot about the design of the website and that everything looks 100% OK in all browsers and screen-sizes. For example, think web agency landing pages, where you're supposed to sell your service to potential customers.

In those cases, using whatever font is usually not good enough, because many of them have different sizes (both length-wise, height-wise and line-height-wise), so if a user gets a different font loaded than what you have tested with, it could at best just have a different size (right-side of the text is now 3px away from the side rather than 6px for example) and at worst introduce line-breaks in your buttons that only expects one line of text, making everything look very fugly.

Re:How to avoid layout shifts caused by web fonts by maccard on Sunday January 30, 2022 @11:56AM (#30138754)
If you care that much you need to bundle the font with your site.
Re:How to avoid layout shifts caused by web fonts by capableweb on Monday January 31, 2022 @07:15AM (#30147133)
Yeah, I mean... Yeah. How is that an argument for just using `body {font-family: sans-serif}`?
Re:How to avoid layout shifts caused by web fonts by Spivak on Sunday January 30, 2022 @01:07PM (#30139480)
Which is what web fonts are. But you still have to handle the case and do something reasonable if the user or user-agent doesn’t load web fonts.
Re:How to avoid layout shifts caused by web fonts by augustuspolius on Sunday January 30, 2022 @06:38AM (#30136131)
Because they want to have a tighter control of user experience, which includes the choice of the font used to display text. So they list their preferred fonts first, with fallback fonts at the end.

It’s a fair reason with an appropriate CSS pattern.

Re:How to avoid layout shifts caused by web fonts by necovek on Sunday January 30, 2022 @09:10AM (#30137322)
I, like the GP, fail to see how listing dozens of fonts of completely different nature (x-height, line-height, width, proportions, weight...) provides any "control of the user experience".

This seems to be developed for browsers which do not default to system-wide fonts: which ones are those today?