Things are better then they used to be, but not quite there yet. The OS needs to know the DPI (dots per inch) of the monitor. Modern monitor hardware has something called EDID, which reports the hardware details to the OS, including the display size in cm. But ... some EDIDs lie, or the OS ignores it.
Have a look at what this site does with JavaScript
:
Display DPI detector - find out DPI of your monitor
The code is there to see, and the following lines query the OS for its figures:
Code:
<script type='text/javascript'> dpi_x = document.getElementById('testdiv').offsetWidth; dpi_y = document.getElementById('testdiv').offsetHeight;
</script>
You could use these figures to scale graphics accordingly. However, this is nevertheless what the OS reports, and may not reflect reality. It tells me that this netbook has a 96x96 DPI resolution, while a few seconds with a ruler and a calculator tell me that it's more like 120 DPI. The EDID in my case has the correct physical dimensions (220mm x 129mm = 10" diagonal) - so Ubuntu should have picked this up, but it didn't - or chose not to.
In my case I can now set the OS (Ubuntu Linux) to display at 120 DPI, but not everyone knows there's even a problem ...