Commit 67ccf8c2 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

app: implement proper manual kerning, but disable it for now

because it breaks the invariant that the pango layout used for
navigating in the on-canvas editor must be a 1:1 view on the text
buffer used for editing. Will have to fix that somehow...
parent 6d176f5a
......@@ -642,3 +642,84 @@ gimp_text_buffer_deserialize (GtkTextBuffer *register_buffer,
return retval;
}
void
gimp_text_buffer_pre_serialize (GimpTextBuffer *buffer,
GtkTextBuffer *content)
{
GtkTextIter iter;
g_return_if_fail (GIMP_IS_TEXT_BUFFER (buffer));
g_return_if_fail (GTK_IS_TEXT_BUFFER (content));
gtk_text_buffer_get_start_iter (content, &iter);
do
{
GSList *tags = gtk_text_iter_get_tags (&iter);
GSList *list;
for (list = tags; list; list = g_slist_next (list))
{
GtkTextTag *tag = list->data;
if (g_list_find (buffer->spacing_tags, tag))
{
GtkTextIter end;
gtk_text_buffer_insert_with_tags (content, &iter,
"\342\200\215", -1,
tag, NULL);
end = iter;
gtk_text_iter_forward_char (&end);
gtk_text_buffer_remove_tag (content, tag, &iter, &end);
break;
}
}
g_slist_free (tags);
}
while (gtk_text_iter_forward_char (&iter));
}
void
gimp_text_buffer_post_deserialize (GimpTextBuffer *buffer,
GtkTextBuffer *content)
{
GtkTextIter iter;
g_return_if_fail (GIMP_IS_TEXT_BUFFER (buffer));
g_return_if_fail (GTK_IS_TEXT_BUFFER (content));
gtk_text_buffer_get_start_iter (content, &iter);
do
{
GSList *tags = gtk_text_iter_get_tags (&iter);
GSList *list;
for (list = tags; list; list = g_slist_next (list))
{
GtkTextTag *tag = list->data;
if (g_list_find (buffer->spacing_tags, tag))
{
GtkTextIter end;
gtk_text_iter_forward_char (&iter);
gtk_text_buffer_backspace (content, &iter, FALSE, TRUE);
end = iter;
gtk_text_iter_forward_char (&end);
gtk_text_buffer_apply_tag (content, tag, &iter, &end);
break;
}
}
g_slist_free (tags);
}
while (gtk_text_iter_forward_char (&iter));
}
......@@ -26,21 +26,26 @@
#define __GIMP_TEXT_BUFFER_SERIALIZE_H__
guint8 * gimp_text_buffer_serialize (GtkTextBuffer *register_buffer,
GtkTextBuffer *content_buffer,
const GtkTextIter *start,
const GtkTextIter *end,
gsize *length,
gpointer user_data);
guint8 * gimp_text_buffer_serialize (GtkTextBuffer *register_buffer,
GtkTextBuffer *content_buffer,
const GtkTextIter *start,
const GtkTextIter *end,
gsize *length,
gpointer user_data);
gboolean gimp_text_buffer_deserialize (GtkTextBuffer *register_buffer,
GtkTextBuffer *content_buffer,
GtkTextIter *iter,
const guint8 *data,
gsize length,
gboolean create_tags,
gpointer user_data,
GError **error);
void gimp_text_buffer_pre_serialize (GimpTextBuffer *buffer,
GtkTextBuffer *content);
void gimp_text_buffer_post_deserialize (GimpTextBuffer *buffer,
GtkTextBuffer *content);
gboolean gimp_text_buffer_deserialize (GtkTextBuffer *register_buffer,
GtkTextBuffer *content_buffer,
GtkTextIter *iter,
const guint8 *data,
gsize length,
gboolean create_tags,
gpointer user_data,
GError **error);
#endif /* __GIMP_TEXT_BUFFER_SERIALIZE_H__ */
......@@ -242,6 +242,10 @@ gimp_text_buffer_set_markup (GimpTextBuffer *buffer,
{
GtkTextIter start, end;
#if 0
gimp_text_buffer_post_deserialize (buffer, content);
#endif
gtk_text_buffer_get_bounds (content, &start, &end);
gtk_text_buffer_get_start_iter (GTK_TEXT_BUFFER (buffer), &insert);
......@@ -273,6 +277,10 @@ gimp_text_buffer_get_markup (GimpTextBuffer *buffer)
gtk_text_buffer_insert_range (content, &insert, &start, &end);
#if 0
gimp_text_buffer_pre_serialize (buffer, content);
#endif
gtk_text_buffer_get_bounds (content, &start, &end);
markup = (gchar *) gtk_text_buffer_serialize (GTK_TEXT_BUFFER (buffer),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment