How can I embed a complete TTF font without subsetting? #1315
Replies: 2 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
-
On subsetting. At the moment there's no way to disable it. ChatGPT completely made that up but I kinda like the API. You are on the right track but that's not all you need. Font embedding is kinda involved in PDF. You also need to produce a correct font descriptor, not just dump the font file. I've been away from Prawn for a while so can't give exact pointer but it's most likely somewhere in pdf-core. On the message. I think it's misleading in your case. It probably means that your font (and fallback fonts if any) have no glyphs defined for some of the characters in your text. It specifically mentions Windows-1252 because that's the extent of what is supposed to be provided by the default fonts. |
Beta Was this translation helpful? Give feedback.
-
I found some old threads on the Google Group:
Also a related discussion:
I would like to re-open the discussion about embedding fonts without subsetting. I need to embed the full TTF font for some custom AcroForm support that I'm working on, so that text fields support other character sets (e.g. cyrillic, hebrew, chinese). The editable form fields need to support custom user input after the document has rendered, since they might type in any other characters.
I also looked at the TTFunk and prawn code to see if I could figure out how to disable embedding, but it's quite difficult to understand how it works. I made a little bit of progress in the
#embed
method inlib/prawn/font/ttf.rb
:Instead of
font_content = @subsets[subset].encode
, I calledfont_content = @subsets[subset].original.contents.read
. And instead offont = TTFunk::File.new(font_content)
I triedfont = @subsets[subset].original
.I struggled to figure out the rest of that method (cmap, widths, ranges, etc.) and broke everything:
This message from Gregory Brown is very interesting:
Maybe I can go back to a much earlier comment and see what the code looked like before subsetting was added.
Any tips would be greatly appreciated! And I think it would be very helpful if there was an option to disable subsetting. Both for this AcroForm use case, and also for the other people who mentioned issues with combining lots of PDFs together.
P.S. I asked ChatGPT, but I think it might have pointed me in the wrong direction and made up some false information.
Is this something that Prawn used to support?
Beta Was this translation helpful? Give feedback.
All reactions