Closed
Bug 1261699
Opened 9 years ago
Closed 9 years ago
Canvas fillText character spacing issues with Skia canvas on Linux
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
VERIFIED
FIXED
mozilla48
Tracking | Status | |
---|---|---|
firefox48 | --- | verified |
People
(Reporter: i93.borg, Assigned: lsalzman)
References
Details
(Whiteboard: [gfx-noted])
Attachments
(6 files, 4 obsolete files)
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
Build ID: 20160318175143
Steps to reproduce:
Test code:
```
<!DOCTYPE html>
<html lang="en">
<head>
<title>Canvas Text Test</title>
</head>
<body>
<canvas id="canvas" style="border: 1px solid #333"></canvas>
<script>
var canvas = document.getElementById('canvas'),
ctx = canvas.getContext('2d'),
xy = 100;
canvas.width = xy;
canvas.height = xy;
ctx.clearRect(0, 0, xy, xy);
ctx.textBaseline = 'top';
ctx.font = '10px sans-serif';
ctx.fillText('1234567890', 5, 5);
ctx.font = '11px sans-serif';
ctx.fillText('1234567890', 5, 25);
ctx.font = '12px sans-serif';
ctx.fillText('1234567890', 5, 45);
ctx.font = '13px sans-serif';
ctx.fillText('1234567890', 5, 65);
ctx.font = '14px sans-serif';
ctx.fillText('1234567890', 5, 85);
</script>
<body>
</html>
```
Actual results:
See attached screenshots.
Firefox has issues with spacing - it varies and some characters overlap. Compare this to Chromium which does a better job.
Expected results:
Better looking text.
Updated•9 years ago
|
Component: Untriaged → Canvas: 2D
Product: Firefox → Core
Updated•9 years ago
|
Whiteboard: [gfx-noted]
Comment 5•9 years ago
|
||
George, how do the Firefox & Chromium results compare if you specify a particular font (instead of the generic 'sans-serif', which looks like it is configured differently in the two browsers)? E.g. replace 'sans-serif' in your testcase a specific font family such as 'Liberation Sans' or 'Open Sans' or others that you may have installed.
Does the problem you see in Firefox happen with *all* fonts, or is it related to one particular face?
Flags: needinfo?(jfkthame) → needinfo?(i93.borg)
Looks my default is "Open Sans". Switching to "Liberation Sans" makes things better, but if you look at the spacing vs Chromium it is still not as consistent.
Flags: needinfo?(i93.borg)
FreeSans has better spacing, but one of the sizes cuts off the top of the text.
I have added text string to my test and the results are not great...
Attachment #8737628 -
Attachment is obsolete: true
Attachment #8737629 -
Attachment is obsolete: true
Attachment #8742229 -
Attachment is obsolete: true
Attachment #8742282 -
Attachment is obsolete: true
Reporter | ||
Comment 10•9 years ago
|
||
Comment 11•9 years ago
|
||
Wow, that looks really bad!
I don't see issues like this on my Linux system, though, so I wonder what's different. My current guess is that if you adjust system configuration settings like font hinting and antialiasing, that may affect the result; if so, it would be good to know what particular settings are "good" or "bad".
Reporter | ||
Comment 12•9 years ago
|
||
Looks like it's "gfx.canvas.azure.backends" - I set mine to "skia" a while back and forgot all about it.
So looks like it's a choice between **** looking fonts or terrible canvas performance. :(
Feel free to close this since it's not a supported configuration.
Reporter | ||
Comment 13•9 years ago
|
||
P.S. Thanks for your help though, sorry it was a bit of a wild goose chase!
Reporter | ||
Comment 14•9 years ago
|
||
And this is possibly a duplicate of bug 1208644?
Although that case is not specifically focused on canvas, but it's also about text rendering.
Comment 15•9 years ago
|
||
Well, I don't think this should just be closed.... AIUI, the intention is to move to skia as the default (only?) backend, and if that's going to regress text rendering -- and your screenshots certainly look unacceptable! -- then there's a problem.
In fact, it looks like the change has been made for Firefox 48 in bug 1244754, so I'm going to mark this as blocking that bug, and let the graphics/skia people take a look.
Blocks: 1244754
Flags: needinfo?(milan)
Flags: needinfo?(jmuizelaar)
Summary: Canvas fillText character spacing issues → Canvas fillText character spacing issues with Skia canvas on Linux
Updated•9 years ago
|
Flags: needinfo?(jmuizelaar) → needinfo?(lsalzman)
Assignee | ||
Comment 16•9 years ago
|
||
Is this fixed in nightly for you? We made some changes to subpixel text positioning around the time of the 45 release that may have regressed Skia/Cairo fonts, which we subsequently fixed more recently.
Flags: needinfo?(lsalzman) → needinfo?(i93.borg)
Assignee | ||
Comment 18•9 years ago
|
||
(In reply to George from comment #17)
> No, I still see the problem in nightly.
I can't reproduce the issue here with nightly using Skia canvas. Can you paste the "Graphics" section of "about:support"?
Flags: needinfo?(i93.borg)
Reporter | ||
Comment 19•9 years ago
|
||
````
Features
Compositing OpenGL
Asynchronous Pan/Zoom wheel input enabled
WebGL Renderer X.Org -- Gallium 0.4 on AMD TURKS (DRM 2.43.0, LLVM 3.7.1)
Hardware H264 Decoding No
GPU #1
Active Yes
Description X.Org -- Gallium 0.4 on AMD TURKS (DRM 2.43.0, LLVM 3.7.1)
Vendor ID X.Org
Device ID Gallium 0.4 on AMD TURKS (DRM 2.43.0, LLVM 3.7.1)
Driver Version 3.0 Mesa 11.1.2
Diagnostics
AzureCanvasAccelerated 0
AzureCanvasBackend skia
AzureContentBackend cairo
AzureFallbackCanvasBackend none
CairoUseXRender 0
````
Flags: needinfo?(i93.borg)
Assignee | ||
Comment 20•9 years ago
|
||
Would you be willing to provide the contents of the files in /etc/fonts/conf.d for me? I would need to check the settings inside some of the files there. They may be symlinks so if you use tar, make sure to use the -h option to deference them.
Also, what distribution/version of Linux?
Flags: needinfo?(i93.borg)
Updated•9 years ago
|
Flags: needinfo?(milan)
Reporter | ||
Comment 21•9 years ago
|
||
I am running Debian Sid, Linux 4.4.0 kernel.
Flags: needinfo?(i93.borg)
Assignee | ||
Comment 22•9 years ago
|
||
(In reply to George from comment #21)
> Created attachment 8742526 [details]
> Contents of /etc/fonts/conf.d/
>
> I am running Debian Sid, Linux 4.4.0 kernel.
I notice you have autohinting enabled, which I was sort of suspicious of being related to this.
Still digging to find out what's going on, though...
Assignee | ||
Comment 23•9 years ago
|
||
So it looks like cairo-ft is checking the autohint setting in fontconfig when creating the font from it. However, this is not represented in Cairo's font options in the API. Thus, we need to check the fontconfig for autohinting, store it in the font, then pass it along when we go to create glyph rendering options.
Skia needs this information passed along in the glyph rendering options so that it's font host can load the freetype font with the same load options Cairo is passing in cairo-ft. When they do not match, you end up with badly offset glyphs that can be improperly cropped as we observed here. Matching is good!
Assignee: nobody → lsalzman
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #8743627 -
Flags: review?(jfkthame)
Comment 24•9 years ago
|
||
Comment on attachment 8743627 [details] [diff] [review]
preserve user fontconfig autohint settings in Cairo glyph rendering options
Review of attachment 8743627 [details] [diff] [review]:
-----------------------------------------------------------------
Looks reasonable to me.
I notice there's an explicit comment that "We don't want to force the use of the autohinter..." in the current code. AFAICS, that originates from gw280's patches in bug 736276, so perhaps we should ask him for a quick sanity-check just in case there was some other issue that we're overlooking here.
Attachment #8743627 -
Flags: review?(jfkthame)
Attachment #8743627 -
Flags: review+
Attachment #8743627 -
Flags: feedback?(gwright)
Comment 25•9 years ago
|
||
Comment 26•9 years ago
|
||
Looking back at the original bug where that was added, I think we should be ok here.
Updated•9 years ago
|
Attachment #8743627 -
Flags: feedback?(gwright) → feedback+
Comment 27•9 years ago
|
||
bugherder |
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox48:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla48
Updated•9 years ago
|
Flags: qe-verify+
Comment 28•9 years ago
|
||
Confirming the fix for this issue on Ubuntu 14.04 x64 using Firefox 48.0b2, build ID 20160620091522.
You need to log in
before you can comment on or make changes to this bug.
Description
•