Skip to content

Is there a way to use textwrap with a font-sepecific line measure #311

Answered by mgeisler
NeverGivinUp asked this question in Q&A
Discussion options

You must be logged in to vote

I will try using multiplied values for a start. But generifying clearly is the superior solution, that does not add artificial inaccuracies to the measurements.
The wrapping algorithms wrap_first_fit and wrap_optimal_fit expect line_width closures that return a usize. That would need to be generified as well.

Yes, I agree! As you can tell, Textwrap is born out of the world of terminal text. It was only with version 0.13 that it became possible to wrap other things via custom Fragment implementations.

I've just put up #310, which contain an example of using Textwrap for wrapping text with f64 widths. The text in question is drawn on a HTML canvas using WebAssembly — the result is live at h…

Replies: 7 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@NeverGivinUp
Comment options

@NeverGivinUp
Comment options

@mgeisler
Comment options

@mgeisler
Comment options

Answer selected by mgeisler
Comment options

You must be logged in to vote
1 reply
@mgeisler
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #309 on April 05, 2021 19:08.