You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature requestNew feature or requestlayoutRelated to the layout category, which is about composing, positioning, etc.textRelated to the text category, which is all about text handling, shaping, etc.
I'm new to typst, so forgive me if I'm missing something.
Could you add more advanced, microtype/InDesign-like, things like protrusion?
Or if you already do support it (I see mention HZ algorithm), maybe take a look at the below.
Using Minion Pro, typst:
LuaLaTeX with microtype:
Reacted by Roland Fredenhagen, Falco Hirschenberger, Enivex, victor-sm, Lua Viana Reis , Adam Krellenstein, Tim Vilgot Mikael Fredenberg, Veirt, hurzl, Eduard Occhipinti and 13 more
Reacted by Jelle Feringa, Rik Huijzer, Eîar Abramski-Kronenberg and Camillo Visini
I'd like to implement the protrusion functionality. I did a bit of research and it seems even in texmacs and pdftex it's implemented with a heuristic lookup table Symbol -> Shift. Regardless of the font used.
A good source is the dissertation of Hàn Thế Thành, who wrote pdftex.
I wonder why it's done in such a simple and uncomplete way. Wouldn't it be possible to directly calculate glyph metrics like e.g. blackness, center of mass to align the border more precisely?
I'd like to implement the protrusion functionality. I did a bit of research and it seems even in texmacs and pdftex it's implemented with a heuristic lookup table Symbol -> Shift. Regardless of the font used.
A good source is the dissertation of Hàn Thế Thành, who wrote pdftex.
I wonder why it's done in such a simple and uncomplete way. Wouldn't it be possible to directly calculate glyph metrics like e.g. blackness, center of mass to align the border more precisely?
I would look to the microtype package, which is the one that implements the advanced features
There's a 270 page document on implementation details.
Yes, I know that, but on page 148 the author mentions that his protrusion is based on the tables that Hàn Thế Thành created in the dissertiation I mentioned above.
In any case, I don't claim to understand the nuances here, but I agree with you @hirschenberger that it'd be ideal to calculate the metrics rather than assume some fixed table.
The typesetting in the original image looks quite good. For me it looks much worse:
The problem in the algorithm used here is that when some line is too long or too short (which is not really that problematic),
the line is just broken and everything is kept like it is. That's a very fast algorithm.
But what is better is this one (top image).
Instead of just breaking the line, add to all horizontal spacing within the line the same amount of additional horizontal space,
so that the space at the end is now zero.
With this new algorithm we will achieve the top picture in the linked wikipedia image instead of the one I linked.
I think, this is the most important first step.
That doesn't look right. I think justification is disabled, either by accident or some bug.
Typst already does this, but it doesn't let all characters overhang by the same amount. You can see the ratios here. The behaviour can be disabled with this property. Could be made more configurable so that you can also have full overhang.
Typst already does this, but it doesn't let all characters overhang by the same amount.
Oh good, so the functionality is there; just a question of optimizing, and/or making it configurable, and/or automating optimization based on calculating the glyph metrics?
In the two examples I posted, the tex/microtype one clearly looks better, and that's without me doing any configuration.
In case it's useful: as of 0.15.0 text.overhang is still a bool, and the overhang amounts are a hardcoded table in typst-layout/src/inline/line.rs covering only dashes, hyphens, .,:; and two Arabic marks — letters get 0, so caps like W/A/V/T at a flush-left line start don't protrude. Looks like #7782 would make this configurable per-glyph (incl. by glyph name) on both margins.
feature requestNew feature or requestlayoutRelated to the layout category, which is about composing, positioning, etc.textRelated to the text category, which is all about text handling, shaping, etc.
Activity
hirschenberger commentedon Mar 25, 2023
I'd like to implement the protrusion functionality. I did a bit of research and it seems even in texmacs and pdftex it's implemented with a heuristic lookup table
Symbol -> Shift. Regardless of the font used.A good source is the dissertation of Hàn Thế Thành, who wrote pdftex.
I wonder why it's done in such a simple and uncomplete way. Wouldn't it be possible to directly calculate glyph metrics like e.g.
blackness,center of massto align the border more precisely?bdarcus commentedon Mar 25, 2023
I don't know. Maybe it wasn't convenient or possible to do that when it was first implemented?
Have you checked the luatex repo? Perhaps they asked the same question when working on it?
Or maybe just try it?
Enivex commentedon Mar 25, 2023
I would look to the microtype package, which is the one that implements the advanced features
https://ctan.org/pkg/microtype?lang=en
There's a 270 page document on implementation details.
hirschenberger commentedon Mar 25, 2023
Yes, I know that, but on page 148 the author mentions that his protrusion is based on the tables that Hàn Thế Thành created in the dissertiation I mentioned above.
bdarcus commentedon Mar 25, 2023
In any case, I don't claim to understand the nuances here, but I agree with you @hirschenberger that it'd be ideal to calculate the metrics rather than assume some fixed table.
bdarcus commentedon Mar 25, 2023
Was curious, and found this:
https://stackoverflow.com/questions/68151488/rusttype-get-text-width-for-font
Enivex commentedon Mar 29, 2023
That doesn't look right. I think justification is disabled, either by accident or some bug.
laurmaedje commentedon Apr 1, 2023
Typst already does this, but it doesn't let all characters overhang by the same amount. You can see the ratios here. The behaviour can be disabled with this property. Could be made more configurable so that you can also have full overhang.
bdarcus commentedon Apr 1, 2023
Oh good, so the functionality is there; just a question of optimizing, and/or making it configurable, and/or automating optimization based on calculating the glyph metrics?
In the two examples I posted, the tex/microtype one clearly looks better, and that's without me doing any configuration.
hirschenberger commentedon Apr 1, 2023
I'm currently working on a PR with a more complete protrusion table based on the values texmacs uses.
bdarcus commentedon Jun 22, 2023
Am I wrong, or did this get fixed at some point, so that you can close this?
Enivex commentedon Jun 22, 2023
It was never broken. I think it's still open because it can still be improved.
[-]Line layout, protrusion[/-][+]More configurable text overhang[/+]hurzl commentedon May 23, 2024
With LaTeX's microtype package
adamkrellenstein commentedon Jun 16, 2026
In case it's useful: as of 0.15.0
text.overhangis still a bool, and the overhang amounts are a hardcoded table intypst-layout/src/inline/line.rscovering only dashes, hyphens,.,:;and two Arabic marks — letters get 0, so caps like W/A/V/T at a flush-left line start don't protrude. Looks like #7782 would make this configurable per-glyph (incl. by glyph name) on both margins.