Closed alliedarmour closed 3 years ago
Hey @alliedarmour, thanks for using prawn-icon
!
I'm pretty sure I've encountered this, and I'm pretty sure the root cause lives in prawn-table
.
I'll do some investigation, but you could help me if you could confirm that the removal of prawn-table
from your Gemfile resolves the issue (i.e. can you replicate the same exception without prawn-table
).
Thanks!
Ahh - I think we've seen this before: https://github.com/jessedoyle/prawn-icon/issues/39
Yes, it does appear to be an issue that stems either from prawn
or prawn-table
. In particular it appears to occur with font-awesome
fonts.
@alliedarmour - I hate locking gems to a particular version, but can you please try locking prawn
to 2.1.0
for your app? If so, does the exception still occur?
Thanks, maybe we can get to the bottom of this!
Ahh - I think we've seen this before: #39
Yes, it does appear to be an issue that stems either from
prawn
orprawn-table
. In particular it appears to occur withfont-awesome
fonts.@alliedarmour - I hate locking gems to a particular version, but can you please try locking
prawn
to2.1.0
for your app? If so, does the exception still occur?Thanks, maybe we can get to the bottom of this!
I'm using the prawn-rails gem where prawn is installed as dependency :/. I looked into the prawn-rails issue with the creation of an initializer, but this didn't work out, it was another problem anyway.
I'm using the prawn-rails gem where prawn is installed as dependency
For sure, but it looks prawn-rails
doesn't lock the version of prawn
(see: https://github.com/cortiz/prawn-rails/blob/master/prawn-rails.gemspec#L21), so the app should be able to define the version prawn.
Can you try adding this line to your app's Gemfile and running bundle install
?
gem 'prawn', '2.1.0'
I can replicate the issue locally when trying to render a table, but only with prawn >= 2.2.2
. So a change to font handling must have been made between versions 2.1.0
and 2.2.2
that introduced the bug.
@alliedarmour - Okay so I think I've figured it out!
It's a complex issue, and it turns out it's fixed in prawn-table
master from a PR I submitted almost 5 years ago now (https://github.com/prawnpdf/prawn-table/pull/60).
Unfortunately, there hasn't been a release of prawn-table
pushed to Rubygems that includes the fix.
Here's what seems to be happening:
prawn
, but also caused the exception to be raised due to broken logic in prawn-table
(prawn-table
wasn't using the text's current font when calculating width).prawn-table
: https://github.com/prawnpdf/prawn-table/pull/60, but a release has not been pushed to Rubygems that includes the fix.TLDR: There was a defect in prawn-table
causing the issue that's long been fixed. Unfortunately there hasn't been a release of prawn-table
to Rubygems that includes the fix.
The error should go away if you point prawn-table
to the GitHub master
branch:
# in Gemfile
gem 'prawn-table', git: 'https://github.com/prawnpdf/prawn-table.git'
I'm going to close the issue as it's not a defect in prawn-icon
. Thanks!
@alliedarmour - Okay so I think I've figured it out!
It's a complex issue, and it turns out it's fixed in
prawn-table
master from a PR I submitted almost 5 years ago now (prawnpdf/prawn-table#60).Unfortunately, there hasn't been a release of
prawn-table
pushed to Rubygems that includes the fix.Here's what seems to be happening:
- Prawn >= 2.2.2 introduced Better Handling for Windows-1252 Encoded Strings.
- This change fixed broken font-handling logic in
prawn
, but also caused the exception to be raised due to broken logic inprawn-table
(prawn-table
wasn't using the text's current font when calculating width).- This PR resolves the issue in
prawn-table
: prawnpdf/prawn-table#60, but a release has not been pushed to Rubygems that includes the fix.TLDR: There was a defect in
prawn-table
causing the issue that's long been fixed. Unfortunately there hasn't been a release ofprawn-table
to Rubygems that includes the fix.The error should go away if you point
prawn-table
to the GitHubmaster
branch:# in Gemfile gem 'prawn-table', git: 'https://github.com/prawnpdf/prawn-table.git'
I'm going to close the issue as it's not a defect in
prawn-icon
. Thanks!
You're my hero, it's working! Thanks for your research and your quick help, you saved a bit of my thesis :D. Hopefully they will merge in the PR and publish a new release.
Working like a charm :)
Glad to hear @alliedarmour! Looks great!
Hey, first it's a really nice gem as it's exactly what I'm looking for, but I can only partially get it to work.
I'm using prawn-rails to generate PDFs in my Rails 6 application, which is working fine. Now I want to include some icons and I imported the Font Awesome font to the font_families:
Now, if I use
pdf.font "Font Awesome"
the icons in my table are working, but I don't want the whole document to have this font family.The problem is if I don't use this change, I always get the error you see in the title:
I searched the repository here and some stackoverflow threads but I can't seem to fix the issue.
I tried to make the cell before the table and set the font family, but also no luck:
Any ideas how to get this to work? Is it maybe a prawn-rails issue?