
On Mon, Mar 10, 2008, Edward Flick wrote:
I'm looking to add (or looking for) a feature which shrinks text to fit inside of a text box (per line preferably or per box). I couldn't find a part of the SVG spec which covers this. Could an addition be made inside of the Inkscape namespace for an attribute that would fit on a <text> or <tspan> element (which applies the same font size to the whole block in which it was declared to fit the widest line, IOW if it is applied to <text> block the whole block would get that new font size or when applied to <tspan> it would be a line by line fit) which would be specified something along the lines of:
[revised version:]
fitText = none | increaseTextSize | decreaseTextSize | changeTextSize
Is there something similar in the SVG spec I should be looking at? Does this seem like a reasonable solution? I'm not asking anybody to code this, I'm just wanting some input.
The closest that comes to mind is the textLength and associated lengthAdjust attributes, that apply to the text, tspan and textPath elements (http://www.w3.org/TR/SVG11/text.html#TextElementTextLengthAttribute).
Inkscape unfortunately doesn't implement it at the moment. It would be nice if it were implemented.
Regarding your proposed attribute & its behaviour:
Note that neither <text> nor <tspan> specify a box, so the question arises what length the longest line should adapt to.
With the increase/decrease options, the proposal doesn't yet specify the editing behaviour. E.g. suppose that the increase option is in force, and one selects the text and types `A' (replacing the existing text). I suppose that the `A' would grow to fit the specified length. Then what happens when one types a `B' ? The attribute just says `increase', so I suppose that the A and B retain the same huge size rather than now decreasing the font size. Except of course that that is unlikely what the user actually wants. One could instead have that the text only grows once the user stops editing that text object, but one still has essentially the same problem if for some reason the user wants to temporarily stop editing after typing the `A' (perhaps to look at something else in the drawing or to fix up a mistake one has just noticed) and then goes back to editing the text only to see that the text is now huge and doesn't shrink.
Regarding adding an inkscape-specific attribute:
For a once-off "scale this text to fit", no attribute is needed. Adding an attribute would mean that the text could be made to scale when editing the text in Inkscape in future.
Note that inkscape is intended to be conformant SVG software: e.g. we want what's seen in inkscape/inkview to accurately show what other conformant SVG user agents show. In order to achieve this intent, any inkscape-specific attributes must only affect editing behaviour, not rendering behaviour. Thus, if one later views in inkview/inkscape with different fonts available or after manually editing the SVG file, then the software must render according to the SVG, ignoring any inkscape-specific attributes.
(If some rendering adaptation behaviour were sufficiently valuable, then a course of action consistent with this goal would be to change the SVG spec to accommodate it.)
pjrm.