New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 635427 link

Starred by 3 users

Issue metadata

Status: WontFix
Owner: ----
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 3
Type: Bug



Sign in to add a comment

CanvasRenderingContext2D bugs.

Reported by orchlonb...@gmail.com, Aug 8 2016

Issue description

Chrome Version       : 52.0.2743.116 (Official Build) m (32-bit)
URLs (if applicable) : http://stackoverflow.com/questions/38823353/chrome-canvas-2d-context-measuretext-giving-me-weird-results
Other browsers tested:
  Add OK or FAIL, along with the version, after other browsers where you
have tested this issue:
     Safari:
    Firefox: OK 48.0
         IE:

What steps will reproduce the problem?

Run the below javascript code.

let canvas = document.createElement('canvas')
let ctx = canvas.getContext('2d')
ctx.font = '11pt Calibri'
ctx.fillStyle = '#000000'

console.log(ctx.font)
console.log(ctx.measureText('M').width)
let temp = ctx.font
ctx.font = temp
console.log(ctx.font)
console.log(ctx.measureText('M').width)

What is the expected result?

Expected results are.

11pt Calibri
12.53........// (accuracy varies)
11pt Calibri
12.53........// (accuracy varies)
Both numbers must match

What happens instead?

15px Calibri // (11pt transformed to 15px on the fly, which is incorrect)
12.53....... // (accuracy varies, number is slightly larger than correct)
15px Calibri // (11pt transformed to 15px on the fly, which is incorrect)
12.82....... // (number is a massive 0.3 off the previous number, yet they should be the same)


 
Components: Platform>DevTools>JavaScript
Labels: M-54 OS-Linux OS-Mac OS-Windows
Owner: ranjitkan@chromium.org
Status: Untriaged (was: Unconfirmed)
Able to reproduce the issue on Windows, MAC and Ubuntu OS for chrome stable version 52.0.2743.116. Issue is a non regression since seen from M50 builds. Previous builds used to throw the below error when executed scripts.

Uncaught SyntaxError: Unexpected identifier
InjectedScript._evaluate
InjectedScript._evaluate
InjectedScript.evaluate

Untriaging it so that it gets addressed.
P.S: Firefox works fine and shows the expected output as mentioned in the bug.
Cc: ranjitkan@chromium.org
Components: -Platform>DevTools>JavaScript Blink>Canvas
Owner: ----
Status: WontFix (was: Untriaged)
the SO thread [1] indicates that 'pt' isnt recommended for canvas and i'd agree.
also nearly all getters for sizes return "px", rather than any original unit. getComputedStyle will always return 'px' rather than the 'em','pt' or whatever.

So i think this ends up as a wontfix.

[1] http://stackoverflow.com/questions/38823353/chrome-canvas-2d-context-measuretext-giving-me-weird-results
According to canvas specs, the getter should return the CSS serialized value. And according to CSS serializing specs [1], you should return any number with a 6 decimals precision.

That's still a bug. https://jsfiddle.net/68q0on9x/

[1]https://www.w3.org/TR/cssom-1/#serializing-css-values

Sign in to add a comment