W3C home > Mailing lists > Public > www-svg@w3.org > September 2015

RE: Possible to resize text to max size within a box?

From: Smailus, Thomas O <Thomas.O.Smailus@boeing.com>
Date: Thu, 17 Sep 2015 20:36:21 +0000
To: Cameron McCormack <cam@mcc.id.au>, David Dailey <ddailey@zoominternet.net>
CC: "'Mats Blakstad'" <mats.gbproject@gmail.com>, "www-svg@w3.org" <www-svg@w3.org>
Message-ID: <175A0EE510663A46ACD5FF1A03AD46F51F129CCD@XCH-BLV-204.nw.nos.boeing.com>
This has been a feature I've been advocating for in the group for over a year, but since I don't write a browser and don't have a works statement that lets me do so, I'm sort of stuck just poking this issue.

At last years symposium in Santa Clara I pushed it again and there was some discussion about this issue.

CGM has it and for technical diagrams it is absolutely a must have to properly communicate and represent meaning by having text expanded/compressed to fit a box.

From an implementation algorithm I'd think you scale the font uniformly to achieve the height you need, then using the length_adjust parameter scale just the length to get the length required.  (as one option)

IE and Firefox do things differently, and none of them do it correctly, as the settings on the text element should flow through and consider any tspan subelements and then solve for the unknowns.

There was some talk  in Santa Clara on what to do with this - and I thought it was flowing up to CSS but I've not heard back.  It’s a critical and missing feature that we currently have ECMAscript workarounds trying to mitigate that are non-ideal because of the inconsistent ways browsers implement effects and what one can do in script.

If CSS isn’t taking up this issue I suggest we take it up formally in SVG2.

If textLength cannot be made precisely to specify the length text should be (what is it now, a request to hope it might be?), and provide a corresponding textHeight, then we need to come up with width/height like parameters on text.

And all of this, as pointed out, needs to be reconciled with multiline text.  SVG1.1se isn't multi-line aware, though I'd be happy with getting it on single-line SVG1.1se type text just fine - as that provides a path to migrate our hundreds of thousands of engineering diagrams from CGM to SVG in a predicable manner.

Thomas Smailus, Ph.D.  P.E.
Boeing Information Technology

> -----Original Message-----
> From: Cameron McCormack [mailto:cam@mcc.id.au]
> Sent: Thursday, September 17, 2015 0:45
> To: David Dailey
> Cc: 'Mats Blakstad'; www-svg@w3.org
> Subject: Re: Possible to resize text to max size within a box?
> Hi David and Mats,
> > http://srufaculty.sru.edu/david.dailey/svg/test/bubbles2.svg (works in
> > Chrome but not in Firefox – there was some part of textLength,(
> > maybe?) that either Firefox hadn’t done or I had done wrong – don’t
> > really remember) and of course Chrome will want me to rewrite all
> > these examples before SVG2 moves to recommended status in 2023
> > (barring objections) and is implemented cross browser in 2033. (humor)
> The stretching of text there seems to work for me in Firefox.  (Firefox
> doesn’t support textLength="" on <tspan>s, but does on a top <text>
> element.)
> I agree with Mats that adjusting the font-size to fit text in a particular space is
> a useful effect, and probably something that you’d want not only in SVG but
> CSS in general, although I am sure it is a difficult problem to solve once you
> have line breaks and floats and so on.
> lengthAdjust="spacingAndGlyphs" just applies a scale in one dimension.
> It shouldn’t be hard to extend that with another value that scales in both
> dimensions (although note that scaling the text as if it had a transform on it
> will not always get you the same result as scaling the font-size down, due to
> hinting at least).  (I feel like the group might have discussed this before…)
> --
> Cameron McCormack ≝ http://mcc.id.au/

Received on Thursday, 17 September 2015 20:37:06 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:47:42 UTC