Skip to content
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

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" #1272

Open
rubyFeedback opened this issue Jul 30, 2022 · 5 comments

Comments

@rubyFeedback
Copy link

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...

@pointlessone
Copy link
Member

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.

@johnnyshields
Copy link
Contributor

johnnyshields commented Jul 30, 2022

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.

@gettalong
Copy link
Member

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 ...".

@pointlessone
Copy link
Member

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".

@johnnyshields
Copy link
Contributor

johnnyshields commented Jul 31, 2022

(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!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants