frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

Open in hackernews

Font-size-adjust Is Useful

https://matklad.github.io/2025/07/16/font-size-adjust.html
152•Bogdanp•3d ago

Comments

mananaysiempre•10h ago
This is an incidental annoyance, but I have to ask somewhere: why have we decided that the FOUC (“flash of unstyled content”) caused by laying out the page twice, once without and once with the fonts, is such a dire problem that it’s worth blocking the page’s first usable render behind a ~1MB resource? If memory serves, that decision is from before the twilight of the Web of documents, a time when div soup and inline styles (now replaced by Tailwind) were widely frowned upon.

Why is it OK to leave a user on a slow or high-latency connection staring at a blank skeleton of a page, as though written in invisible ink, for several seconds? I still remember using Opera because it had a toggle for “cached images only”. What happened?

pitaj•10h ago
I think the best solution for this is to just not use webfonts, and in fact use the system font instead.
Brajeshwar•10h ago
I don’t have extensive experience on this yet, but I believe this is also a solved issue (using custom fonts). Serve the font-family from the same source as the website, preload only the primary font-style (say “normal”), and custom-pick the font to just the Latin subset. That should be fast enough that almost none will notice, except for the pedantic developers like us (personally, I can forgive that).

Henceforth, let the others (styles, variable, etc) kick in as needed.

wonger_•2h ago
Yep, that's what I do on my website (except for the Latin subset). Still noticeable on spotty connections, like on a phone in a dead zone.
Filligree•10h ago
Which system font? There’s no standards here; each operating system has their own, with no guarantees as to what is available.

Until OS developers get their house in order, designers will keep on ignoring them.

mananaysiempre•9h ago
Partly, the answer is “tough”. As a designer, you don’t and aren’t meant to have pixel-level control over the screen contents. Web is not print. Don’t ask for the PostScript standard fourteen. (Somehow this lesson comes through much better for reflowable ebooks.)

Partly, I am willing to admit that web fonts are still nice when you can get them. But they’re too unwieldy to block on (slow connections exist; font foundries are assholes[1]; etc.), and we don’t really have a solution (the problem with FOUC is not the unstyled content, it’s the layout shift).

[1] https://jakearchibald.com/2021/f1-perf-part-1/

luckylion•9h ago
While I'm absolutely not a design-should-rule-all person, I think there's quite a range between "pixel-level control" and "you can't choose which font to use".

If we'd reliably have the top 50 google fonts on every OS, there'd be a lot less webfonts used.

mrec•9h ago
From https://developer.mozilla.org/en-US/docs/Web/CSS/font-family :

    system-ui

    Glyphs are taken from the default user interface font
    on a given platform. Because typographic traditions vary
    widely across the world, this generic is provided for 
    typefaces that don't map cleanly into the other generics.
reaperducer•9h ago
Which system font? There’s no standards here;

Yes, there is:

   font-family: system-ui;
Vvector•9h ago
Just brainstorming here, why can't we have "browser fonts" shipped with the browsers?
skydhash•9h ago
There's serif, sans-serif, monospace,... That's more than enough to present any content.
bmacho•8h ago
Even better: we have OS fonts shipped with the OS, also users can install additional fonts for all the applications to use.
valadaptive•9h ago
You can also subset your fonts; e.g. if your content is in a language that uses the Latin alphabet, then you only need to include those characters in your font. Between that, variable fonts, and WOFF2, I've managed to get Inter down to 50kB (plus another 50 if you need real italics).
mediumsmart•8h ago
I get Inter at 77kb but that includes 8 language versions of the site... or should it be less?
Joeri•7h ago
Or just use any of the font stacks from https://modernfontstacks.com/
yoz-y•5h ago
I like custom fonts, but I must say I like this. Will use it on my blog.
leptons•7h ago
>(now replaced by Tailwind)

Speak for yourself. Tailwind isn't universal.

esperent•7h ago
> why have we decided that the FOUC (“flash of unstyled content”) ... is such a dire problem

I think the answer is that different people are sensitive to different things. I'll often come across articles going to great length to reduce some minor jank in animations or page load, and I'll be looking at it thinking yeah, I can see it, but it really doesn't bother me enough to fix. Certainly not by going to these lengths.

Meanwhile, FOUC bothers me a lot, to the point where I can't understand that its accepted in any form. I'd much rather that I don't get shown the page at all until the real font is loaded. Otherwise my eye will have tracked to the text, started reading and then there's a jarring reflow and I lose my place and have to find it again. If I'm scanning for information through lots of websites, it does mentally tire me.

saurik•5h ago
I think there are different use cases, though; like, I agree with you that I find it really really annoying when I'm starting to read a paragraph of text... but, for the various buttons and navigation structure--even the headings--having them temporarily in the wrong font is a major win, as it lets me start to orient myself into the page (and might even help me get to my next nav point and out of the site before the font even bothers to load).
dawnerd•5h ago
Leaving the page blank isn’t the solution but if you want to blame anyone blame Google. Everyone chases their web best practices that Google can’t even be bothered to follow. Maybe with ai killing search we can get back to building sites the right way.
seanwilson•4h ago
> why have we decided that the FOUC (“flash of unstyled content”) caused by laying out the page twice, once without and once with the fonts, is such a dire problem that it’s worth blocking the page’s first usable render behind a ~1MB resource?

Why do you think that's a majority view? Google's page speed metric which they use as a SEO signal is followed by many webdevs and it very strongly encourages displaying text with system fonts while custom fonts load, and that the top of the page is displayed quickly:

"Ensure text remains visible during webfont load ... Fonts are often large files with slow load times. Some browsers hide text until the font loads, causing a flash of invisible text (FOIT)."

https://developer.chrome.com/docs/lighthouse/performance/fon...

"First Contentful Paint (FCP) is an important, user-centric metric for measuring perceived load speed because it marks the first point in the page load timeline where the user can see anything on the screen—a fast FCP helps reassure the user that something is happening."

https://web.dev/articles/fcp

If you hide the page content from displaying until custom fonts load and your header image loads for example, you'll likely get a red/unacceptable score.

Culonavirus•2h ago
Yea but the same POS company then tells you CLS bad mkaaaay... and guess what FOUC causes, layout shifts... (sorry, I got carried away with all the acronyms haha)
seanwilson•1h ago
> tells you CLS bad mkaaaay... and guess what FOUC causes, layout shifts

I haven't had a problem here (with layout shift). As long as you specify width + height of images in the HTML, and you don't have dynamic content pushing the layout about as it loads it in your page header, you'll likely get a high CLS score as it has some leeway.

And sounds like `font-size-adjust` from the OP is helpful in avoiding layout shift when the stand-in font is swapped out for the custom font when it arrives? I haven't found this necessary though.

Waterluvian•9h ago
Oh wow. I love this. I think this is precisely what I’ve needed when I want to use fonts and emojis as icons in my toy games but they’re just never consistent.
vessenes•9h ago
That is a great use case! More compelling than the original blog post I think.
lucb1e•29m ago
Monospaced fonts always bother me when I use them in emails or on websites. Never the same size as the prose. This is great for websites at least! Wonder if I could find an HTML mode to use in Thunderbird and if any email client would understand this css directive
alberth•9h ago
Text-Box

I’m probably missing the obvious but how is font-size-adjust different from text-box-trim.

https://github.com/jantimon/text-box-trim-examples

throwanem•9h ago
That adjusts leading (from the material originally used, so rhymes with "breading") and thus space between lines.

This adjusts properties such as x- and cap heights, which determine relative proportions of characters within the line. For example, in a browser supporting font-size-adjust, any font can be used as small caps.

rpastuszak•5h ago
I wrote a quick note on that:

Leading or Line Height - a Measured Response

https://untested.sonnet.io/notes/leading-or-line-height-a-me...

lelandfe•9h ago
Please don’t inline a whole font to avoid a momentary flash. You’re worsening every page’s load to avoid a stutter on one.

Here’s what is still the authority on this https://www.industrialempathy.com/posts/high-performance-web...

matklad•6h ago
To clarify, "specify @font-face inline" meant to say that the font's URL should be in the `head`, not the actual font bytes. The linked page includes `<link href="/fonts/GeistVF.woff2" rel="preload" type="font/woff2" as="font" crossorigin="">` in the `head`, which is another (probably better) way to achieve "font URL in the head" outcome.

But I must say I don't agree with `font-display: optional` advice. It indeed maximize the LCP and CLS metrics, but it does that to the extent that the results become detrimental to the user experience. Like, if I open that link in a private window, and then hit refresh, the layout shifts, because I don't have their custom font on the first load, but do have it on the second one. This doesn't make sense! Do you want me to see your custom font or not?

I would say that if you _really_ care about the page being ready as fast as possible, you should use `font-style: system-ui`. If you _really_ care about your fonts, you should use `font-display: auto` or `font-display: block` (and, yes, tweak fallback font metrics). If you care about _both_, tough luck, they are inherently in conflict and you need to pick one side. `font-display: optional` let's you formally pass the automated test with flying colors, but doesn't seem to result in actually useful behavior?

adregan•9h ago
Those sound like the exact same use case in the end as both are concerned with what happens to the texture of a page were the font to change.
hiccuphippo•9h ago
Is there a way to make the text fill the box in 1 line? So short text shows with a bigger font and longer text shows with a smaller font. The only way I found was multiple passes with javascript.
bawolff•8h ago
I think there is a hack you can do with scroll driven animation https://frontendmasters.com/blog/edge-to-edge-text/
kbelder•8h ago
My hot take is that browsers should never have enabled you to specify an exact font. The web would be much better off if it was accepted that the server could only suggest how the content is displayed, not control it.
ironmagma•8h ago
That’s how it was for over a decade, with the browser quirks and inconsistent behavior. Why is that good?
throwanem•5h ago
This works when users broadly understand the concept of a user agent, which has not ever really been the case in the general sense, and indeed we observe a historical trend toward increase in the conceptual distance between usership and agency.

Your hot take reduces to that the web should never have become a product, which is equally defensible and in my view the formulation more likely productive of interestingly nuanced discussion. For example, we could critique the Gopher and Gemini crowds' sort of conceptually Sapir-Whorf-esque approach to at least notional redress, or ask what effect clientside inference might come to have.

bawolff•8h ago
I think the reason most people dont consider font-adjust useful, is if you are explicitly chosing fonts you are going to chose ones with compatible metrics.
webstrand•8h ago
That is hard to do in my experience, when only using free fonts. I'm wondering if this works on icon fonts, which are not fun to deal with when they don't align correctly.
MBCook•5h ago
I think the argument you may change the fonts in the future presented in the article a great counterpoint.

You can ensure the size won’t change even in the future with a font that hasn’t even been designed yet.

That’s a nice benefit.

bee_rider•8h ago
Font designers intentionally decided to define things based on the size of that box, rather than the size of the x, right? I bet they did that for a reason.
Eric_WVGG•6h ago
I believe the bounding box has to fit all the possible ascenders and descenders etc., so the em-height is proportioned within the box to whatever the highest and lowest marks in the typeface are.

But this technique isn’t correcting for some kind of mistake the typographer theoretically made, it’s adjusting for the fact that CSS sizes by the bounding box instead of the em-height. The font itself is unchanged and renders exactly how it’s designed, this just lets us use it in a more intuitive way.

IMO sizing by bounding-box was the wrong move in the original CSS spec, but that’s how digital type renderers have worked going back to the eighties, so the whole thing was probably too entrenched in the first place. And I have no idea if font standards of the day even had em-heights encoded in a way that could be read in font metadata.

Anyway, this whole feature is news to me, can’t wait to try it. Between this and text-box-trim (life changing), I’ve never been happier with web design.

sigil•2h ago
> I believe the bounding box has to fit all the possible ascenders and descenders etc., so the em-height is proportioned within the box to whatever the highest and lowest marks in the typeface are.

I wish it were this simple.

The em square != the bounding box of all glyphs. The em square is defined by the font's ascent & descent vertical metrics, which are set by the font designer.

There are reasons why you might want glyphs to escape the em square. Perhaps you're typesetting English text without accent marks above capitals, and using the bounding box's vertical maximum would introduce too much line space. Or perhaps you're using a decorative font which is designed to escape the em square, and potentially even overlap the em squares of lines above and below, like this: https://alangrow.com/images/blog/script-font-escaping-em-squ...

To make matters worse, and mostly for legacy reasons, there are THREE different sets of ascent & descent metrics in a font file. Which is used depends on your OS and the software rendering the font. But the Webfont Strategy described here is a nice one, because you can use the bounding box (winAscent & winDescent) if you really need to, say because any glyph might be used and you want to avoid em square escape: https://glyphsapp.com/learn/vertical-metrics

plorkyeran•4h ago
Font size being the bounding box means that you can determine the line height from just the font size with no knowledge of the font itself, which makes layout simpler. This was significant in the 80s when the convention was established, but probably isn't today in the context of the dramatically more complicated CSS layout engines.
drewbeck•4h ago
Font files are based on the original “font”, which was a drawer of metal type. Metal type size was based on the full piece of metal which was sized based on the full extent of the typeface, including capitals, ascenders and descenders. When typesetting went digital it made sense to continue with this approach since the industry needed a plug-n-play way to use digital assets; that is, a typesetter could use the same concepts and language that existed for physical type as well.

As a long time print and digital designer I’m very excited to have these new type tools that meet the needs of digital typesetting on the web!

mcculley•7h ago
Is there is a way to automatically tell HTML/CSS to adjust the font size automatically? For example, iOS UILabel has adjustsFontSizeToFitWidth. Does HTML have anything similar?
Eric_WVGG•6h ago
I don’t believe so. It would be hugely useful, but I have found the iOS implementation to be kind of wonky, so I’d rather it not come to web unless the idea can be perfected.

Also I think a proper implementation would require reference to line count in the CSS markup, and CSS seems to have an awful time with properties that depend on character or line counts. We still don’t have working line-clamp!

ex.

  div {
    font-size: 24px;
  }
  div[line-count > 2] { // doesn’t exist, and must be difficult to implement
    font-size: fit-width; // … what about vertical text?
    min-font-size: 8px; // maintain legibility
    max-font-size: 28px; // why not
  }
Sure would make a lot of my designers happy, though…

Resizable Structs in Zig

https://tristanpemble.com/resizable-structs-in-zig/
64•rvrb•2h ago•21 comments

Epic Recall, Epic Fail

https://taipology.substack.com/p/epic-recall-epic-fail
55•hunglee2•3h ago•3 comments

How We Rooted Copilot

https://research.eye.security/how-we-rooted-copilot/
225•uponasmile•8h ago•99 comments

Asyncio: A library with too many sharp corners

https://sailor.li/asyncio
7•chubot•59m ago•1 comments

Personal aviation is about to get interesting (2023)

https://www.elidourado.com/p/personal-aviation
14•JumpCrisscross•1h ago•2 comments

Paul Dirac and the religion of mathematical beauty (2011) [video]

https://www.youtube.com/watch?v=jPwo1XsKKXg
20•magnifique•2h ago•2 comments

Show HN: QuickTunes: Apple Music player for Mac with iPod vibes

https://furnacecreek.org/quicktunes/
13•albertru90•51m ago•2 comments

What went wrong for Yahoo

https://dfarq.homeip.net/what-went-wrong-for-yahoo/
104•giuliomagnifico•6h ago•105 comments

Purple Earth hypothesis

https://en.wikipedia.org/wiki/Purple_Earth_hypothesis
155•colinprince•2d ago•47 comments

Rust running on every GPU

https://rust-gpu.github.io/blog/2025/07/25/rust-on-every-gpu/
465•littlestymaar•14h ago•161 comments

Arvo Pärt at 90

https://www.theguardian.com/music/2025/jul/24/the-god-of-small-things-celebrating-arvo-part-at-90
28•merrier•3h ago•7 comments

Tinyio: A tiny (~200 line) event loop for Python

https://github.com/patrick-kidger/tinyio
20•tehnub•4d ago•11 comments

OCaml Programming: Correct and Efficient and Beautiful

https://cs3110.github.io/textbook/cover.html
76•smartmic•3h ago•18 comments

Getting decent error reports in Bash when you're using 'set -e'

https://utcc.utoronto.ca/~cks/space/blog/programming/BashGoodSetEReports
48•zdw•2d ago•18 comments

Test Results for AMD Zen 5

https://www.agner.org/forum/viewtopic.php?t=287&start=10
189•matt_d•5h ago•33 comments

Torqued Accelerator Using Radiation from the Sun (Tars) for Interstellar Payload

https://arxiv.org/abs/2507.17615
9•virgildotcodes•1h ago•1 comments

Large ancient Hawaiian petroglyphs uncovered by waves on Oahu

https://www.sfgate.com/hawaii/article/hawaii-petroglyphs-uncovered-20780579.php
63•c420•4d ago•19 comments

The natural diamond industry is getting rocked. Thank the lab-grown variety

https://www.cbc.ca/news/business/lab-grown-diamonds-1.7592336
108•geox•12h ago•142 comments

Font-size-adjust Is Useful

https://matklad.github.io/2025/07/16/font-size-adjust.html
152•Bogdanp•3d ago•47 comments

Millet mystery: Why staple crop failed to take root in ancient Japanese kitchens

https://phys.org/news/2025-07-millet-mystery-staple-crop-root.html
10•PaulHoule•3d ago•0 comments

Algorithm for simulating phosphor persistence of analog oscilloscopes

https://richardandersson.net/?p=350
11•pillars•2d ago•4 comments

Shallow Water Is Dangerous Too

https://www.jefftk.com/p/shallow-water-is-dangerous-too
63•surprisetalk•3d ago•23 comments

Getting into Flow State with Agentic Coding

https://kau.sh/blog/agentic-coding-flow-state/
24•vortex_ape•1h ago•9 comments

Coronary artery calcium testing can reveal plaque in arteries, but is underused

https://www.nytimes.com/2025/07/26/health/coronary-artery-calcium-heart.html
9•brandonb•2h ago•6 comments

CCTV footage captures video of an earthquake fault in motion

https://www.smithsonianmag.com/smart-news/cctv-footage-captures-the-first-ever-video-of-an-earthquake-fault-in-motion-shining-a-rare-light-on-seismic-dynamics-180987034/
402•chrononaut•21h ago•76 comments

The Sail instruction-set semantics specification language

https://alasdair.github.io/manual.html
20•weinzierl•4h ago•5 comments

Inverted Indexes: A Step-by-Step Implementation Guide

https://www.chashnikov.dev/post/inverted-indexes-a-step-by-step-implementation-guide
60•klaussilveira•3d ago•20 comments

Open Sauce is a confoundingly brilliant Bay Area event

https://www.jeffgeerling.com/blog/2025/open-sauce-confoundingly-brilliant-bay-area-event
303•rbanffy•3d ago•174 comments

Marine biologist for a day: Ars goes shark tagging

https://arstechnica.com/science/2025/07/marine-biologist-for-a-day-ars-goes-shark-tagging/
6•LorenDB•3d ago•0 comments

Breaking the WASM/JS communication performance barrier

https://github.com/ealmloff/sledgehammer_bindgen
118•weinzierl•3d ago•25 comments