Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wishlist: configure underline behavior wrt descenders #9

Open
callegar opened this issue May 21, 2021 · 3 comments
Open

Wishlist: configure underline behavior wrt descenders #9

callegar opened this issue May 21, 2021 · 3 comments

Comments

@callegar
Copy link

I wonder if it could be possible to make the package also support underlining at a tighter distance from the baseline omitting the descenders. The stackexchange discussion at https://tex.stackexchange.com/questions/36894/underline-omitting-the-descenders considers it using soul or ulem.

@zauguin
Copy link
Owner

zauguin commented Jul 4, 2021

This is unlikely to be implemented. Basically there are multiple issues which make this somewhat out of scope:

  1. luaul intentionally tries to reduce it's influence on the text beyond drawing the actual lines whenever possible to avoid any unintentional interference. This makes it very hard to implement a system which strongly depends on the structure of the individual characters.

  2. There are basically four possible implementation for this that I know of, all of them have significant issues:

    • Drawing all characters a second time in bolder and white to hide the underline around them. (This is AFAICT implemented in the linked StackExchange answers) This doesn't work with non white backgrounds (or at least has to be adapted, especially when the background is non uniform), the duplication can lead to issues around text extraction (since everything is present twice) and it's unclear how to handle non-text content (or boxed text content).
    • Enabling fill and stroke for glyph drawing (as done for FakeBold) and setting the stroke color to white. Similar issues as before for colors but no duplication. But it does make glyphs thinner than they are supposed to be which is often unacceptable.
    • Draw all glyphs a second time in a transparency knockout group to make the underline transparent around it. Solves the color issue but leads to insane overhead in the PDF file. Also has problematic interactions with other nodes. Doesn't interact properly with other uses of transparency.
    • Manually calculate intersections of the underline with the glyph outlines and then shorten the line. This is slow, hard to implement, extremely dependent on the font formats involved and breaks when any kind of non-text construct is encountered.
  3. Most of these approaches are pretty independent from the actual underlining and would belong into the glyph drawing code.

So I don't think that there is a reasonable way to implement this in a sufficiently stable and reliable way to fit into lua-ul and therefore should be implemented as separate functionality for now.

@callegar
Copy link
Author

callegar commented Jul 5, 2021

Most of these approaches are pretty independent from the actual underlining and would belong into the glyph drawing code.

I was sort of expecting something like that. Is there anything, at least wrt "modern" fonts (OTF) that could allow this to be done at the glyph drawing level? Namely, is there any concept of an "underlined" char that could be used?

@zauguin
Copy link
Owner

zauguin commented Jul 5, 2021

Namely, is there any concept of an "underlined" char that could be used?

No. OpenType fonts contain a suggested height and width for the underline (inherited from Type 1 fonts actually), but that's it. There is a specified flag to mark a font as underlined (for separate underlined fonts), but I'm not aware of any font actually having a separate underlined version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants