-
Notifications
You must be signed in to change notification settings - Fork 688
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
Font Embedding: Template Text is broken #1362
Comments
Thanks for the nicely reproducible steps! I can confirm the issue: The reason why the initial text looks now mangled is that Prawn overwrites the font object for the text with the one for the Arial font. If you add another TrueType font and write some text in it, the second font object will also be overwritten. So this indicates a problem with choosing a PDF internal name for the fonts when the template PDFs contains font reference in the style Prawn itself generates. The code for generating these internal font names seems to be at https://github.com/prawnpdf/prawn/blob/master/lib/prawn/font.rb#L543-L553 if you want to take a stab. |
Thanks for confirming the issue and pointing me in the right direction! Indeed, I was able to verify that a non-unique ID is selected. In the PDF template shared, the existing fonts are embedded as When checking for a unique key, the method It seems like the dot I don't have a good proposal for a permanent solution yet. However, I was able to confirm that using another key than |
This looks like a straight-up bug, possibly resulting from conversion from regexp which would be |
Since updating to prawn 2.5.0, we face issues with font embedding and changes to text provided on a template.
Reproduction example:
Arial Unicode MS.TTF
is present in the local working directory. While the font is shipped with Microsoft Office by default and can be licensed by Microsoft, it is also available on GitHub (for example here).template.pdf
is present in the local working directory downloaded from this issue: template.pdf. The template text was created in Word and then exported to PDF. It contains two lines of text in two different fonts; namely "Source Sans Pro" and "Calibri". Both fonts are shipped with the template as embedded subset:With both files being available, a simple
irb
can be started and the following script can be executed:Issue noticed:
We assume that this issue is not directly related to #1361, since subsetting is explicitly disabled for the font. However, since we are not fully aware of the inner workings of Prawn, both issues could be well related. In this case, we excuse for the duplicate reporting. Any help to fix the issue mentioned is very appreciated!
--
prawn:
2.5.0
Ruby:
3.3.5
Adobe Acrobat Pro:
2024.003.20121
Microsoft Word:
Version 2408 Build 16.0.17928.20156
The text was updated successfully, but these errors were encountered: