GNOME Bugzilla – Bug 620674
Adding support for multi-colored text layer
Last modified: 2010-09-01 22:22:14 UTC
It would be great if we could use more than one color in each layer (aka, using different colors for different letters/words). I'm opening this bug report to track the progress of this hack. A first patch will be attached in a moment.
Created attachment 162818 [details] [review] First attempt to add the feature First version of the patch, to add support for several colors in one layer. Known issues: - The data of the text layer is probably correct, but it won't render correctly since gimp_text_layer_render_layout() creates a CAIRO_FORMAT_A8 image surface, and it only renders a mask using cairo, Just switching to 32bits won't work since then it won't function correctly on indexed images. - When selecting text, the gui doesn't seem to update to match the color. For example, selecting blue text when the color button was previously red, won't change the color button to blue. Issues that should be thought of: - How should we handle "default" color? Should there be a base color for the layer ("default") and when changing it, all the uncolored areas would change? - We need to fix GimpColorButton to be able to display "no color"/"inherited"/etc. This will be required for the default state of text that wasn't colored yet. Another data change: The color of the text layer (before this hack) was some parameter that the buffer had no acces to, since it was irrelevant (we rendered a mask using cairo, and the rendering function assigned the right color). If we will change the text core to render the true layout and not just a mask, we'll need some way to give the text buffer access to the layer's default color. Could probably done during the buffer creation, but we'll have to notify the buffer when the default color was changed in the tool-options dialog. Anyway, we'll need to save this default color in the side, and add it when creating the markup (as the most other markup tag). We'll also need to notice to remove it when loading the markup (during the serialization). In other words, serialization/deserialization should be taken care of when we decide how do we treat the "default" color.
Apparently there is something wrong with the conversion between color formats (GimpRGB, GdkColor and 24-bits)... Also, on IRC it was suggested that we get rid of the "default" color that text layers have. Instead, assign a color to all the text when it's created and that way we get rid off unexpected changes (right now, changing the color in the tool-options window would change the color of all the areas that weren't assigned a new color after the creation of the text layer). As noted, we'll also need to add the ability for the color button to display no color, or display a "?". This will be needed when marking text that has several colors in it. Also, clearing the style of a layer should revert to either the foreground color (logical in some cases) or to the color the layer was created with (more logical in most cases, but it may behave weirdly for files that the color of all the text was already changed many times).
Looks nice so far :) I don't have the time for a complete review right now, but one thing I noticed: Our convention for returning GimpRGB is *not* to allocate a new one and returning it, but instead say: void foo_get_color (Foo *foo, GimpRGB *color); so we pass in a return location for the struct, much like gtk_widget_get_allocation() the resp. setter would be: void foo_set_color (Foo *foo, const GimpRGB *color);
Created attachment 165754 [details] [review] Text that renders text layers as pixels instead of mask and thus supports colors
Comment on attachment 165754 [details] [review] Text that renders text layers as pixels instead of mask and thus supports colors Pushed this patch so colors are possible now
Fixed in master: commit ad819263af66224d6c60e37a0adbbb695a06575b Author: Michael Natterer <mitch@gimp.org> Date: Thu Sep 2 00:20:04 2010 +0200 Bug 620674 - Adding support for multi-colored text layer Apply slightly modified patch from Barak Itkin that adds colors for text spans plus GUI to edit these colors. app/widgets/gimptextbuffer.c | 137 +++++++++++++++++++++++++++++++++++++ app/widgets/gimptextbuffer.h | 9 +++ app/widgets/gimptextstyleeditor.c | 93 +++++++++++++++++++++++++ app/widgets/gimptextstyleeditor.h | 2 + app/widgets/gimptexttag.c | 20 ++++++ app/widgets/gimptexttag.h | 3 + 6 files changed, 264 insertions(+), 0 deletions(-)