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

If text begins with a zero-width space fragment, CannotFit exception is thrown #984

Closed
mojavelinux opened this issue Sep 19, 2016 · 0 comments

Comments

@mojavelinux
Copy link
Contributor

If a string of text begins with a discrete zero-width space fragment, the line wrap logic incorrectly concludes that the text cannot fit. This happens even when the "wrap by char" option is active.

Here's a scenario that reproduces this problem:

require 'prawn'
Prawn::Document.generate 'cannot-fit-bug.pdf' do
  font %(#{Prawn::DATADIR}/fonts/DejaVuSans.ttf)
  bounding_box [0, cursor], width: 50 do
    text %(\u200b<color rgb="0000FF">stringofchars</color>), inline_format: true
  end
end

If the leading zero-width space character (\u200b) is taken away, the text is rendered without exception.

The problematic line is line_wrap.rb#L199 called from line_wrap.rb#L112.

A zero-width space fragment is often used as a placeholder for adding non-visible objects such as an anchor point.

mojavelinux added a commit to mojavelinux/prawn that referenced this issue Sep 19, 2016
packetmonkey added a commit that referenced this issue Sep 21, 2016
resolves #984 don't raise CannotFit if first fragment is a zero-width space
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant