Navigation Menu

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

Column box jumps a column with float and wraparound #461

Open
benhell opened this issue Mar 15, 2013 · 1 comment
Open

Column box jumps a column with float and wraparound #461

benhell opened this issue Mar 15, 2013 · 1 comment

Comments

@benhell
Copy link

benhell commented Mar 15, 2013

The following code is how I implement bulleted lists. However,
if the bulleted item is supposed to "wrap around"and appear at the top of the second column, it doesn't quite work. The bullet appears at the top of an otherwise empty second column, but then the text of the bullet appears in the third column.

 require 'prawn'

Prawn::Document.generate("jumpcol.pdf") do 
  column_box([0, cursor], columns: 3, width: bounds.width, height: font.height) do
     2.times do
       float{ indent(10){ text("*") } } 
       indent(20){ text("bullet text") }
     end 
  end 
end

If I remove the float and instead do "move_up(font.height)" after the bullet but before the text, I do not get this bug.

I speculate that the bullet character within the float triggers a new column (2). On exiting the float, the position is reset to the bottom of the first column. Then, the text following bullet character triggers another new column (3). Thus, three columns, the second being almost empty.

This is on 0.12. Haven't tested RC.

Wonderful project, btw. Truly sanity saving for me.

@practicingruby
Copy link
Member

Your assumptions sound correct, and I think the core problem is that float is very naive in how it works: it keeps track of what page you start on and will rewind back to that page even if you crossed a page boundary, but isn't aware at all of what box you're in.

For this particular issue, I'd recommend using Unicode bullets in your text because it'll avoid having to hack around with float and indent, but the general problem is interesting enough that I'll re-open for further investigation / commentary.

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

No branches or pull requests

2 participants