Bug 1353000 - Fix canvas size used for font inspector preview to avoid risk of non-integer scaling that may lead to rounding discrepancies. r=gl
authorJonathan Kew <jkew@mozilla.com>
Fri, 28 Apr 2017 20:04:34 +0100
changeset 355723 795219dcd057dccf452e19a9d095268fc7ef8443
parent 355722 ecddb82a88d8f49b6c4d58871556fcc037ed2d4d
child 355724 fb34b24b4cd63f732bcb001dbda047dd62044f04
push id31736
push userarchaeopteryx@coole-files.de
push dateSat, 29 Apr 2017 09:10:55 +0000
treeherdermozilla-central@308cdb913d71 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl
bugs1353000
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1353000 - Fix canvas size used for font inspector preview to avoid risk of non-integer scaling that may lead to rounding discrepancies. r=gl
devtools/server/actors/styles.js
--- a/devtools/server/actors/styles.js
+++ b/devtools/server/actors/styles.js
@@ -1514,19 +1514,19 @@ function getFontPreviewData(font, doc, o
 
   let canvas = doc.createElementNS(XHTML_NS, "canvas");
   let ctx = canvas.getContext("2d");
   let fontValue = fontStyle + " " + previewFontSize + "px " + font + ", serif";
 
   // Get the correct preview text measurements and set the canvas dimensions
   ctx.font = fontValue;
   ctx.fillStyle = fillStyle;
-  let textWidth = ctx.measureText(previewText).width;
+  let textWidth = Math.round(ctx.measureText(previewText).width);
 
-  canvas.width = textWidth * 2 + FONT_PREVIEW_OFFSET * 2;
+  canvas.width = textWidth * 2 + FONT_PREVIEW_OFFSET * 4;
   canvas.height = previewFontSize * 3;
 
   // we have to reset these after changing the canvas size
   ctx.font = fontValue;
   ctx.fillStyle = fillStyle;
 
   // Oversample the canvas for better text quality
   ctx.textBaseline = "top";