Re: Alpha in Pango Color
- From: William Kappler <wekapple ncsu edu>
- To: Behdad Esfahbod <behdad esfahbod gmail com>
- Cc: Matthias Clasen <mclasen redhat com>, gtk-i18n-list gnome org
- Subject: Re: Alpha in Pango Color
- Date: Tue, 11 Aug 2015 12:52:08 -0400
I didn’t consider that when I suggested a possible separate tag – it would seem excessive to have more than one alpha tag, and if the background and foreground at least couldn’t be independently controlled, a lot of possible functionality would be lost. I’m not sure about things like the strikethrough or underline being independent. It seems it might be inconsistent if they behaved differently. That said, let me just suggest a case for my initial suggestion of expanding the hex color values.
First off, I didn’t realize color was supported in different precision formats. That would cause a problem with adding a 4th parameter because of ffffffffffff – which could be either 3 colors X 4 or 4 colors X 3. As such, perhaps adding an optional marker of some sort at the end of the existing hex color, followed by another hex value (representing only alpha) would be a solution. For example: “#0000FF|5”. That should not conflict with anything else or anyone’s expected behavior. ‘|’ isn’t necessarily the symbol that should be used, but I can’t off the top of my head think of a better marker.
Then, PangoColor would have to be modified to have the additionally guint16 for alpha. This of course means the alpha becomes a core part of the color, and they have to be specified together. If the user chooses not to specify an alpha, I think it should default to fully opaque. Typically that’s how text systems handle color and alpha, like CSS. Unless the alpha is specified via “rgba”, it assumes fully opaque, overriding any previous foreground alpha.
Actually drawing the color would be as easy as switching cairo_set_source_rgb for cairo_set_source_rgba and adding the new component.
The only downside I see is the work to implement such a change and that it could cause some users of Pango to see text suddenly becoming fully opaque when they use a 3-parameter color tag, if they previously set the alpha via Cairo. Since Pango’s support for alpha is basically nonexistent now, anyone using alpha would benefit in the long run even if some refactoring of how they handle colors was needed.
In any case, thank you both for taking my suggestion seriously. It would be a great help if anything like this were implemented. Again, if there’s anything I can do to help, I’m more than willing to do what I can.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]