frontpage.
newsnewestaskshowjobs

Made with ♥ by @iamnishanth

Open Source @Github

fp.

Open in hackernews

Show HN: React hooks that predict text height before render, using font metrics

5•ahmadparizaad•2h ago
I built @pretext-studio/core to solve a specific annoyance: the browser won't tell you how tall a text block is until after it renders. This forces you into either a render-then-measure cycle (which causes layout shift) or hacks like max-height: 9999px for accordion animations (which makes easing look wrong because the animation runs over 9999px, not the actual content height).

The library wraps @chenglou/pretext, a pure-JS text layout engine that replicates the browser's line-breaking. algorithm using font metrics loaded once via the Font Metrics API. From there, computing height is arithmetic — no DOM, no getBoundingClientRect, no reflow. A prepare() call runs in ~0.03ms; a layout() call in under 0.01ms. Results are cached in a module-level LRU map so repeated calls for the same font/size pair are nearly free.

The main hooks are useTextLayout (height + line count for a block at a given width), useBubbleMetrics (finds the tightest width that preserves line count, which eliminates the dead space you get from CSS fit-content), and useStableList (pre-computes heights for a list of items before paint, useful for virtualized lists and masonry layouts). There's also a MeasuredText drop-in component with a debug overlay that draws predicted line boundaries over actual rendered text so you can see where predictions diverge.

The honest limitation: it only works with fonts you can load metrics for, so arbitrary system fonts or poorly-behaved variable fonts may drift. The isReady flag on every hook is false until font metrics load, so you need to gate renders on it when using web fonts. It also doesn't handle white-space: pre-wrap yet. Feedback welcome — especially if you've hit edge cases with font loading or non-Latin scripts.

GitHub: https://github.com/ahmadparizaad/pretext-studio-core — npm: @pretext-studio/core

Three months of agentic coding – my experience

https://meertens.dev/blog/three-months-of-agentic-coding/index.html
2•rmeertens•2m ago•0 comments

Sopwith

http://www.sopwith.org/
1•elvis70•3m ago•0 comments

One Month of Wispr: From First Release to CLI

https://stormacq.com/2026/03/30/one-month-of-wispr-from-first-release-to-cli
1•mariuz•4m ago•0 comments

Websites frozen in time: Pages abandoned in the 90s still live today [video]

https://www.youtube.com/undefined
1•souravmahapatra•5m ago•0 comments

Show HN: Bugparty.org an Ethereum-based forum and marketplace for agents

https://bugparty.org
1•stanleykm•7m ago•0 comments

US deploying nearly all stealthy long-range JASSM-ER cruise missiles to Iran war

https://www.msn.com/en-us/money/other/us-deploys-bulk-of-stealthy-long-range-missile-for-iran-war...
2•prmph•8m ago•0 comments

(Ab)use HDR images for marketing

https://tn1ck.com/blog/abuse-hdr-images-for-marketing
2•TN1ck•10m ago•2 comments

Apollo Guidance Computer Restoration Videos and Press Coverage

https://www.curiousmarc.com/space/apollo-guidance-computer
1•mariuz•10m ago•0 comments

Ultraplan with Claude Code

https://code.claude.com/docs/en/ultraplan
3•emschwartz•12m ago•1 comments

Reaffirming our commitment to child safety in the face of European Union inactio

https://blog.google/company-news/inside-google/around-the-globe/google-europe/reaffirming-commitm...
3•emptysongglass•13m ago•0 comments

Show HN: Running local OpenClaw together with remote agents in an open network

https://github.com/hybroai/hybro-hub
3•kevinlu•14m ago•0 comments

Chat Control: The Technical and Legal Case Against Mass Scanning

https://vixen.moe/chat-control-the-technical-and-legal-case-against-mass-scanning/
2•DarkGodErebus•14m ago•0 comments

Floating point from scratch: Hard Mode

https://essenceia.github.io/projects/floating_dragon/
1•random__duck•16m ago•0 comments

Scientists capture how cells trigger inflammation

https://news.stanford.edu/stories/2026/03/immune-response-inside-cells-inflammation-research
3•ohjeez•16m ago•0 comments

Ask HN: Best build in public/regular updates blogs?

2•suralind•17m ago•0 comments

Batteries-included terminal UI framework for Go

https://useglyph.sh/
2•DeveloperOne•17m ago•1 comments

37,000 AI-generated podcasts on Kaggle

https://www.kaggle.com/datasets/listennotes/ai-generated-fake-podcasts-spams
3•wenbin•24m ago•0 comments

Aspire Docs in Your Terminal (and Your AI's Brain)

https://devblogs.microsoft.com/aspire/aspire-docs-in-your-terminal/
1•vyrotek•29m ago•0 comments

Bazaarly – A Thought Exercise

https://blog.sayemahmed.com/p/bazaarly-a-thought-exercise-universe
1•sayembd•31m ago•0 comments

AI Agents to Organise My Secret Society's Dinners

https://chillphysicsenjoyer.substack.com/p/ai-agents-to-organise-my-secret-societys
2•crescit_eundo•33m ago•0 comments

Deafness reversed: One injection restores hearing in just weeks – ScienceDaily

https://www.sciencedaily.com/releases/2026/04/260403044651.htm
5•bilsbie•34m ago•1 comments

Beyond the Verdict: Holding Big Tech Accountable Isn't as Simple as It Seems

https://connectsafely.org/beyond-the-verdict-holding-big-tech-accountable-isnt-as-simple-as-it-se...
1•ohjeez•35m ago•0 comments

Plague Ships

https://www.afloat.com.au/feature/plague-ships/
3•bryanrasmussen•36m ago•0 comments

Mapping AI into Production: A Field Experiment on Firm Performance

https://papers.ssrn.com/sol3/papers.cfm?abstract_id=6513481
2•senko•39m ago•0 comments

Artemis II crew snaps portrait of Earth on their way to the moon

https://www.popsci.com/science/earth-photo-artemis-ii/
1•geox•44m ago•0 comments

Across the social sciences, half of research doesn't replicate

https://www.science.org/content/article/across-social-sciences-half-research-doesn-t-replicate
2•XzetaU8•44m ago•0 comments

Polymarket apologizes for allowing wagers on fate of U.S. pilots downed in Iran

https://www.nbcnews.com/news/us-news/polymarket-apologizes-allowing-wagers-fate-us-pilots-downed-...
5•ceejayoz•46m ago•2 comments

Malaysia's age verification rules for social media could be strictest

https://www.biometricupdate.com/202604/malaysias-age-verification-rules-for-social-media-could-be...
1•anonhaven•48m ago•0 comments

IBM 3270 Information Display System: Color and Programmed Symbols (1979) [pdf]

https://bitsavers.org/pdf/ibm/3278/GA33-3056-0_3270_Information_Display_System_Color_and_Programm...
2•hggh•49m ago•1 comments

Not all of this is new

https://www.natemeyvis.com/not-all-of-this-is-new/
1•Brajeshwar•51m ago•0 comments