Got a few notes on this idea:
On Tue, March 11, 2008 6:39 am, Peter Moulder 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:
fitText = none | increaseTextSize | decreaseTextSize | changeTextSize
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).
I read about textLength and lengthAdjust. Unfortunately it states that "spacingAndGlyphs indicates that the advance values are adjusted and the glyphs themselves stretched or compressed in one axis". Which I read as meaning a change in aspect ratio, which is not desired behavior in this circumstance.
Inkscape unfortunately doesn't implement it at the moment. It would be nice if it were implemented.
Indeed it would ;-).
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.
I have just found that out (sorry I only work on this as a hobby or if relevant to work). I suppose this only really applies to flowed text (since that is how a bounding rectangle is specified in Inkscape). I suppose we should substitute <flowRoot> and <flowSpan> in place of <text> and <tspan> respectively.
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.
You are absolutely correct. I realized this shortly after posting. There would also need to be a "baseTextSize" attribute.
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.
Yes, this attribute would be used by inkscape to set specific font-sizes in the style of the <flowRoot> and <flowSpan> elements. So it would only even be needed when editing.
What do you think?
Edward Flick