Skip to content

Commit

Permalink
Improve geom creation, scaling and translation
Browse files Browse the repository at this point in the history
  • Loading branch information
WandererFan authored and wwmayer committed Mar 18, 2014
1 parent c700d9d commit 13cdc44
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 132 deletions.
9 changes: 1 addition & 8 deletions src/Mod/Draft/Draft.py
Expand Up @@ -2134,8 +2134,6 @@ def makePoint(X=0, Y=0, Z=0,color=None,name = "Point", point_size= 5):
def makeShapeString(String,FontFile,Size = 100,Tracking = 0):
'''ShapeString(Text,FontFile,Height,Track): Turns a text string
into a Compound Shape'''

# temporary code
obj = FreeCAD.ActiveDocument.addObject("Part::Part2DObjectPython","ShapeString")
_ShapeString(obj)
obj.String = String
Expand Down Expand Up @@ -4580,7 +4578,7 @@ def __init__(self, obj):
obj.addProperty("App::PropertyString","String","Draft","Text string")
obj.addProperty("App::PropertyFile","FontFile","Draft","Font file name")
obj.addProperty("App::PropertyFloat","Size","Draft","Height of text")
obj.addProperty("App::PropertyInteger","Tracking","Draft",
obj.addProperty("App::PropertyFloat","Tracking","Draft",
"Inter-character spacing")

def execute(self, obj):
Expand All @@ -4590,11 +4588,6 @@ def execute(self, obj):
if obj.String and obj.FontFile:
if obj.Placement:
plm = obj.Placement
# TODO: os.path.splitunc() for Win/Samba net files?
#head, tail = os.path.splitdrive(obj.FontFile) # os.path.splitdrive() for Win
#head, tail = os.path.split(tail)
#head = head + '/' # os.split drops last '/' from head
print "_ShapeString FontFile: ", obj.FontFile
CharList = Part.makeWireString(obj.String,
obj.FontFile,
obj.Size,
Expand Down
12 changes: 4 additions & 8 deletions src/Mod/Part/App/AppPartPy.cpp
Expand Up @@ -330,28 +330,26 @@ static PyObject * makeWireString(PyObject *self, PyObject *args)
const char* fontfile;
const char* fontspec;
bool useFontSpec = false;
float height;
int track = 0;
double height;
double track = 0;

Py_UNICODE *unichars;
Py_ssize_t pysize;

PyObject *CharList;

if (PyArg_ParseTuple(args, "Ossf|i", &intext, // compatibility with old version
if (PyArg_ParseTuple(args, "Ossd|d", &intext, // compatibility with old version
&dir,
&fontfile,
&height,
&track)) {
Base::Console().Message("** makeWireString dir + font\n");
useFontSpec = false; }
else {
PyErr_Clear();
if (PyArg_ParseTuple(args, "Osf|i", &intext,
if (PyArg_ParseTuple(args, "Osd|d", &intext,
&fontspec,
&height,
&track)) {
Base::Console().Message("** makeWireString useFontSpec\n");
useFontSpec = true; }
else {
Base::Console().Message("** makeWireString bad args.\n");
Expand All @@ -378,10 +376,8 @@ static PyObject * makeWireString(PyObject *self, PyObject *args)

try {
if (useFontSpec) {
Base::Console().Message("** makeWireString trying fontspec\n");
CharList = FT2FC(unichars,pysize,fontspec,height,track); }
else {
Base::Console().Message("** makeWireString trying dir + file\n");
CharList = FT2FC(unichars,pysize,dir,fontfile,height,track); }
}
catch (Standard_DomainError) { // Standard_DomainError is OCC error.
Expand Down

0 comments on commit 13cdc44

Please sign in to comment.