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

Make type used for line width computations generic #327

Closed
mgeisler opened this issue Apr 19, 2021 · 1 comment
Closed

Make type used for line width computations generic #327

mgeisler opened this issue Apr 19, 2021 · 1 comment
Labels

Comments

@mgeisler
Copy link
Owner

We currently use usize for line widths, which works well for terminal text. To support wrapping text for PDFs or SVGs, we need to be more flexible. We might be able to use f64, but we should probably make the type generic so that people can plug in their own bignum types.

This would also allow terminal text applications to use a smaller type, such as u16, which would lower the memory usage a 64-bit system.

@mgeisler
Copy link
Owner Author

With the changes in #421, we now use f64 internally in wrap_first_fit and wrap_optimal_fit. The top-level interface is still usize, but this is just because Textwrap is providing functions for wrapping console text (which is naturally measured in an integer number of columns).

I think this is a good compromise: the f64 type covers all integers up to about 2^53, so this covers our terminal use cases. Simultaneously, f64 makes it easy for GUI programs to wrap text measured in pt or px with sub-pixel accuracy.

This means that this issue is obsolete now.

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

No branches or pull requests

1 participant