W3C home > Mailing lists > Public > www-svg@w3.org > November 2002

Re: General Text Metrics Requirement

From: J. David Eisenberg <catcode@catcode.com>
Date: Tue, 19 Nov 2002 15:07:03 -0600 (CST)
To: "Kanaskie, Kurt A (Kurt)" <kkanaskie@lucent.com>
cc: "'www-svg@w3.org'" <www-svg@w3.org>, "'arazdow@mathsoft.com'" <arazdow@mathsoft.com>
Message-ID: <Pine.LNX.4.44.0211191458470.7741-100000@tengu.host4u.net>

On Tue, 19 Nov 2002, Kanaskie, Kurt A (Kurt) wrote:

> Allen,
> I too have been struggling with the inability to calculate string
> length. I'm transforming Schema with XSLT to generate SVG and I want to
> draw a simple text box. I can draw a bounding box using filters, but
> that still doesn't give me the extents of the text box, it just renders
> it. I need to know where the end of the text box is so I draw a
> connector from it to the next box.
> My strategy is to estimate the length of the string based on the font
> size, draw the bounding rectangle and then set the textLength attribute
> to expand or shrink the text to fit. Sounds good, but I discovered that
> textLength is not supported by Adobe 3.0 Build 76, my defacto plugin. Oh
> well.
> Another option is to use a fixed width font. Can someone identify a
> fixed with font-family value? Or where I can find a list of them?

I think that "courier, courier new, monospace" would do the trick.

Here's an idea which might work with Xalan, but which I haven't tested.  
Write an XSLT extension that opens up a bufferedImage and set its graphics
environment to use the same font and size as will go into the resultant
SVG.  Call stringWidth() and return the results. Then hope for the best.

J. David Eisenberg  http://catcode.com/
Received on Tuesday, 19 November 2002 16:10:00 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 March 2017 09:46:54 UTC