-
Notifications
You must be signed in to change notification settings - Fork 80
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
Support libpng with no iTXt chunk support #571
Conversation
libpng's support for the `iTXt` chunk ('international textual data') is optional, and off-by-default before libpng 1.3, which causes a compile error. This writes an iTXt chunk only if supported, and writes a tEXt chunk otherwise. (A tEXt chunk is identical but specified to contain Latin-1 text instead of UTF-8, and has no language tag.)
Thank you for submitting this fix! The switch to using iTXt rather than tEXt chunks happened pretty late in the work on this feature, and I wasn't aware of the version limitations. I don't see it in the libpng 1.2 documentation for these chunks at all. Do you have a reference for this information we can look to in the future? I'll be able to give this a test in the next few days. Thanks again! |
That's the documentation for the PNG file format itself, not for libpng. The libpng manual says:
pngconf.h from libpng 1.2.59 [source tarball] says:
|
Oh, I was looking in the wrong place the whole time. 😳 |
text[num_txtfields].lang = "en-us"; // Language used in 'text' and 'lang_key'. | ||
text[num_txtfields].lang_key = ""; // Translation of 'key' into 'lang', if needed. | ||
text[num_txtfields].compression = PNG_ITXT_COMPRESSION_NONE; | ||
#else | ||
it->second = it->second.to_latin_1(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can throw, since ST::string
expects to hold UTF-8 data. Instead, the char_buffer
should be stored off separately, and should point to either the UTF-8 data or Latin-1 data to be written by libpng.
@zrax LGTY? |
Looks great. 👍 |
libpng's support for the
iTXt
chunk ('international textual data') isoptional, and off-by-default before libpng 1.4, which causes a compile
error. This writes an iTXt chunk only if supported, and writes a tEXt
chunk otherwise. (A tEXt chunk is identical but specified to contain
Latin-1 text instead of UTF-8, and has no language tag.)