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

text positioning

From: darcy w.christ <darcy@1000camels.com>
Date: Tue, 21 Oct 2003 17:26:36 -0400
To: www-svg@w3.org
Message-Id: <402E73EB-040D-11D8-88B0-000A959FFC3E@1000camels.com>


    i'm new to this list.  i hope my question is appropriate for this 

    i'm trying to produce an svg from a script.  the svg is very simple. 
  All i really need to do is create an image of a certain size, and 
place multiple lines of text within a certain location on the image.  
My problem is that i am unable to get control over the text.  Here's 
what i'm producing so far:

  <?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20001102//EN" 
<svg width="864" height="648">
	<style type="text/css">
	.textClass {
		font-size: 139px;
		font-family: Arial;
		fill: #000000;
	<rect x="0" y="0" width="864px" height="648px" fill="none" 
stroke="none" />
	<rect x="445" y="68" width="374px" height="160px" fill="none" 
stroke="black" />
	<text class="textClass" x="445" y="68" dy="1em" text-anchor="start">

i've also played around with mutliple lines like so:

	 <tspan x="445" dy="1em">second line</tspan>

my issue is that i would like to be able to vertically center the text 
within the box.  i am getting the font size from another image 
application (image magick) and it is choosing the font size based upon 
the space of the box and the text itself.  But when i take the values i 
have an create this svg, everything is good except the vertical 
placement.  i've even figured out how to center or align right by 
setting the text-anchor and changing the x value appropriately.  But, 
as for the height, i'm not sure how to approach this.  How does one 
work with the font information (like ascenders and descenders)?  Is 
there a way to refer to them in a relative way, much like the dy 
property that i use?

i appreciate any help, including tips on the best place to learn more 
about svg.

~darcy w. christ
Received on Tuesday, 21 October 2003 17:38:40 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:53:59 UTC