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

RE: General Text Metrics Requirement

From: Kanaskie, Kurt A (Kurt) <kkanaskie@lucent.com>
Date: Wed, 20 Nov 2002 09:17:32 -0500
Message-ID: <E4BB443436F22D4AB9E84B06AB7C4CE001BD2223@nj7460exch004u.ho.lucent.com>
To: "'Allen Razdow'" <arazdow@mathsoft.com>, "'J. David Eisenberg'" <catcode@catcode.com>, "Kanaskie, Kurt A (Kurt)" <kkanaskie@lucent.com>
Cc: "'www-svg@w3.org'" <www-svg@w3.org>

Thanks Allen for the suggestions on fixed width font, that should suffice for my application.

The suggestion to use a buffered image reminds me of my X11 programming days, where the solution is to query the Graphics Context for things like stringLength(). I started down that path with XSLT, DOM, etc., but it seemed like a long hike with lots of side trails.

Regards,
________________________________________________________________
Kurt Kanaskie
Lucent Technologies
kkanaskie@lucent.com
work:	(610) 778-1069
home:	(610) 756-4435


 -----Original Message-----
From: 	Allen Razdow [mailto:arazdow@mathsoft.com] 
Sent:	Tuesday, November 19, 2002 4:23 PM
To:	'J. David Eisenberg'; 'Kanaskie, Kurt A (Kurt)'
Cc:	'www-svg@w3.org'
Subject:	RE: General Text Metrics Requirement

David,

Thanks for this, I've seen this done from script,
doing it from XSLT is a good idea too.  Do you agree that
this should be more directly supported in SVG or is
there a reason why that doesn't make sense?

-Allen

-----Original Message-----
From: J. David Eisenberg [mailto:catcode@catcode.com]
Sent: Tuesday, November 19, 2002 4:07 PM
To: Kanaskie, Kurt A (Kurt)
Cc: 'www-svg@w3.org'; 'arazdow@mathsoft.com'
Subject: Re: General Text Metrics Requirement


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 Wednesday, 20 November 2002 09:18:23 GMT

This archive was generated by hypermail 2.3.1 : Friday, 8 March 2013 15:54:23 GMT