On 24-9-2013 22:16, Krzysztof KosiĆski wrote:
2013/9/24 <ian_bruce@...2136...>:
The other absolute unit identifiers from CSS (i.e., pt, pc, cm, mm, in) are all defined as an appropriate multiple of one px unit (which, according to the previous item, is defined to be equal to one user unit), based on what the SVG user agent determines is the size of a px unit (possibly passed from the parent processor or environment at initialization time). For example, suppose that the user agent can determine from its environment that "1px" corresponds to "0.2822222mm" (i.e., 90dpi). Then, for all processing of SVG content: - "1pt" equals "1.25px" (and therefore 1.25 user units) - "1pc" equals "15px" (and therefore 15 user units) - "1mm" would be "3.543307px" (3.543307 user units) - "1cm" equals "35.43307px" (and therefore 35.43307 user units) - "1in" equals "90px" (and therefore 90 user units)
So it seems that 1px should ideally correspond to 1in / dpi of the monitor. E.g. the units are supposed to map 1:1 to the real world when the document is displayed at 100% zoom.
The px, pc, mm, cm, in ratios are fixed, so it seems like they can be compiled in, while the DPI value could be obtained from the EDID of the monitor. GDK has functions which can be used for this:
gdk_screen_get_monitor_geometry() gdk_screen_get_monitor_height_mm() gdk_screen_get_monitor_width_mm()
I interpret the text slightly different. Indeed the name "px" for "user unit" is very unfortunate, and I think for the discussion it would help to not use "px" if it is not clear if "user unit" or "pixels" is meant.
In any case, I believe that the pc, mm, cm, in ratios are fixed (duh ;), but *not* the "px"/"user unit" ratio. The viewbox (together with a defined document height and width in real-world units) defines the ratio of user unit to the other units. In a document without viewbox or with non-real-unit document height&width, we have to resort to some arbitrary/default value. This default value might be what Krzysztof suggests: use whatever DPI the monitor is using. But that will cause non-viewbox documents to be shown with different sizes (mm, in, cm,...) on different machines. Confusing for people perhaps, because the default Inkscape document does not specify the relation between user units and real-world units, and so in that case if someone thinks he is using "mm", he is actually using an ill-defined "mm". I think it is better to have some fall-back dpi value stored in the preferences, so people have better control over it and can handle interoperability better (on documents without proper scale definition).
Now for rendering, I agree that it would be nice if we can map a "1in" rectangle to 1in on-screen. There are some means in Inkscape to do that, but I haven't looked if it uses gdk_screen_get_monitor_geometry() or friends.
I see three possibilities for the "px" unit in our UI: A) "px" in our UI means "user unit". And thus it does *not* mean "pixels". In this case, in a document with viewbox (0,0,10,10), and width=10mm, height=10mm, it means: 1px = 1mm. B) "px" in our UI means "pixel on your current device". And thus "1px" in our UI, does *not* always mean "1px" written in XML/SVG. In this case, in a document with viewbox (0,0,10,10), and width=10in, height=10in, with a 200 dpi monitor, it means: 200px (Inkscape UI) = 1in = "1px" (SVG/XML). C) same as B but with dpi value set in preferences (say, the current 90dpi). I think this is the current state (90dpi "hardcoded" in units.xml).
regards, Johan