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•3h 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

Show HN: A game where you build a GPU

https://jaso1024.com/mvidia/
184•Jaso1024•2h ago•41 comments

Show HN: TurboQuant-WASM – Google's vector quantization in the browser

https://github.com/teamchong/turboquant-wasm
68•teamchong•4h ago•2 comments

Show HN: sllm – Split a GPU node with other developers, unlimited tokens

https://sllm.cloud
51•jrandolf•3h ago•30 comments

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

https://github.com/hybroai/hybro-hub
7•kevinlu•1h ago•2 comments

Show HN: Kaoslabs – High-intensity AI video and visual experiments

https://kaoslabs.org
2•wilhart•2h ago•0 comments

Show HN: DocMason – Agent Knowledge Base for local complex office files

https://github.com/jetxu-llm/docmason
4•Jet_Xu•2h ago•0 comments

Show HN: Pluck – Copy any UI from any website, paste it into AI coding tools

https://www.pluck.so/
7•bring-shrubbery•7h ago•10 comments

Show HN: I built a frontpage for personal blogs

https://text.blogosphere.app/
734•ramkarthikk•1d ago•188 comments

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

5•ahmadparizaad•3h ago•0 comments

Show HN: Apfel – The free AI already on your Mac

https://apfel.franzai.com
699•franze•1d ago•144 comments

Show HN: A simple iOS app that helps you give yourself some time"

https://apps.apple.com/tr/app/alnuo/id6761344069
4•sezginozgur•4h ago•0 comments

Show HN: I made open source, zero power PCB hackathon badges

https://github.com/KaiPereira/Overglade-Badges
4•kaipereira•4h ago•0 comments

Show HN: Semsei — AI SEO for clicks, not impressions

https://www.semsei.io/en
6•andresdvelez•4h ago•3 comments

Show HN: Tokencap – Token budget enforcement across your AI agents

https://github.com/pykul/tokencap
4•pykul•4h ago•0 comments

Show HN: Travel Hacking Toolkit – Points search and trip planning with AI

https://github.com/borski/travel-hacking-toolkit
81•borski•16h ago•36 comments

Show HN: ctx – an Agentic Development Environment (ADE)

https://ctx.rs
46•luca-ctx•1d ago•51 comments

Show HN: Ownscribe – local meeting transcription, summarization and search

https://github.com/paberr/ownscribe
3•paberr•6h ago•0 comments

Show HN: AdaShape-3D modeler for intuitive 3D printing parts / Windows 11

https://adashape.com
3•fsloth•6h ago•2 comments

Show HN: Ismcpdead.com – Live dashboard tracking MCP adoption and sentiment

https://ismcpdead.com
35•sagirodin•23h ago•21 comments

Show HN: Mtproto.zig – High-performance Telegram proxy with DPI evasion

https://github.com/sleep3r/mtproto.zig
18•slp3r•21h ago•13 comments

Show HN: Tusk for macOS and Gnome

https://shapemachine.xyz/tusk/
3•factorialboy•8h ago•0 comments

Show HN: Made a little Artemis II tracker

https://artemis-ii-tracker.com/
148•codingmoh•1d ago•55 comments

Show HN: Deeplink – Go library for short links, click tracking, and OG previews

https://github.com/yinebebt/deeplink
3•yinebeb_sc•9h ago•2 comments

Show HN: ZipSee – explore remote ZIP archives using HTTP range requests

https://zipsee.pages.dev/
4•vsekar•9h ago•1 comments

Show HN: Dull – Instagram Without Reels, YouTube Without Shorts (iOS)

https://getdull.app
151•kasparnoor•2d ago•117 comments

Show HN: Docking – extensible Linux dock in Python

https://docking.cc
3•edumucelli•10h ago•0 comments

Show HN: DotReader – connects ideas across your books automatically

https://dotreader.info
5•efecerre•18h ago•1 comments

Show HN: Web Push Notifications for Hacker News

https://hn-push.val.run
3•kinlan•11h ago•2 comments

Show HN: GraphReFly – Reactive graph protocol for human and LLM co-operation

https://graphrefly.dev/
5•clfhhc•11h ago•2 comments

Show HN: TinyOS – A minimalist RTOS for Cortex-M written in C

https://github.com/cmc-labo/tinyos-rtos
99•hpscript•21h ago•42 comments