pathfinder
pathfinder copied to clipboard
weird text rendering feature: "text-combine-upright"
I was just auditing where we fallback on drawing text in webrender, and I found this extremely obscure feature that I disabled years ago and forgot about:
https://searchfox.org/mozilla-central/source/layout/painting/nsDisplayList.cpp#9474-9511
Basically text-combine-upright is used to draw arabic numbers horizontally in vertical text, with the specifically interesting property of: if the text would overflow the column squish it to fit.
Simple HTML page demonstrating this:
data:text/html,<html><head><meta charset="utf8"></head><body style="font-family: sans-serif; width: 100%"><div><div style="writing-mode:vertical-rl;">%E4%BD%A0%E5%A5%BD<span style="text-combine-upright:all">1</span><span style="text-combine-upright:all">12</span><span style="text-combine-upright:all">123</span><span style="text-combine-upright:all">1234</span><span style="text-combine-upright:all">12345</span>%E4%BD%A0%E5%A5%BD</div></div></body></html>
<html>
<head>
<meta charset="utf8">
</head>
<body style="font-family: sans-serif; width: 100%">
<div>
<div style="writing-mode:vertical-rl;">你好<span style="text-combine-upright:all">1</span><span style="text-combine-upright:all">12</span><span style="text-combine-upright:all">123</span><span style="text-combine-upright:all">1234</span><span style="text-combine-upright:all">12345</span>你好
</div>
</div>
</body>
</html>
It's possible we could implement this natively in WR now in a similar way to gecko: wrap everything in a context/frame with a horizontal scale transform to just squish everything. Haven't tried it since this is a truly niche thing and it's not a big deal to fallback on. Just thought this would be interesting to toss your way as an interesting text rendering usecase.
I think this is mostly a skribo
bug, but certainly something to keep in mind.