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

Image.from_text: "align: :center" does not work without passing "width:" #445

Open
jlnr opened this issue Apr 22, 2018 · 3 comments
Open

Comments

@jlnr
Copy link
Member

jlnr commented Apr 22, 2018

Not really intuitive, I guess I should merge both forms of Image.from_text :/

@Kjarrigan
Copy link
Collaborator

Well I guess if you think about it its intuitive, because to what reference (virtual box) should it be aligned if there is no defined width? It works that way in other gems as well (like Prawn). But the docu could be better. At the moment only the "long" explanation of width hints that it only works in pair. Maybe just add "width has to be set to use alignment".

@jlnr
Copy link
Member Author

jlnr commented Apr 23, 2018

Image.from_text("abc \n abcabcabc", align: :center) could create an image that is as wide as the second line, and then center the first line within that image. In the absence of :width, max(text_width of each line) sounds like an intuitive fallback. It's not super efficient to iterate over the text twice, but I don't think that's a concern for Image.from_text.

@Juksefantomet
Copy link

What if it counts when iterating the first time and if no width is defined use that to set width? no need for double iteration correct? Or if you know the x number of characters where 1 character is equal to a number if pixels the chars*pix_pr_char=width

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

3 participants