Remove the ISO8859-1 restriction from the description of png tEXt
* gdk-pixbuf-io.c (gdk_pixbuf_save): Remove the ISO8859-1 restriction from the description of png tEXt parameters. * io-png.c (png_text_to_pixbuf_option): (gdk_pixbuf__png_image_save): If libpng supports it, store and retrieve non-ISO8859-1 text as UTF-8. (#76172)
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
2002-04-24 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
|
* gdk-pixbuf-io.c (gdk_pixbuf_save): Remove the ISO8859-1
|
||||||
|
restriction from the description of png tEXt parameters.
|
||||||
|
|
||||||
|
* io-png.c (png_text_to_pixbuf_option):
|
||||||
|
(gdk_pixbuf__png_image_save): If libpng supports it,
|
||||||
|
store and retrieve non-ISO8859-1 text as UTF-8. (#76172)
|
||||||
|
|
||||||
2002-04-11 Matthias Clasen <maclas@gmx.de>
|
2002-04-11 Matthias Clasen <maclas@gmx.de>
|
||||||
|
|
||||||
More fixes for #77807:
|
More fixes for #77807:
|
||||||
|
|||||||
@ -784,9 +784,7 @@ gdk_pixbuf_real_save (GdkPixbuf *pixbuf,
|
|||||||
* "quality" parameter; its value should be in the range [0,100].
|
* "quality" parameter; its value should be in the range [0,100].
|
||||||
* Text chunks can be attached to PNG images by specifying parameters of
|
* Text chunks can be attached to PNG images by specifying parameters of
|
||||||
* the form "tEXt::key", where key is an ASCII string of length 1-79.
|
* the form "tEXt::key", where key is an ASCII string of length 1-79.
|
||||||
* The values are UTF-8 encoded strings. Note however that PNG text
|
* The values are UTF-8 encoded strings.
|
||||||
* chunks are stored in ISO-8859-1 encoding, so you can only set texts
|
|
||||||
* that can be represented in this encoding.
|
|
||||||
*
|
*
|
||||||
* Return value: whether an error was set
|
* Return value: whether an error was set
|
||||||
**/
|
**/
|
||||||
|
|||||||
@ -204,14 +204,19 @@ png_text_to_pixbuf_option (png_text text_ptr,
|
|||||||
gchar **key,
|
gchar **key,
|
||||||
gchar **value)
|
gchar **value)
|
||||||
{
|
{
|
||||||
*value = g_convert (text_ptr.text, -1,
|
if (text_ptr.text_length > 0) {
|
||||||
"UTF-8", "ISO-8859-1",
|
*value = g_convert (text_ptr.text, -1,
|
||||||
NULL, NULL, NULL);
|
"UTF-8", "ISO-8859-1",
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
*value = g_strdup (text_ptr.text);
|
||||||
|
}
|
||||||
if (*value) {
|
if (*value) {
|
||||||
*key = g_strconcat ("tEXt::", text_ptr.key, NULL);
|
*key = g_strconcat ("tEXt::", text_ptr.key, NULL);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
g_warning ("Couldn't convert tEXt chunk value to UTF-8.");
|
g_warning ("Couldn't convert text chunk value to UTF-8.");
|
||||||
*key = NULL;
|
*key = NULL;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -602,7 +607,7 @@ png_info_callback (png_structp png_read_ptr,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Extract tEXt chunks and attach them as pixbuf options */
|
/* Extract text chunks and attach them as pixbuf options */
|
||||||
|
|
||||||
if (png_get_text (png_read_ptr, png_info_ptr, &png_text_ptr, &num_texts)) {
|
if (png_get_text (png_read_ptr, png_info_ptr, &png_text_ptr, &num_texts)) {
|
||||||
for (i = 0; i < num_texts; i++) {
|
for (i = 0; i < num_texts; i++) {
|
||||||
@ -753,8 +758,8 @@ gdk_pixbuf__png_image_save (FILE *f,
|
|||||||
|
|
||||||
for (kiter = keys; *kiter; kiter++) {
|
for (kiter = keys; *kiter; kiter++) {
|
||||||
if (strncmp (*kiter, "tEXt::", 6) != 0) {
|
if (strncmp (*kiter, "tEXt::", 6) != 0) {
|
||||||
g_warning ("Bad option name '%s' passed to PNG saver", *kiter);
|
g_warning ("Bad option name '%s' passed to PNG saver", *kiter);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
key = *kiter + 6;
|
key = *kiter + 6;
|
||||||
len = strlen (key);
|
len = strlen (key);
|
||||||
@ -762,7 +767,7 @@ gdk_pixbuf__png_image_save (FILE *f,
|
|||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
GDK_PIXBUF_ERROR,
|
GDK_PIXBUF_ERROR,
|
||||||
GDK_PIXBUF_ERROR_BAD_OPTION,
|
GDK_PIXBUF_ERROR_BAD_OPTION,
|
||||||
_("Keys for PNG tEXt chunks must have at least 1 and at most 79 characters."));
|
_("Keys for PNG text chunks must have at least 1 and at most 79 characters."));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
@ -770,7 +775,7 @@ gdk_pixbuf__png_image_save (FILE *f,
|
|||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
GDK_PIXBUF_ERROR,
|
GDK_PIXBUF_ERROR,
|
||||||
GDK_PIXBUF_ERROR_BAD_OPTION,
|
GDK_PIXBUF_ERROR_BAD_OPTION,
|
||||||
_("Keys for PNG tEXt chunks must be ASCII characters."));
|
_("Keys for PNG text chunks must be ASCII characters."));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -787,11 +792,23 @@ gdk_pixbuf__png_image_save (FILE *f,
|
|||||||
"ISO-8859-1", "UTF-8",
|
"ISO-8859-1", "UTF-8",
|
||||||
NULL, &text_ptr[i].text_length,
|
NULL, &text_ptr[i].text_length,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
#ifdef PNG_iTXt_SUPPORTED
|
||||||
|
if (!text_ptr[i].text) {
|
||||||
|
text_ptr[i].compression = PNG_ITXT_COMPRESSION_NONE;
|
||||||
|
text_ptr[i].text = g_strdup (values[i]);
|
||||||
|
text_ptr[i].text_length = 0;
|
||||||
|
text_ptr[i].itxt_length = strlen (text_ptr[i].text);
|
||||||
|
text_ptr[i].lang = NULL;
|
||||||
|
text_ptr[i].lang_key = NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!text_ptr[i].text) {
|
if (!text_ptr[i].text) {
|
||||||
g_set_error (error,
|
g_set_error (error,
|
||||||
GDK_PIXBUF_ERROR,
|
GDK_PIXBUF_ERROR,
|
||||||
GDK_PIXBUF_ERROR_BAD_OPTION,
|
GDK_PIXBUF_ERROR_BAD_OPTION,
|
||||||
_("Value for PNG tEXt chunk can not be converted to ISO-8859-1 encoding."));
|
_("Value for PNG text chunk %s can not be converted to ISO-8859-1 encoding."), keys[i] + 6);
|
||||||
num_keys = i;
|
num_keys = i;
|
||||||
for (i = 0; i < num_keys; i++)
|
for (i = 0; i < num_keys; i++)
|
||||||
g_free (text_ptr[i].text);
|
g_free (text_ptr[i].text);
|
||||||
|
|||||||
Reference in New Issue
Block a user