def textAt( x, y, text, style, rotate=0 ): "Places a test-element at global-coordinates." elem = TextElement(x=str(x), y=str(y)) elem.text = text elem.style = style if rotate != 0: elem.set('transform','rotate({},{},{})'.format(rotate,x,y)) return elem
def add_text(self, x, y, text): """Add a text label at the given location""" elem = TextElement(x=str(x), y=str(y)) elem.text = str(text) elem.style = { 'font-size': self.svg.unittouu(self.options.fontsize), 'fill-opacity': '1.0', 'stroke': 'none', 'font-weight': 'normal', 'font-style': 'normal', 'fill': '#999' } return elem
def generateText(self, text, x, y, size): tspan = Tspan() tspan.text = text textElement = TextElement() textElement.set("x", str(x)) textElement.set("y", str(y)) # textElement.style = "font-size:50px; font-family:Metal Lord" textElement.style = "font-size:{}px;".format(size) textElement.append(tspan) return textElement
def draw_text(self, text, add_size=0, anchor='start', **kwargs): """Draw a textual label""" vtext = TextElement(**kwargs) vtext.style = { 'fill': self.options.font_color, 'font-family': self.options.font, 'font-size': str(self.options.font_size + add_size) + 'px', 'font-style': 'normal', 'font-variant': 'normal', 'font-weight': 'normal', 'font-stretch': 'normal', '-inkscape-font-specification': 'Bitstream Charter', 'text-align': anchor, 'text-anchor': anchor, } vtext.text = str(text) return vtext