title: Why do rendered pixels differ from real pixels?
body: <p>In my HTML i have a <code>&lt;div&gt;</code> (call it the panel) with fixed width that contains some text; that text is set to <code>font-size: 25px; line-height: 25px;</code> in the accompanying CSS. It so happens that the text ends up as 36 lines. </p>
  
  <p>Given that all margins, paddings and borders are zero, you'd expect the height of the panel to be <code>36 * 25px = 900px</code>, and that is in fact what i find in Firefox, using the DOM's <code>getBoundingClientRect()</code> method.</p>
  
  <p>However, in Google Chrome i get different figures; it would appear the panel is only 892.7999877929688px high while lines are 24.799999660915798px high. Dividing those two numbers still gives 36 though. It looks like there is a scaling ratio between nominal pixels as set in the CSS and real pixels as reported by <code>getBoundingClientRect()</code>; in my case, this is 1.0080645299120465 nominal per real pixels.</p>
  
  <p>One more piece of evidence comes from Chromium running inside an nwjs app where i initially observed the discrepancy. During my tests, it showed consistently a <em>different</em> ratio from the one in Chrome. Now, at some point during my tests, the pixels reported by Chromium suddenly jumped to the integer values as reported in Firefox; i'm not sure what i did to make this happen. </p>
  
  <p>It could be expected that the fractional ratios are in some way linked to page zoom; after all, at very small sizes, Chrome and Chromium reflow the text (and sometimes do it wrong). And indeed, varying the zoom in Chrome leads to different ratios, and making Chrome zoom in to the max will make the ratio flat out at 1. Still, my Chromium app is not zoomed in to the max and still has <strike>a fractional ratio.</strike> an integer pixels ratio in the test but a fractional value in the real app. </p>
  
  <p>For all i presently know, all i can do to obtain the ratio so i can make sound, consistent box size measuring with JavaScript is to set up a box of known size and measure it. </p>
  
  <p>I'm still wondering what the source of the observed behavior is. Are there any reports of it? Is it an intentional or an emergent behavior of the renderer? Was it ever discussed by the devs? Is there an API to obtain the ratio?</p>
  
  <p>I've put some code on a gist at <a href="https://gist.github.com/loveencounterflow/d8c20b9021d2ab3f573a">https://gist.github.com/loveencounterflow/d8c20b9021d2ab3f573a</a> to simplify testing.</p>