CanvasRenderingContext2D bugs.
Reported by
orchlonb...@gmail.com,
Aug 8 2016
|
||
Issue descriptionChrome 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)
,
Aug 10 2016
P.S: Firefox works fine and shows the expected output as mentioned in the bug.
,
Sep 12 2016
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
,
Sep 12 2016
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 |
||
Comment 1 by ranjitkan@chromium.org
, Aug 10 2016Labels: M-54 OS-Linux OS-Mac OS-Windows
Owner: ranjitkan@chromium.org
Status: Untriaged (was: Unconfirmed)