fschutt / printpdf

A fully-featured PDF library for Rust, WASM-ready
https://fschutt.github.io/printpdf/
MIT License
829 stars 98 forks source link

Underlined text? #132

Open Joeboy opened 1 year ago

Joeboy commented 1 year ago

Hi! Thanks for this lib, which I'm currently using via genpdf.

I couldn't see a way to underline text, using either genpdf or printpdf? Any chance of supporting that, or documenting it if it's already supported in some way I haven't found? Thanks!

fschutt commented 1 year ago

as far as I'm aware, underlines are not a PDF feature, you'd need to calculate underlines manually using a text shaping crate

Joeboy commented 1 year ago

Thanks, I hadn't understood how fiddly it is to do this with the native pdf format. In case anybody's interested, I ended up doing it in a "pragmatic" (ie. nasty and hackish) way by forking both genpdf and printpdf, and printing underscores over the underlined chars. Which will only work right with a monospace font, but as it happens that's all I need.