Draw text transform
Jean-Michel BRUCK (3009) 359 posts |
Hi, Compute Tbox matrice a= 65536, b= 0, c= 0, d= 65536, e= 70000, f= 100000 The transformation works correctly if the translation coefficients of the matrix are zero. The result |
nemo (145) 2546 posts |
Not allowed. (matrix X,Y must be zero) It’s no consolation, but apps ought to fix it when they see it: |
Jean-Michel BRUCK (3009) 359 posts |
Thanks Nemo, Difficult because there can be several texts for example on a map and the text is no longer in its place:-( The result is better than decoding in !Netsurf. Question: can we apply a transformation matrix on a group, it will suit me a lot because it is very used by SVG files ? |
nemo (145) 2546 posts |
The reason that the matrix in a Transformed Text Object must have a zero x,y is because it is followed by the contents of a standard Text Object, which already has an x,y. This is in contrast to a Transformed Sprite which does use the x,y in the matrix, because the standard Sprite Object is positioned by its bounding box only, not by an x,y anchor. 35 years of precedent means none of this is going to change now. The maxim is “Strict on output, lenient on input” – so if you are creating Transformed Text Objects in code then you must ensure the matrix has x,y=0. But if you are loading Draw files then you ought to sanitise Transformed Text Objects if they’re malformed.
There are two approaches – the one !Draw takes is to recalculate bounding boxes on loading a file (regardless). So it ought to sanitise the matrix at the same time. Vantage however only recalculates bounding boxes upon editing an object (which is why I ‘changed’ the font size in the above GIF). But sanitising such objects only requires adding the matrix x,y to the object x,y and zeroing the matrix translation (and then recalculating the bounding box for safety) – notably this does not involve changing the byte size of any objects, so it is easy to do.
Vantage has done the above correction for a long time because it is mathematically correct (from one point of view). However, instead of obeying the two x,y offsets and recalculating the bounding box, one could instead take the bounding box as reliable and calculate the appropriate x,y to position the text within it. But there was no reason to believe that the bounding box was any more correct than the explicit coordinates – bounding boxes are often incorrect, in general.
What a lot of groups!
A group only contains a 12-byte name and the objects it comprises. A tag contains a single object (which can be a group of course) and an arbitrary amount of data. But neither has a concatenating matrix to apply to the contents. One could invent such an object (and many of my Draw objects contain such matrices) but that doesn’t allow !Draw and other applications to understand the resulting file. So, no. Instead, when converting SVG to Draw one must apply the concatenated matrix to the object in question – producing a transformed path, a Transformed Sprite Object or Transformed Text Object. In the latter case one must ensure the translation part is in the explicit X,Y coordinate, not in the “matrix” which must contain the affine transformation only. |
nemo (145) 2546 posts |
[This is no help for you, but Draw Object &414 is an IFR Object containing a transformation matrix and any other kind of file, which is passed to ImageFileRender to display (by a suitable version of IFR_DrawFile) and which can, in principle, be another DrawFile. Hence there is a way to apply a matrix to a Group (wrapped in its own DrawFile)… but currently that only exists on my machine. Sorry.] |
Jean-Michel BRUCK (3009) 359 posts |
Thanks for that info on text in Draw. I couldn’t find these by browsing the PRMs. Yes, the affine transform and the translation are applied to the starting point of the text in my program.So I treat matrices differently if it’s text. The SVG file was created by !Artworks (looked at the beginning of the SVG file) from a Drawfile created by RiscOSM, I think. Vantage looks very interesting. Thanks for the info on group objects, no matrix for them :-(
sniff! |
nemo (145) 2546 posts |
|
Jean-Michel BRUCK (3009) 359 posts |
Thanks Captain, Both of these programs are available on my site. Jules Vernes :-) |
Clive Semmens (2335) 3276 posts |
Link? Interesting! |
Jean-Michel BRUCK (3009) 359 posts |
Sorry, |
Clive Semmens (2335) 3276 posts |
:thumbsup: Thank you! Especially !Svg2Draw, something I was never brave enough to tackle! But interesting to take a look at the others, too. |
Jean-Michel BRUCK (3009) 359 posts |
Thanks, !Svg2Draw doesn’t claim to do the whole SVG standard, and it should be viewable with Draw. FYI, !PariGP allowed me to do and check the matrix calculations for !Svg2Draw transformations, a very powerful tool, Risc Os version. |
Clive Semmens (2335) 3276 posts |
Ah – I see. I could have done that, but I have so little use for transferring graphics in that direction that whatever I did in that line would be of very limited use to anyone else! It was the sheer size of the SVG standard, and the fact that it’s a moving target, put me off rather… Will take a look at !PariGP for sure, but not in the immediate future. Busy on other stuff… |