After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 620674 - Adding support for multi-colored text layer
Adding support for multi-colored text layer
Status: RESOLVED FIXED
Product: GIMP
Classification: Other
Component: Tools
git master
Other All
: Normal enhancement
: 2.8
Assigned To: GIMP Bugs
GIMP Bugs
Depends on:
Blocks:
 
 
Reported: 2010-06-05 17:22 UTC by LightningIsMyName
Modified: 2010-09-01 22:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
First attempt to add the feature (18.35 KB, patch)
2010-06-05 17:38 UTC, LightningIsMyName
committed Details | Review
Text that renders text layers as pixels instead of mask and thus supports colors (4.91 KB, patch)
2010-07-12 19:03 UTC, Michael Natterer
committed Details | Review

Description LightningIsMyName 2010-06-05 17:22:47 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.
Comment 1 LightningIsMyName 2010-06-05 17:38:37 UTC
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.
Comment 2 LightningIsMyName 2010-06-05 18:37:36 UTC
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).
Comment 3 Michael Natterer 2010-06-06 10:21:56 UTC
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);
Comment 4 Michael Natterer 2010-07-12 19:03:11 UTC
Created attachment 165754 [details] [review]
Text that renders text layers as pixels instead of mask and thus supports colors
Comment 5 Michael Natterer 2010-09-01 21:39:46 UTC
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
Comment 6 Michael Natterer 2010-09-01 22:21:36 UTC
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(-)