W3C home > Mailing lists > Public > www-svg@w3.org > May 2011

RE: measuring glyphs with script -- can it be done?

From: David Dailey <ddailey@zoominternet.net>
Date: Sun, 29 May 2011 18:10:43 -0400
To: "'David Dailey'" <ddailey@zoominternet.net>, "'www-svg'" <www-svg@w3.org>
Message-ID: <005f01cc1e4d$40e81b50$c2b851f0$@net>
BTW, I found this discussion dating from 2005:

http://lists.w3.org/Archives/Public/www-svg/2005Jun/0075.html 

 

It doesn't seem to help, and perhaps hints that the problem is indeed
unsolved within SVG, unless someone knows of progress on this front.

 

cheers

David

 

From: www-svg-request@w3.org [mailto:www-svg-request@w3.org] On Behalf Of
David Dailey
Sent: Sunday, May 29, 2011 3:09 PM
To: 'www-svg'
Subject: measuring glyphs with script -- can it be done?

 

I've been fussing with this problem for some time now and am beginning to
think the spec is broken in addition to all the browsers.

 

Perhaps someone can show me a different approach? An additional approach? 

 

To give an idea of the problem take a look at this picture

http://srufaculty.sru.edu/david.dailey/svg/TopAlignBrowsers.png

of how five browsers handle the file at

http://granite.sru.edu/~ddailey/svg/tspanmeasure.svg 

 

For an explanation of what is going on see here:

http://granite.sru.edu/~ddailey/svg/tspanmeasure3.svg 

 

I have manually positioned the glyphs of the word "trampoline" so that the
tops of the glyphs all align at the red line above. This is a standard
typographic effect used in numerous logos, shop signs, advertisements, album
covers, etc.

 

All browsers seem to manage this manual use of a comma-delimited set of
y-values on a text tag: y="128,120,120,120,120,120,128,127,120,127,120,120",
though in this case I also added a bit of stretching: textLength="605"
lengthAdjust="spacingAndGlyphs". SBUG means suspected bug; with all the bugs
found here, I suspect it will be 2017 by the time I have figured out how to
and actually gotten around to filing all the bug reports in all these
different browsers. I'm more concerned with how to do what I want to rather
than where I can do it.

 

Results of stretching:

IE9 and Opera behave as I think they should,

SBUG: FF seems to stretch the glyphs but not the spacing and not just
horizontally, and not the right amount 

SBUG: Safari stretches the spacing but not the glyphs

SBUG: Sarari doesn't antialias the text

SBUG: Chrome - oh my - this is just awful!

 

Okay , next, let's see what it looks like to apply some text-decoration
using script:

 

                Opera, Safari and Chrome seem to allow the application of
Q.setAttributeNS(null,"text-decoration","overline")

                SBUG: E9 and Firefox seem to think this attribute is not
settable (if it isn't settable then the spec must have a bug)

 

However:

                SBUG: Opera, Chrome and Safari leave the overline a fixed
distance over the text, rather than being a straight overline. Isn't
IE/ASV's behavior in
http://srufaculty.sru.edu/david.dailey/svg/TopAlignBrowsers.png

 how it ought to be?

                SBUG: Chrome and Safari make the overline strokes cover only
the extent of the glyph underneath, hence resulting in a series of line
segments rather than one overline. Both IE9 and Opera make continuous lines
if the effect is applied manually and without differential y values for the
glyphs.

 

Next, let's rebuild the string "trampoline" as a series of <tspan>s in hopes
that we might be able to measure the glyphs if they are not all inside the
same <text> (which, by the way, doesn't seem to work so well, if you push
the "make boxes" button before the "retype" button.)

Push the "Retype" button.

                Opera does it the way I would like (and as I recall IE/ASV
does too)

                SBUG: IE9, FF, Safar and Chrome all seem to miss the
textLength="605" lengthAdjust="spacingAndGlyphs" attributes on the
dynamically filled text tag (It should be the same as the text below it)

                SBUG: Chrome and Firefox seem to miss the
text-decoration="overline" attributes on the dynamically filled text tag.

 

 

Now let's see if we can actually create the desired effect: text aligned so
that the tops of all glyphs are aligned at their tops. Push the "Top
justify" button. This uses the getExtentOfChar() method which is supposed to
give us something like a bounding box around the glyphs. I tried getBBox,
but some browsers complained that I wasn't suppose to. 

                SBUG: (spec) why doesn't the spec allow us to draw a
bounding box around glyphs? Wouldn't it make sense, from an author's
perspective to allow this?

                SBUG: Opera which comes closest (along with IE/ASV) top
aligns all characters except for the "p" and the "g" both of which have
descenders that extend below the baseline. Is there any way to adjust for
this??

                SBUG: Firefox, IE9, Safari and Chrome all seem to move the
text different amounts upward or downward, but all glyphs move the same
amount!

                SBUG: all these browsers seem to have different ideas about
how far the text as a whole should be moved.

 

Let's try drawing boxes (IE/ASV sort of does what I want) here

                SBUG: Opera draws all its boxes over in some private little
space at the upper left of the screen - but at least the boxes are
differently sized

                SBUG: : Firefox, IE9, Safari and Chrome all seem to drawn
boxes around the glyphs, but though the boxes have different widths, they
all have the same height. 

 

If these browsers are behaving according to spec here then:

                SBUG: the spec has a bug regarding getExtentOfChar. What
good is it if you can't do this? 

 

Finally, does anyone know any other way to accomplish this simple
typesetting feature through script, without doing it by hand and eye? The
spec's text description is lengthy and complex and I have forged into it
several times now without seeing anything to do this. There are things it
talks about which I know I don't understand, but then one gets the sense
that one might not need to know them, unless one is building a user agent.
I have not seen anything in the test suite
(http://dev.w3.org/SVG/profiles/1.1F2/test/svg/ ) which would address this.

 

I found Cameron (heycom) and Bjoern talking about a GVTGlyphVector method in
2006, but that seems to be a Batik only thing, SFAIK.

 

Ideas?

David

 
Received on Sunday, 29 May 2011 22:11:20 GMT

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