Notes On Units Handling in Extensions in 0.91

From Inkscape Wiki
Revision as of 02:05, 31 January 2015 by ~suv (talk | contribs)
Jump to navigation Jump to search

Since the release of Inkscape 0.48.4 there has been a fundamental change made in the scaling of length variables in Inkscape. The viewBox attribute has been introduced as a standard feature of all files, and its size is determined by the units that are chosen for the variable inkscape:document-units (see dialog Document Properties: Default Units). In the Python extensions this has led to the requirement that units of length variables must be explicitly taken into account, otherwise they will not scale correctly when changing the Default Units (see Bug 1240455). Previously this type of scaling was done with a call to inkex.unittouu(), the new syntax for this call is self.unittouu(). Attached is a list of situations in which you may need to do this type of scaling, to convert to document units:

  1. When reading the document height/width (see, r12722)
  2. When reading any .inx file input variable that has units of length (see, r13007)
  3. When specifying a stroke-width or font-size in a style attribute (see, r12722; r12722, r13001, r13036)
  4. For multiple items in a group, it may be more efficient to scale the group with a transform, rather than scaling individual objects (see, r13015).
  5. Remember that console commands like inkscape --query-all, to query the bbox, return pixels regardless of the document units, so they will need to be converted (see, r13028).
  6. Remember that guides, which are in the sodipodi:namedview section, are not affected by document units, so they do not need to be scaled (see, r12722, r13007).
  7. If you are creating new classes unique to your application, you may need to provide a mechanism to allow your new class to continue to access unittouu() (see, r12722, r13027).

Original version of the notes by Alvin Penner: scaling.txt (see comments 31-34 in Bug 1240455)