latex-css icon indicating copy to clipboard operation
latex-css copied to clipboard

Not properly typeset

Open purpleidea opened this issue 4 years ago • 9 comments

Great idea, I love it! However the most important feature of LaTeX is proper typesetting, IOW, variable spaces, etc... Any way this can be implemented? I'm not sure how HTML would really support this. Perhaps that is an upstream browser issue that someone can fix first?

Cheers!

purpleidea avatar May 24 '20 14:05 purpleidea

I agree, but I doubt there is a way to properly typeset HTML. Hyphenation is a mess and having text-align: justify; doesn't really help. Check out this comment from yesterday's HN thread.

The line-height, font-size and letter-spacing can probably be tweaked, but other than that there is not much that can be done using CSS only in terms of typesetting. Hopefully, the situation improves in the near future.

vincentdoerig avatar May 24 '20 15:05 vincentdoerig

Yeah, I always hated reading on screens for exactly this purpose. Maybe it's time for HTML to grow up and grow proper type setting? Maybe you can use this issue to track links to upstream issue trackers? Maybe open an issue with w3c, firefox, chrome, and whatever M$ is doing these days?

Thanks for the nice idea, hopefully you can properly fix ugly text everywhere!

purpleidea avatar May 24 '20 15:05 purpleidea

Actually I don't think that's true anymore. Firefox apparently uses the same algorithm as TeX, see here:

https://github.com/mnater/Hyphenopoly/issues/116

So for the same font and geometry, the results should be the same.

The Hyphenopoly library could be used as a polyfill for the rare cases that don't support it, but with up-to-date browsers it's becoming less and less relevant.

jotaf98 avatar May 24 '20 17:05 jotaf98

@jotaf98 Hyphenation is only one aspect of typesetting. Open a LaTeX document and look put calipers up to your screen and measure the difference between the size of the space between two words, and the size of the space between two sentences. And there's much more...

purpleidea avatar May 24 '20 21:05 purpleidea

That's true -- it's a start, not a full solution.

Building on Hypohenopoly's example, which iterates the words and adds hyphens at strategic places, could it theoretically be possible to iterate the words and wrap them in <span> tags with custom left/right margins and letter-spacing, following TeX's spacing algorithm?

The CSS font ligatures handle quite a bit of odd inter-letter spacing. I wonder if the level of granularity of per-word letter-spacing plus inter-word margins would be enough to achieve an almost indistinguishable effect!

jotaf98 avatar Jun 10 '20 14:06 jotaf98

Nice project guys,

I have had this link in my bookmarks for quite some time: https://github.com/bramstein/typeset

Would that help with the typesetting?

nvictor avatar Jan 20 '21 22:01 nvictor

Good find! @purpleidea and @vincentdoerig does this seem to address the issues you mentioned before?

jotaf98 avatar Jan 22 '21 11:01 jotaf98

@jotaf98 I don't have time to look into it, but I hope the state of the art gets better!

purpleidea avatar Jan 22 '21 15:01 purpleidea

Thanks for the link @nvictor! The project looks very interesting. Unfortunately, I'm currently also busy and don't have time to explore it further. But it's definitely something I'd like to look at in the future 👍.

vincentdoerig avatar Jan 24 '21 16:01 vincentdoerig