首页›Raph Levien›文章

Minikin retrospective

2022年11月8日

AI 摘要 AI 生成,可能有误

In this retrospective, the author, who wrote the original Minikin text layout engine for Android around 2013, describes its design, which was shaped by compatibility with Android's text APIs and includes features like a Knuth-Plass-inspired line breaking algorithm optimized for mobile, itemization based on font fallback chains with bitmap acceleration, and handling of emoji presentation and backspace deletion. He encourages those working on text layout projects (such as new Rust efforts like cosmic-text and parley) to study existing open source codebases, since the knowledge is arcane and documentation scarce. He points readers to resources including the newly released 2013 Project Minikin slide deck, an LWN article, and his 2015 ATypI talk, noting that Flutter's LibTxt was originally based on Minikin.

There’s a lot of new interest in open source text layout projects, including cosmic-text, and the parley work being done by Chad Brokaw. I’m hopeful we’ll get a good Rust solution soon.

I encourage people working on text to study existing open source code bases, as much of the knowledge is arcane, and there is unfortunately no good textbook on the subject. Obviously browser engines facilitate extremely sophisticated layout, but because of their complexity and the constraints of HTML and CSS compatibility, they may be hard going. The APIs of DirectWrite and Core Text are also worthy of study, but unfortunately their implementations remain closed.

An interesting codebase is Minikin. It powers text layout in the Android framework. I wrote the original version starting back around 2013, but it is since maintained by the very capable Android text team.

继续阅读全文

为了尊重作者,这里只展示开头几段。你可以去原文阅读,或者在 HorizonReader 里读:划线做笔记、让 AI 帮忙。

更多来自 Raph Levien

I want a good parallel computer

AI 摘要The article argues that GPUs, despite being 10-100x more powerful than CPUs, are prevented from becoming general-purpose parallel computers by an impoverished execution model and inadequate languages and tools, illustrated by the author's struggles with bounded memory in the Vello 2D renderer. Reviewing historical designs like the Connection Machine, Cell, and Larrabee, the author shows that promising parallel architectures existed but failed to catch on, leaving today's overly complex GPUs and limited AI accelerators. With workloads increasingly shifting toward compute, the author believes a simpler, more powerful parallel computer is possible and points to paths forward such as chips with large grids of CPU cores.

A note on Metal shader converter

AI 摘要The author critiques Apple's new Metal shader converter, which eases porting DirectX 12 games by translating DXIL/HLSL shaders to Metal, arguing it adds underspecified complexity rather than advancing robust GPU infrastructure. A key complaint is that Metal remains the only major GPU API lacking device-scope atomic barriers (present in HLSL since Direct3D 11 in 2009), which prevents single-pass prefix sum implementations and reliable cross-threadgroup coordination, and in turn holds back WebGPU's performance. The author recommends Apple document which HLSL features are unsupported, and points to WebGPU and Asahi Linux's work as more promising paths toward well-specified, portable GPU compute.

Simplifying Bézier paths

AI 摘要The article describes refinements to curve-fitting techniques for approximating arbitrary curves with near-optimal Bézier paths, implemented in the Rust library kurbo, built around a new ParamCurveFit trait and efficient error evaluation using Green's theorem area/moment prefix sums. It covers error metrics, favoring Fréchet distance approximated via Tiller-Hanson ray casting, with a slower but more robust arc-length approach used for 'spicy' high-curvature regions, and goes beyond simple adaptive subdivision by optimizing subdivision point placement to minimize segment count. Finally, it addresses an unexpected problem where aggressively Fréchet-optimized curves develop bumps, solved by penalizing extreme control-point configurations to keep the output smooth at a cost of only one additional segment.

Moving from Rust to C++

AI 摘要This is a satirical April Fools' post in which the author, a longtime Rust developer, mock-announces that the Linebender GUI projects will migrate from Rust to C++. In a deliberately persuasive style, the piece humorously dismisses memory safety concerns, praises C++'s abundance of build systems and rapid language evolution, and claims the C++ community is friendlier. The post is intended to satirize bad arguments commonly made against Rust, with the author noting afterward that its serious points and tone confused some readers.

Requiem for piet-gpu-hal

AI 摘要The article explains why the Vello 2D GPU renderer (formerly piet-gpu) abandoned piet-gpu-hal, its hand-rolled GPU abstraction layer, in favor of wgpu and the WebGPU/WGSL ecosystem. Although the custom layer achieved goals like precompiled shaders (saving binary size and startup time) and access to advanced GPU features such as subgroups and descriptor indexing, wgpu offers a better developer experience, community tooling, and web deployment. The author reflects on lessons learned, notes WebGPU pain points, and says the roadmap may eventually revisit precompiled shaders and native back-ends to regain those lost capabilities.