Closed ToniTornado closed 8 years ago
I believe you need to provide the inline_format: true
attribute directly to the icon
method if you wish to use <icon>
tags:
icon '<icon size="12">fa-info-circle</icon> Here is some information', size: 10, style: :bold, inline_format: true
I was unable to make your original code work. Prawn::Icon
(correctly) generated the following exception:
Prawn::Errors::UnknownFont: Icon font not found for set: <icon size="12">fa
Were you seeing the same exception?
@ToniTornado - I'm going to close this issue.
The solution is to provide the inline_format: true
option to the icon
method:
Prawn::Document.generate('test.pdf') do
icon "Here's an icon that is inline <icon>fa-info-circle</icon>", inline_format: true
end
Produces this:
Feel free to re-open this issue if you notice any odd behaviour!
Actually, I've noticed the issue. Looks like a bug to me!
Example Code:
Prawn::Document.generate('test.pdf') do
text 'Hello'
move_down 10
text 'More'
move_down 10
icon '<icon>fa-info-circle</icon> alert!', inline_format: true
move_down 10
text 'END'
end
Output:
Sorry @ToniTornado - I'll look into when I get a chance!
Thanks for your time! This is exactly what it looked like in my document, I should have added a screenshot. I missed the inline_format: true
option in my code because I added it in my solution above by default.
When I understand your parser correctly, inline_format: true
is always required because the parser removes the <icon>
tag and generates an appropriate <font>
tag with font face set to the correct icon font. I guess the method wouldn't work without inline_format: true
so wouldn't it make sense to set it by default?
@jessedoyle I installed your branch inline-cursor
in my project and it works for me. 👍
I installed your branch inline-cursor in my project and it works for me.
Perfect that's good to hear! I hacked something together, but the code definitely needs to be cleaned up (and tests need to be written).
But it's a start, I should have a solution merged into master over the next few days.
@ToniTornado - I've merged #25 and released v1.1.1
to Rubygems. Please let me know if this solves your problem!
I expect a call to
icon()
to render the text into the document flow, but instead it was rendered at the top of the current page. I'm not sure why exactly this happens; maybe it is because ofText::Formatted::Box
(prawn-icon/lib/prawn/icon.rb line 125)?I use the following patch in an initializer to print text with parsed icons at the correct position. But it will be a better place to put a method like this into the gem itself. Or am I missing something?