prawnpdf/prawn

Encoding warning: Prawn::Errors::IncompatibleStringEncoding, "Your document includes text that's not compatible with the Windows-1252 character set.\n If you need full UTF-8 support, use TTF fonts instead of PDF's built-in fonts"

rubyFeedback opened this issue · 7 comments

Could the error message be improved?

"use TTF fonts instead of PDF's built-in font" does not tell me that much. I had to google
and still have absolutely no idea what to do. I don't even understand why it writes
"instead of PDF's built-in font". What does this even mean? Does this mean prawn's
built in font or something?

I don't remember having had this issue years ago but now I have it. Has that behaviour
be changed? I have mostly german umlauts which I keep in UTF-8. In ruby all works
fine. This is a bit annoying that with prawn I now have to find out what to do - all is
in UTF-8 ... I don't even understand why I have to use windows-1252...

I'm open for suggestions.

As far as the message goes, it's pretty straight-forward. PDF built-in fonts only support limited set of characters. It does not include umlauts. In order to have proper rendering of umlauts you need to supply your own font file. Refer to the Manual for how to use external fonts.

Suggestion:
Your document includes text that is not compatible with PDF's built-in fonts, which use the Windows-1252 character set. For full UTF-8 support, please define a custom TTF font file. Refer to the manual.

Maybe the name of the font that resulted in the error should be mentioned, too?

And maybe just leave out the Windows-1252 part because this is an internal detail that an ordinary Prawn user won't know.

Also, since Prawn/ttfunk now supports OpenType fonts, it should probably read "... TTF/OTF font ...".

Naming a font is probably not useful. I'm fairly confident this error occurs 90% with no font set, that is a default font (Times) used.

Leaving out encoding may be an improvement. You're quite correct that it's a misdirection.

Specifying TTF is not correct, that's true. But adding OTF doesn't quite fix it. As you noted, TTFunk supports a few font formats and TTF and OTF is not the full list. It's probably better to just mention "external font".

(In my proposed message intentionally put encoding after "PDF's built-in font". I agree it's it is less useful information, but still relevant. If Prawn users don't know what a character enconding is... well they should!)