SVGText
Part of wslib
superclass : SVGObject
related classes : SVGTSpan, AvailableFonts
The SVGText object contains data text, its printing location, font and color.
an SVGText object can hold Strings and SVGTSpan objects.
creation
SVGText ( string, x, y, fontName, fontSize, fillColor, dx, dy, name, transform )
creates a new object with the instance variables as described below and in the SVGObject helpfile
string : a String with the text to be included, or an array of strings and SVGTSpan objects
instance variables
string
string actually doesn't hold a String, it is an array of Strings and SVGTSpan objects.
x, y
x,y location where the string is printed. If these are arrays each char of the string gets printed at the next position
please note: Adobe Illustrator® leaves these open (nil) and uses the transform element (an SVGTransform) for the placement of the text in saved files.
SVGText( "bumpy text", 100, {10.rand + 100}!6, fontSize: 24 ).plot; // array for y
dx, dy
relative x,y location where the string is printed. Can also be array
fontName
name of the font. If the fontName is nil, plotting will happen with Font( "Helvetica", 12 )
fontSize
size of the font in pt
fontFound
(getter only) boolean states wether the provided font is available on the current system.
This is checked at creation, but can also be checked by hand using checkFont.
If the fontName is nil, fontFound will be true.
fillColor
color of the text. This can be
a Color
a String or Symbol with a color name ( e.g. "light_blue" or "#0000FF" )
"none" or nil
SVGText( "bit of text", 100, 100, "Courier", 24, "olive", 0,0, "my text" ).plot;
anchor
the anchor states where the x/y location is relative to the string
SVGText only supports the default anchor ('start') for plotting, and will warn if another anchor is found
instance methods
fullString
returns one string with the full text (including that from SVGTSpan objects).
fullString_ ( newString )
replaces the string contents by a new String
font, font_ ( aFont )
get or set the font as a regular Font object.
checkFont
checks if the font is available using AvailableFonts. If not it posts a message.
This sets the fontFound variable.
++ anSVGText
Concatenate the strings of two SVGText attributes, or if the other is a String, add it to the string.
Creates a new SVGText object
at ( index ), copySeries ( first, second, last )
calls .at and copySeries on string, also to provide compatibility with the ..[..] syntax in SC