You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
module Prawn
class Document
alias_method :orig_width_of, :width_of
def width_of(string, options={})
orig_width_of(string.gsub(/\n\z/,""),options)
end
end
end
The text was updated successfully, but these errors were encountered:
I don't think we can make an assumption about newlines.
The documentation in Prawn already states:
"Text wrap in Prawn does not re-flow linebreaks, so if you want fully automated text wrapping, be sure to remove newlines before attempting to draw your string. "
I could clarify that a little more, but this basically means it's up to you to remove your newlines. If font designers include a width for \n, it's best for us to respect those intentions even if they don't make much sense.
This particular issue is driving me crazy when using the Arial TTF font, which apparently has a width defined for the newline character, although I'm hard-pressed to figure out why anyone would want a newline to have width.
using center layout in prawn is not correct as the length of lines is not correctly determined (incloding '\n' character)
This was published and discussed on in google group:
http://groups.google.com/group/prawn-ruby/browse_thread/thread/6754ada443dd22cd
workaround is to overwrite width_of method by manually removing tailing '\n' characters. (sorry the layout is broken as githup is always reformating this as coding)
module Prawn
class Document
alias_method :orig_width_of, :width_of
def width_of(string, options={})
orig_width_of(string.gsub(/\n\z/,""),options)
end
end
end
The text was updated successfully, but these errors were encountered: