Re: [chromium-discuss] How is Chrome rounding fractional pixel font sizes?

Skip to first unread message

Ramesh Srigiriraju

unread,
Dec 13, 2015, 7:42:51 AM12/13/15
to mail....@gmail.com, Chromium-discuss
Vincent,

I just ran your code in Mozilla Firefox 42, and it seems to be rounding to the nearest whole pixel value.  The first five lines in each section are the same length, and so are the last five lines, but the last five are all longer than the first five.  Also, the last five lines in each section are the same length as the first five lines in the next section.

On Fri, Dec 11, 2015 at 5:30 AM, Vincent Wong <mail....@gmail.com> wrote:
The following JS Bin contains 3 sets of 10 lines of text. Each line increases the font size by 0.1px. The sets start at 11, 12 and 13px respectively:



I am working on Windows 10, Chrome 47. I would ideally expect a smooth increase in line length; however, the result seems to be fairly random stepping of line length. The above screenshot was taken at 100% browser zoom, but the result changes significantly if the browser zoom is changed.

Could anyone shed light on what is going on here, and whether this is actually a bug?

From CrossBrowserTesting, it appears that Chrome 37, the first stable version with DirectWrite, produces a smooth increase in line length; Chrome 38 onwards shows the stepping as above.

If DirectWrite is turned off (chrome://flags), at 100% zoom, there is obvious rounding of fractional font sizes to the nearest whole pixel. At least this is predictable, and can be worked around. With DirectWrite on (default), I'm not currently able to explain what is happening.

--
--
Chromium Discussion mailing list: chromium...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-discuss

---
You received this message because you are subscribed to the Google Groups "Chromium-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-discu...@chromium.org.

linePixels.JPG

Koji Ishii

unread,
Dec 14, 2015, 9:10:05 PM12/14/15
to ramesh.sr...@gmail.com, mail....@gmail.com, Chromium-discuss
Chrome disables anti-alias and/or subpixel positioning on specific conditions where doing so improves legibility. When they are disabled, as a natural consequence, you won't be able to get linear scale.

Please try changing the font from "Arial" to "Segoe" for instance, and you will see your example scales linearly.

The different behaviors across versions are likely that problems for the condition were reported and fixed in that version.

/koji

Vincent Wong

unread,
Dec 15, 2015, 4:23:18 AM12/15/15
to Chromium-discuss, ramesh.sr...@gmail.com, mail....@gmail.com
Thank you both for your input.

It looks like there was a change to kerning behaviour in Chrome 47 on Windows, which has now been listed as a regression in the following Chromium issue (Koji, I believe you are mentioned in the issue):

Vince.

Koji Ishii

unread,
Dec 15, 2015, 8:56:29 PM12/15/15
to Vincent Wong, Chromium-discuss, ramesh.sr...@gmail.com

It is somewhat related but is a different topic, I'll comment on the bug for that one.

Technically I can see no way for a subpixel-disabled font to scale linearly. If you could talk about use cases, maybe we can understand what you want to solve better.

/koji

Reply all
Reply to author
Forward
0 new messages