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

RE: baseline problem

From: Allen Razdow <arazdow@mathsoft.com>
Date: Mon, 5 May 2003 08:42:24 -0400
Message-ID: <8D1EA20CE6AB1043956A27D60E468F1CABE603@distrib.mathsoft.com>
To: "'Doug Schepers'" <doug@schepers.cc>, www-svg@w3.org

Thanks Doug,

I admit to being more of a potential user keeping a weather-eye on the SVG
design discussions, than an SVG expert.  But perhaps the view of an
interested "outsider" can be useful!

Mathml notwithstanding, consider displaying mathematical equations as an
example of careful placement of strings within graphical elements such as
fraction-bars, square-brackets and integral signs.  This sort of precision
requires knowing the bounding-box, baselines, and the offsets of particular
characters in strings.  When I last inquired about this, it seemed that the
only way to get true text metrics was to display them and then use scripts
to read actual size information via DOM.  Folks at SchemaSoft that had
written a Mathml to SVG converter confirmed this back then.

I'm not sure what specific feature to suggest, but a category of measurement
functions such as X-OFFSET-OF-SUBSTRING("foo", textEntityID) placed
somewhere in SVG, would do the trick, though probably requiring some
restrictions based on sequence of rendering.

Certainly, the accurate embedding of text in graphics will be a common
requirement in many commercial uses of SVG.  So long as the SVG community is
satisfied that this requirement is met, I'm happy :)


-----Original Message-----
From: Doug Schepers [mailto:doug@schepers.cc] 
Sent: Monday, May 05, 2003 12:39 AM
To: www-svg@w3.org
Subject: RE: baseline problem

Hi, Allen-

I'm not sure that is pertinent. Of course, you could make a font with
ascenders twice as high as capital letters (for whatever reson... maybe it's
a funky now-Western font or something, or it has accent marks), but since
'baseline-shift' can take units in percentages, it should be able to cope in
the way that Dario wants 'alignment-baseline="top"' to do. That is, if I
understand what Dario is trying to do... maybe they want to make it so that
all the letters are aligned by their top edge --along the height of the
tallest ascender-- instead of their bottom (sans descenders)? If you wanted
to do that, you could make your own custom font.

I made a simple font to show what I mean... even with an uncommonly tall
ascender, the results are still pretty acceptable when you use

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" >
<svg xmlns="http://www.w3.org/2000/svg" width="100%" height="100%">

<defs >
<font horiz-adv-x="1038" ><font-face
    panose-1="2 11 6 3 3 8 4 2 2 4"
    alphabetic="0" />
<missing-glyph horiz-adv-x="1229"
d="M102 -362V1444H1126V-362H102ZM217 -248H1012V1329H217V-248Z" />
<glyph unicode=" " glyph-name="space" horiz-adv-x="651" />
<glyph unicode="A" glyph-name="A" horiz-adv-x="1401" d="M700 1294L426
551H975L700 1294ZM586 1493H815L1384 0H1174L1038 383H365L229 0H16L586 1493Z"
<glyph unicode="f" glyph-name="f" horiz-adv-x="721" d="M760 1956 V1803 H584
Q485 1803 447 1763 T408 1519 V1120 H711 V977 H408 V0 H223 V977 H47 V1120
H223 V1598 Q223 1785 310 1870 T586 1956 H760 Z" />
<glyph unicode="t" glyph-name="t" horiz-adv-x="803" d="M375
1438V1120H754V977H375V369Q375 232 412 193T565 154H754V0H565Q352 0 271 79T190
369V977H55V1120H190V1438H375Z" />
   <line x1='5' y1='100' x2='695' y2='100' style='stroke:red;
stroke-width:1; fill:none; '/>
   <line x1='5' y1='120' x2='695' y2='120' style='stroke:red;
stroke-width:1; fill:none; '/>
   <text x='200' y='100' style='fill:black; text-anchor:middle;
      <tspan style='baseline-shift:baseline;'>
      <tspan style='baseline-shift:-100%;'>
   <text x='300' y='100' style='font-family:TallAscender; fill:black;
text-anchor:middle; font-size:16pt;'>
      <tspan style='baseline-shift:baseline;'>
      <tspan style='baseline-shift:-100%;'>


Allen Razdow wrote:
> I think it's a question of knowing how much to shift, which may vary by
> font, whether the particular string has ascenders, etc.
> -Allen
> -----Original Message-----
> From: Doug Schepers [mailto:doug@schepers.cc]
> Sent: Sunday, May 04, 2003 8:53 PM
> To: dario
> Cc: www-svg@w3.org
> Subject: RE: baseline problem
> Why not just use 'baseline-shift'? Am I missing something here?
> <svg>
>    <line x1='5' y1='100' x2='695' y2='100' style='stroke:red;
> stroke-width:1; fill:none; '/>
>    <text x='300' y='100' style='fill:black; text-anchor:middle;
> font-size:16px;'>
>       <tspan style='baseline-shift:baseline;'>
>          baseline
>       </tspan>
>       <tspan style='baseline-shift:sub;'>
>          sub
>       </tspan>
>       <tspan style='baseline-shift:super;'>
>          super
>       </tspan>
>       <tspan style='baseline-shift:-33%;'>
>          percentage (-33%)
>       </tspan>
>       <tspan style='baseline-shift:3px;'>
>          length (3px)
>       </tspan>
>       <tspan style='baseline-shift:-80%;'>
>          Baseline-Shift (-80%)
>       </tspan>
>    </text>
> </svg>
> Hope that helps-
> -Doug
> Chris Lilley wrote:
> >
> >
> > On Sunday, May 4, 2003, 10:49:09 PM, dario wrote:
> >
> > d> OK, what can i do to draw text under specified line
> >
> > d> so, there is line at 100 pixels from the top, i'd like text
> > drawn just under
> > d> it. is it possible?
> >
> > I understand the use case and no, not directly. You need to know what
> > the text size is and then offset that much by yourself.
> >
> > <text x="100" y="62" font-size="12" text-anchor="middle">blah</text>
> >
> > --
> >  Chris                            mailto:chris@w3.org
> >
Received on Monday, 5 May 2003 09:26:35 GMT

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