W3C home > Mailing lists > Public > www-svg@w3.org > July 2009

Re: SVG text flip-invariance

From: R. Timothy Edwards <tim.edwards@multigig.com>
Date: Tue, 07 Jul 2009 09:47:47 -0400
To: "Dr. Olaf Hoffmann" <Dr.O.Hoffmann@gmx.de>
Cc: www-svg@w3.org, Erik Dahlström <ed@opera.com>
Message-id: <4A535203.3050107@multigig.com>
Dear Olaf,

> Why is scale=(-1,1) relevant for the text?
> Does xcircuit have an x-axis from right to left?
> For postscript this is not the case, it is from left
> to right, bottom to top.
> 
> A simillar problem appears with graphical representations of functions,
> data sets, statistical material etc
> A program like grace caring about such data has a similar problem for
> SVG output, because the y-axis of SVG points down (top to bottom). 
> I think, they use a scale(1,-1) and some translations for the complete
> set of graphical objects and use additionally a matrix transformation
> on each text element (which can be decomposed again in a scale(1,-1)
> and some other transformations of course).

No, the problem is not the global orientation, which is easily taken
care of with a simple matrix transformation at the top-level and for
each text element, as you mention.

The problem typically occurs in tools like schematic capture programs
where you have a symbol, such as a logic gate, and you may flip or
rotate that symbol as needed to draw the circuit cleanly.  The symbol,
though, may contain text, such as the name of the gate, or the pin
names, or the instance number.  If you flip the orientation of the gate
symbol with respect to the Y-axis, you definitely do *not* want the
text inside it to appear in mirror-image.  You *do* want the text to
stay within the same bounding box that it would if the symbol were not
flipped (for example, a right-justified text becomes left justified
after the symbol is flipped across the Y-axis).  Likewise, if the symbol
is rotated through 180 degrees, you want the text inside it to appear
right-side-up, not upside-down.

There is always some ambiguity about what to do when a symbol is rotated
to 90 or -90 degrees.

The answer from Erik Dalström is satisfactory, in that if one is allowed
to access the top-level transformation matrix, one can adjust the text
accordingly.  However, a lot of arithmetic is involved, and it would be
rather nice to be able to specify that the direction of the text is
invariant to certain transformations as a simple property of the <text>
element.

As pointed out by Erik, there is a difference between text that is
adjusted so as to be "readable" (that is, for left-to-right fonts,
they should always read left to right, except for the limiting cases
of 90 and -90 degree rotation), and text that is truly invariant to
all rotations and flips, such that it always prints at zero degrees
rotation.  However, even so, I think that the solution he proposes of
using 'transform="ref(svg)"' is not quite right, because the tranformation
should not be invariant to scale (other than sign changed) and translation
within the hierarchy (for example, if a symbol has text centered on (0,0)
and the symbol is placed at (100, 0), one wants to have the text drawn
at (100, 0)).  However, it is pretty easy to correct the matrix values
in this case.

It is always possible to flatten the entire drawing such that there are
no reusable symbols (which is what I'm doing now in xcircuit, since it
is not strictly necessary to keep the symbol hierarchy in an output
format).  But that destroys much of the benefit of the format, and
prevents the use of SVG to directly manipulate the symbols, such as
one might wish to do in a web-based schematic capture program.

Geometry is always beautiful until it meets practicality. . .

						---Tim

+--------------------------------+-------------------------------------+
| Dr. R. Timothy Edwards (Tim)   | email: tim.edwards@multigig.com     |
| MultiGiG, Inc.                 | web:   http://www.multigig.com      |
| 100 Enterprise Way, Suite A-3  | phone: (831) 621-3283               |
| Scotts Valley, CA 95066        | cell:  (240) 401-0616               |
+--------------------------------+-------------------------------------+
Received on Tuesday, 7 July 2009 13:48:39 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:42 GMT