6 from __future__ import absolute_import
7 #Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
10 from fabmetheus_utilities.geometry.creation import lineation
11 from fabmetheus_utilities.geometry.geometry_tools import path
12 from fabmetheus_utilities.geometry.geometry_utilities import evaluate
13 from fabmetheus_utilities import euclidean
14 from fabmetheus_utilities import svg_reader
17 __author__ = 'Enrique Perez (perez_enrique@yahoo.com)'
18 __credits__ = 'Art of Illusion <http://www.artofillusion.org/>'
19 __date__ = '$Date: 2008/02/05 $'
20 __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agpl.html'
23 def getGeometryOutput(derivation, elementNode):
24 "Get vector3 vertexes from attributes."
25 if derivation == None:
26 derivation = TextDerivation(elementNode)
27 if derivation.textString == '':
28 print('Warning, textString is empty in getGeometryOutput in text for:')
32 for textComplexLoop in svg_reader.getTextComplexLoops(derivation.fontFamily, derivation.fontSize, derivation.textString):
33 textComplexLoop.reverse()
34 vector3Path = euclidean.getVector3Path(textComplexLoop)
35 sideLoop = lineation.SideLoop(vector3Path)
36 sideLoop.rotate(elementNode)
37 geometryOutput += lineation.getGeometryOutputByManipulation(elementNode, sideLoop)
40 def getGeometryOutputByArguments(arguments, elementNode):
41 "Get vector3 vertexes from attribute dictionary by arguments."
42 evaluate.setAttributesByArguments(['text', 'fontSize', 'fontFamily'], arguments, elementNode)
43 return getGeometryOutput(None, elementNode)
45 def getNewDerivation(elementNode):
47 return TextDerivation(elementNode)
49 def processElementNode(elementNode):
50 "Process the xml element."
51 path.convertElementNode(elementNode, getGeometryOutput(None, elementNode))
55 "Class to hold text variables."
56 def __init__(self, elementNode):
58 self.fontFamily = evaluate.getEvaluatedString('Gentium Basic Regular', elementNode, 'font-family')
59 self.fontFamily = evaluate.getEvaluatedString(self.fontFamily, elementNode, 'fontFamily')
60 self.fontSize = evaluate.getEvaluatedFloat(12.0, elementNode, 'font-size')
61 self.fontSize = evaluate.getEvaluatedFloat(self.fontSize, elementNode, 'fontSize')
62 self.textString = elementNode.getTextContent()
63 self.textString = evaluate.getEvaluatedString(self.textString, elementNode, 'text')