Summary: | [CAIRO] SVG/Canvas fonts miss gradients/pattern support | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Dirk Schulze <krit> | ||||||||||||||||||||
Component: | SVG | Assignee: | Nobody <webkit-unassigned> | ||||||||||||||||||||
Status: | RESOLVED FIXED | ||||||||||||||||||||||
Severity: | Normal | CC: | alp | ||||||||||||||||||||
Priority: | P2 | Keywords: | Cairo | ||||||||||||||||||||
Version: | 528+ (Nightly build) | ||||||||||||||||||||||
Hardware: | PC | ||||||||||||||||||||||
OS: | Linux | ||||||||||||||||||||||
Attachments: |
|
Description
Dirk Schulze
2008-04-19 00:50:01 PDT
It's a little bit more problematic. If you comment the line out (...source_rgb()) the text is rendered fine (gradients and colors). But if the text has a stroke. The complete text is filled with the settings of the stroke. Cg gives a setTextDrawingMode(cTextStroke) or setTextDrawingMode(cTextFill) in SVGPaintServer... back to GraphicsContext. Perhaps cairo should do the same? Created attachment 20811 [details]
dosplay of SVG-Text
In Cairo SVG-text works with this changes. But texts on normal webpages are broken. Perhaps HTML-texts should do the same like SVG-texts. To hard-code the font-color isn't a good idea.
Created attachment 20815 [details]
Display SVG-text
SVG-Text is now displayed right and the most HTML-pages work now too.
Some texts still don't get there color (like text in buttons or textfields). They are white. Stroke of HTML-text doesn't work like they should.
Created attachment 20821 [details]
Display SVG-text
The patch of above is the wrong file. Now the right one.
Created attachment 20823 [details]
Display texts in SVG and HTML
This patch fixes the problem with displaying texts in SVG and HTML. I had to use a workaround to get a full support.
I had to hard-code the fill-rule for SVG's to CAIRO_FILL_RULE_EVEN_ODD to differentiate between HTML- and SVG-texts. For HTML-text the font-color has to be hard-coded at present. If you don't do it (e.g. use of setPlatformFillColor(), see attachment above) not all HTML-objects are displayed right.
HTML makes only use of CAIRO_FILL_RULE_WINDING.
I couldn't find any optical differences in SVG between the two fill-rules.
This patch fixes bug-report: 18663, 15619 too.
Created attachment 20830 [details]
Painting of texts in SVG and HTML
Same changes like above:
SVG- and HTML-text are displayed well now, with a workaround. Added support for text-stroke (SVG needs it).
Plus text-shadow on stroked Texts in HTML/CSS.
Created attachment 20845 [details]
Painting of texts in SVG and HTML
The workaround only affects texts in SVG now. More information look 2 comments above.
This patch fixes bug-report: 18663, 15619 too.
Comment on attachment 20845 [details]
Painting of texts in SVG and HTML
I appreciate the push to get SVG fixed but we can't really take a patch that misuses fill rule as a flag to denote text drawing. We'll need to figure out how to do this properly -- we might need to fix the GraphicsContext abstraction if it's too closely tied to the assumption that the platform graphics library has separate brushes for text and graphics.
It should be possible to add displaysSVGtext() and setDiaplaysSVGtext() to GraphicsContext. You could differentiate between HTML- and SVG-text again but it would be a hack to. Another idea was to use setPlatformFillColor(); and setPlatformStrokeColor();(Isn't used yet). But if you try to give the fillColor to 'cairo_t* cr = m_data->cr;' with cairo_set_source_rgba(), not every text in HTML is affected by it (strange). And there will be problems to include text-stroke of CSS into Cairo since the complete text uses the fillColor or the strokeColor (depending which Color was set at last). *** Bug 15619 has been marked as a duplicate of this bug. *** Solid colors will be fixed with https://bugs.webkit.org/show_bug.cgi?id=20699 (third part). I can't run LayoutTests, so I can't land it yet. To fix patterns and gradients they have to be platformindependent first: https://bugs.webkit.org/show_bug.cgi?id=21205 https://bugs.webkit.org/show_bug.cgi?id=20543 Created attachment 25237 [details]
Fonts with Pattern/Gradient
Moved the fill and stroke code out of fillPath() and strokePath() to common methods for paths and texts.
Created attachment 25238 [details]
Fonts with Pattern/Gradient
The same idea as the previous patch, but add own methods for text fill/stroke. The other patch could be a bit slower on filling paths (but not noticeable).
I would prefer the previous patch.
Created attachment 28065 [details]
Fonts with Pattern/Gradient
Make use of the new calls fillGradient/strokeGradient and fillPattern/strokePattern in GraphicsContext to support patterns and gradient on Fonts in Cairo.
I also added support for globalAlpha on Fonts for Cairo.
I forgot to mension that I commented the clipToImageBuffer on CanvasRenderingContext2D::drawTextInternal. Just CG needs this hack for filling and stroking texts with gradients. All other platforms have their own way to do it. Comment on attachment 28065 [details]
Fonts with Pattern/Gradient
r=me, the CG specific path makes me sad, oh well.
landed in r41279. |