Discussion:
[cairo] color fonts and CAIRO_OPERATOR_SOURCE
Uli Schlachter
2017-09-11 08:44:58 UTC
Permalink
Hi everyone,

yesterday I was asked to comment here:

https://github.com/i3/i3/pull/2925

The issue seems to be: With operator SOURCE, drawing a color glyph
clears the entire surface. So, while "normal" glyphs are supposed to be
a mask that is then filled, color glyphs seem to be handled as an
unbounded source. This doesn't make a difference for OVER, but for lots
of other operators (at least SOURCE) it obviously matters.

I didn't investigate this at all. I did not even try to reproduce.
Hence, this ping. Could one of you please look at this, confirm this
really happens, and say what should be done about this? Thanks.

And yes, in the thread on color fonts, Matthias Clasen answered one of
Okay... so what is the new model? What happens when I draw a color glyph
with operator XOR and a red source?
The red source is ignored for color glyphs because they are used as the
source.
So apparently this behaviour is by design, meaning that glyphs can only
really be used with operator OVER any more (well, and some others). So
let me ask this another why: Is this really a good behaviour?

Oh and one more thing: Who updates cairo's docs and all the explanations
on the web page? ("glyphs work like this, except when they do not").

Cheers,
Uli

P.S.: The list of recipents is copied from the recent thread on color
fonts. I have no overview of how people ended up in this list. Sorry if
$YOU are the wrong recipent.
P.P.S: Yes, I also included Gtk-devel-list. I vaguely remember someone
saying that this stuff is relevant there. Dear moderator, sorry for the
work that this causes you.
--
99 little bugs in the code
99 little bugs in the code
Take one down, patch it around
117 little bugs in the code
-- @irqed
--
cairo mailing list
***@cairographics.org
https://lists.cairog
Matthias Clasen
2017-09-11 11:13:44 UTC
Permalink
Post by Uli Schlachter
So apparently this behaviour is by design, meaning that glyphs can only
really be used with operator OVER any more (well, and some others). So
let me ask this another why: Is this really a good behaviour?
I think you are jumping to conclusions here. The only glyphs for which this
is a problem
with the current code are color glyphs. Most glyphs are still fine with
other operators. One
answer I gave on irc is: if you want to do fancy stuff with text, you
better control which
fonts are involved, so use a custom context (which can avoid loading color
glyphs for the
emoji family). But that is not a great answer. Some ideas for a better one:

- Add an api to find out if a fond has color glpyhs
- Add an api to control loading of color glyphs
- Clip when painting color glyphs to not affect the target outside the
extent of the glyph
Post by Uli Schlachter
Oh and one more thing: Who updates cairo's docs and all the explanations
on the web page? ("glyphs work like this, except when they do not").
I can take a look at docs. No idea about the web page.
Bill Spitzak
2017-09-11 18:17:30 UTC
Permalink
For normal monochrome text Cairo acts like the text is a mask. It is
not the source image. So drawing text should absolutely not alter any
pixels that are "outside" all the glyphs.

It seems like the "ideal" thing to do with color glyphs is to treat
them as much like a mask as possible. When they are rendered it acts
like the source is the *unpremultiplied* version of the color glyph,
with the alpha set to 1 everywhere, while the mask is the alpha of the
color glyph intersected with the actual mask. It then renders using
the current Cairo operator. However I also think this idea will
produce a lot of useless combinations and would be complex and slow
(though OVER and SOURCE can be special-cased).

A much simpler and probably preferable alternative is to have any
operation other than OVER just ignore the color of the glyph and use
the alpha of the glyph as the shape, then render just like any
monochrome letter. This would be useful for making drop shadows and
other effects on the text. You could also specify that it is done this
way only for unbounded operators, or only for a subset that is
"non-additive". I do think filling the shapes with a solid color is
useful enough that one of the operators (probably SOURCE) should
support it.




On Mon, Sep 11, 2017 at 4:13 AM, Matthias Clasen
Post by Matthias Clasen
Post by Uli Schlachter
So apparently this behaviour is by design, meaning that glyphs can only
really be used with operator OVER any more (well, and some others). So
let me ask this another why: Is this really a good behaviour?
I think you are jumping to conclusions here. The only glyphs for which this
is a problem
with the current code are color glyphs. Most glyphs are still fine with
other operators. One
answer I gave on irc is: if you want to do fancy stuff with text, you better
control which
fonts are involved, so use a custom context (which can avoid loading color
glyphs for the
- Add an api to find out if a fond has color glpyhs
- Add an api to control loading of color glyphs
- Clip when painting color glyphs to not affect the target outside the
extent of the glyph
Post by Uli Schlachter
Oh and one more thing: Who updates cairo's docs and all the explanations
on the web page? ("glyphs work like this, except when they do not").
I can take a look at docs. No idea about the web page.
--
cairo mailing list
https://lists.cairographics.org/mailman/listinfo/cairo
--
cairo mailing list
***@cairographics.org
https
Behdad Esfahbod
2017-09-12 05:39:56 UTC
Permalink
It was actually not that complicated:
https://bugs.freedesktop.org/show_bug.cgi?id=102661
Post by Uli Schlachter
Hi everyone,
https://github.com/i3/i3/pull/2925
The issue seems to be: With operator SOURCE, drawing a color glyph
clears the entire surface. So, while "normal" glyphs are supposed to be
a mask that is then filled, color glyphs seem to be handled as an
unbounded source. This doesn't make a difference for OVER, but for lots
of other operators (at least SOURCE) it obviously matters.
I didn't investigate this at all. I did not even try to reproduce.
Hence, this ping. Could one of you please look at this, confirm this
really happens, and say what should be done about this? Thanks.
And yes, in the thread on color fonts, Matthias Clasen answered one of
Okay... so what is the new model? What happens when I draw a color glyph
with operator XOR and a red source?
The red source is ignored for color glyphs because they are used as the
source.
So apparently this behaviour is by design, meaning that glyphs can only
really be used with operator OVER any more (well, and some others). So
let me ask this another why: Is this really a good behaviour?
Oh and one more thing: Who updates cairo's docs and all the explanations
on the web page? ("glyphs work like this, except when they do not").
Cheers,
Uli
P.S.: The list of recipents is copied from the recent thread on color
fonts. I have no overview of how people ended up in this list. Sorry if
$YOU are the wrong recipent.
P.P.S: Yes, I also included Gtk-devel-list. I vaguely remember someone
saying that this stuff is relevant there. Dear moderator, sorry for the
work that this causes you.
--
99 little bugs in the code
99 little bugs in the code
Take one down, patch it around
117 little bugs in the code
--
behdad
http://behdad.org/
Bill Spitzak
2017-09-13 18:07:44 UTC
Permalink
Post by Behdad Esfahbod
https://bugs.freedesktop.org/show_bug.cgi?id=102661
Yes that sounds just like my second suggestion.

To deal with the double-premultiply, I would just special-case OVER
(and perhaps a few other bounded operators). They cause the current
code to be run where it uses the glyph color+alpha as the source. All
other compositing operators ignore the glyph color, and use the glyph
alpha as the letter shape.

SOURCE can then be used to fill the glyph shapes with a constant color.
Post by Behdad Esfahbod
Post by Uli Schlachter
Hi everyone,
https://github.com/i3/i3/pull/2925
The issue seems to be: With operator SOURCE, drawing a color glyph
clears the entire surface. So, while "normal" glyphs are supposed to be
a mask that is then filled, color glyphs seem to be handled as an
unbounded source. This doesn't make a difference for OVER, but for lots
of other operators (at least SOURCE) it obviously matters.
I didn't investigate this at all. I did not even try to reproduce.
Hence, this ping. Could one of you please look at this, confirm this
really happens, and say what should be done about this? Thanks.
And yes, in the thread on color fonts, Matthias Clasen answered one of
Okay... so what is the new model? What happens when I draw a color glyph
with operator XOR and a red source?
The red source is ignored for color glyphs because they are used as the
source.
So apparently this behaviour is by design, meaning that glyphs can only
really be used with operator OVER any more (well, and some others). So
let me ask this another why: Is this really a good behaviour?
Oh and one more thing: Who updates cairo's docs and all the explanations
on the web page? ("glyphs work like this, except when they do not").
Cheers,
Uli
P.S.: The list of recipents is copied from the recent thread on color
fonts. I have no overview of how people ended up in this list. Sorry if
$YOU are the wrong recipent.
P.P.S: Yes, I also included Gtk-devel-list. I vaguely remember someone
saying that this stuff is relevant there. Dear moderator, sorry for the
work that this causes you.
--
99 little bugs in the code
99 little bugs in the code
Take one down, patch it around
117 little bugs in the code
--
behdad
http://behdad.org/
--
cairo mailing list
https://lists.cairographics.org/mailman/listinfo/cairo
--
cairo mailing list
***@cairographics.org
https://lists.cairogr
Behdad Esfahbod
2017-09-20 19:15:29 UTC
Permalink
Post by Bill Spitzak
Post by Behdad Esfahbod
https://bugs.freedesktop.org/show_bug.cgi?id=102661
Yes that sounds just like my second suggestion.
To deal with the double-premultiply, I would just special-case OVER
(and perhaps a few other bounded operators). They cause the current
code to be run where it uses the glyph color+alpha as the source. All
other compositing operators ignore the glyph color, and use the glyph
alpha as the letter shape.
SOURCE can then be used to fill the glyph shapes with a constant color.
I'm not sure how I feel about that.
Post by Bill Spitzak
Post by Behdad Esfahbod
Post by Uli Schlachter
Hi everyone,
https://github.com/i3/i3/pull/2925
The issue seems to be: With operator SOURCE, drawing a color glyph
clears the entire surface. So, while "normal" glyphs are supposed to be
a mask that is then filled, color glyphs seem to be handled as an
unbounded source. This doesn't make a difference for OVER, but for lots
of other operators (at least SOURCE) it obviously matters.
I didn't investigate this at all. I did not even try to reproduce.
Hence, this ping. Could one of you please look at this, confirm this
really happens, and say what should be done about this? Thanks.
And yes, in the thread on color fonts, Matthias Clasen answered one of
Okay... so what is the new model? What happens when I draw a color glyph
with operator XOR and a red source?
The red source is ignored for color glyphs because they are used as
the
Post by Behdad Esfahbod
Post by Uli Schlachter
source.
So apparently this behaviour is by design, meaning that glyphs can only
really be used with operator OVER any more (well, and some others). So
let me ask this another why: Is this really a good behaviour?
Oh and one more thing: Who updates cairo's docs and all the explanations
on the web page? ("glyphs work like this, except when they do not").
Cheers,
Uli
P.S.: The list of recipents is copied from the recent thread on color
fonts. I have no overview of how people ended up in this list. Sorry if
$YOU are the wrong recipent.
P.P.S: Yes, I also included Gtk-devel-list. I vaguely remember someone
saying that this stuff is relevant there. Dear moderator, sorry for the
work that this causes you.
--
99 little bugs in the code
99 little bugs in the code
Take one down, patch it around
117 little bugs in the code
--
behdad
http://behdad.org/
--
cairo mailing list
https://lists.cairographics.org/mailman/listinfo/cairo
--
behdad
http://behdad.org/
Bill Spitzak
2017-09-20 19:39:31 UTC
Permalink
Post by Behdad Esfahbod
Post by Bill Spitzak
Post by Behdad Esfahbod
https://bugs.freedesktop.org/show_bug.cgi?id=102661
Yes that sounds just like my second suggestion.
To deal with the double-premultiply, I would just special-case OVER
(and perhaps a few other bounded operators). They cause the current
code to be run where it uses the glyph color+alpha as the source. All
other compositing operators ignore the glyph color, and use the glyph
alpha as the letter shape.
SOURCE can then be used to fill the glyph shapes with a constant color.
I'm not sure how I feel about that.
Yes there is a problem in that you cannot make a partially-transparent
shadow with this. I'm not sure if perhaps one of the other compositing
operators (ATOP?) will produce the desired result.

All I can say for sure is that OVER must produce the colored glyphs or
you will break everything, and that SOURCE is currently useless so it
makes sense to change what it does.
--
cairo mailing list
***@cairographics.org
h
Loading...