SVGCairoVisitor>>
drawString: aString forElement: anElement
| fontDescription xCoord yCoord dxCoord dyCoord layout |
self needsMoreWork. "Something funky with text positioning (lower than expected). Probably need to set more parameters. For now do a translate with negated height"
fontDescription := WriteStream on: (String new: 256).
xCoord := anElement x ifNil: [0] ifNotNil: [:x | x first].
dxCoord := anElement dx ifNil: [0] ifNotNil: [:dx | dx first].
yCoord := anElement y ifNil: [0] ifNotNil: [:y | y first].
dyCoord := anElement dy ifNil: [0] ifNotNil: [:dy | dy first].
layout := Pango.Layout text: aString.
anElement fontFamily ifNotNil:
[:fontFamily |
fontDescription
nextPutAll: fontFamily;
space].
anElement fontWeight ifNotNil:
[:fontWeight |
fontDescription
nextPutAll: fontWeight svgString;
space].
anElement fontStyle ifNotNil:
[:fontStyle |
fontStyle = 'normal'
ifFalse:
[fontDescription
nextPutAll: fontStyle;
space]].
anElement fontSize
ifNotNil: [:fontSize | fontSize printOn: fontDescription].
fontDescription isEmpty
ifFalse: [layout fontDescriptionString: fontDescription contents].
cairoContext
translateX: (xCoord valueFor: anElement) + (dxCoord valueFor: anElement)
y: (yCoord valueFor: anElement) + (dyCoord valueFor: anElement)
- layout height.
anElement fill isNil ifFalse: [cairoContext source: anElement fill].
layout
showOn: cairoContext;
release