-
Notifications
You must be signed in to change notification settings - Fork 687
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
Really, really odd behaviour...? #972
Comments
And another odd one for you... Using a Google Font, renders some bits fine, others, not... If you highlight the text, copy & paste it's all there, so it's a rendering / PDF issue rather than a data issue. |
@packetmonkey I could really use some help in figuring this out, otherwise I may have to switch away from Prawn, which I really don't want to do! |
Prawn does font subsetting as an optimization to keep your documents small. You may want to try and trace if it does it properly with your font. The code is in TTFunk gem. I don't have other ideas at the moment. |
@pointlessone Thanks for the words of wisdom, I'll try to take a look, clearly something's gone nuts. |
@pointlessone As a quick and dirty fix, is there a way to turn subsetting off?! |
@Siyfion I'm afraid, no. IIRC, it's not a removal of unused glyphs but rather import of the used ones. You may hack TTF to include all glyphs, or maybe even just use original font file instead of generating a subset. But I don't think there's a way to just turn subsetting off. |
Damn. Well it's this font: https://fonts.google.com/specimen/Taviraj?selection.family=Taviraj Is there a way to use font's in a pdf that can be retrieved from a url? Like a CSS import? |
Technically, PDF has means to reference external resources (including via URL). But I'm not sure if this is applicable specifically to fonts. Check out PDF Reference. |
@Siyfion It would help if you could provide a small script that reproduces the error. As for external object streams specified via URLs: Yes, this should be possible, see section 7.11.5. However, I doubt that there would be much support for that feature. |
@pointlessone @gettalong Minimal code reproduction done and attached. It's literally hello-world with a font and different character-set. |
@pointlessone & @gettalong require "prawn"
Prawn::Document.generate("hello.pdf") do
font("Taviraj/Taviraj-Regular.ttf") do
text "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-=!@$%^&*()__+}"
end
end Outputs the following: |
@Siyfion I'm not that paranoid ;) So thanks for the ZIP-File. What I can confirm right now is that the embedded font is not a valid TrueType font. When extracting the font stream and opening it with FontForge, it throws errors. However, if we replace the font with another one, like Also, running What you experience with Acrobat may be that Acrobat re-subsets the font on save and therefore everything works correctly. |
@gettalong If I open the TTF in FontForge, I don't seem to get anything too out of the ordinary..? |
@Siyfion Did you open the original TrueType font or the one embedded into the PDF file? The original one works fine but the embedded one is corrupt. |
The original, surely that means that the font file I'm using is perfectly Simon Mansfield On 28 October 2016 at 17:49:15, Thomas Leitner (notifications@github.com)
|
@Siyfion Yes, the original file also works correctly for me but not the embedded subset of the file and, as you said, this means that subsetting does not work for this file. |
@gettalong So where does the error lie (in what piece of code?) |
@Siyfion Didn't have to investigate further, but I guess it will be somewhere here: https://github.com/prawnpdf/ttfunk/blob/master/lib/ttfunk/table/glyf.rb |
Wow, that's er... waaaay outside my comfort zone to try and debug/fix. Guess I'll have to wait until someone can take a proper look at it. |
@Siyfion No problem, I think I will some time today to have a look. |
@Siyfion I tracked down the problem after some lengthy investigation (I'm not that familiar with ttfunk myself) and have opened an issue (see prawnpdf/ttfunk#32) where you will also find the fix that you can apply to your ttfunk installation. |
Awesome work! Thank you so much for looking into it! Simon Mansfield On 1 November 2016 at 21:27:48, Thomas Leitner (notifications@github.com)
|
Confirmed that @gettalong's fix does indeed cure this issue. I'd like to get the change merged into the release if possible, as I'm sure this affects more than just one or two fonts! |
This issue is fixed in TTFunk 1.5.1. I will close it now. Feel free to reopen in case it doesn't work for you and you have new details. @gettalong Thank you for the research you did on this issue. |
@pointlessone & @gettalong, awesome work both of you. 👍 |
For anyone who stumbles upon it and for some reason't can't easily upgrade to new version of prawn a workaround (from master) is: unless Prawn::VERSION > '0.13'
module TTFunk
class Table
class Loca
# Backport from current master to fix https://github.com/prawnpdf/ttfunk/issues/32
def self.encode(offsets)
long_offsets =
offsets.any? do |offset|
short_offset = offset / 2
short_offset * 2 != offset || short_offset > 0xffff
end
if long_offsets
{ type: 1, table: offsets.pack('N*') }
else
{ type: 0, table: offsets.map { |o| o / 2 }.pack('n*') }
end
end
end
end
end |
I've created a label for print with some text and tables, etc. (Attached)
But there is a load of information at the bottom of the page (which if you try to select, you can see positionally) that simply does not appear at all.
I've opened up the PDF in Acrobat and if I so much as change one little thing, all of it then re-renders correctly (I assume Acrobat is "fixing" the issue on save)...
@practicingruby / @packetmonkey Any idea's would be great! As I'm currently a bit stuck helping a customer until I can understand this better!
uni309_YAPzvqyWS7Ek5BPFL_20160809-125327.pdf
The text was updated successfully, but these errors were encountered: