1443: Fix ShapeString user font selection on Windows

This commit is contained in:
WandererFan
2014-02-26 19:28:24 -05:00
committed by wmayer
parent a48ec3ce45
commit b3d1b7a2ea
5 changed files with 68 additions and 30 deletions

View File

@@ -326,8 +326,10 @@ show(PyObject *self, PyObject *args)
static PyObject * makeWireString(PyObject *self, PyObject *args)
{
PyObject *intext;
const char* dir;
const char* dir;
const char* fontfile;
const char* fontspec;
bool useFontSpec = false;
float height;
int track = 0;
@@ -336,35 +338,51 @@ static PyObject * makeWireString(PyObject *self, PyObject *args)
PyObject *CharList;
if (!PyArg_ParseTuple(args, "Ossf|i", &intext,
&dir,
&fontfile,
&height,
&track)) {
Base::Console().Message("** makeWireString bad args.\n");
return NULL;
}
if (PyArg_ParseTuple(args, "Ossf|i", &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,
&fontspec,
&height,
&track)) {
Base::Console().Message("** makeWireString useFontSpec\n");
useFontSpec = true; }
else {
Base::Console().Message("** makeWireString bad args.\n");
return NULL; }
}
if (PyString_Check(intext)) {
PyObject *p = Base::PyAsUnicodeObject(PyString_AsString(intext));
if (!p) {
Base::Console().Message("** makeWireString can't convert PyString.\n");
return NULL;
}
pysize = PyUnicode_GetSize(p);
pysize = PyUnicode_GetSize(p);
unichars = PyUnicode_AS_UNICODE(p);
}
else if (PyUnicode_Check(intext)) {
pysize = PyUnicode_GetSize(intext);
else if (PyUnicode_Check(intext)) {
pysize = PyUnicode_GetSize(intext);
unichars = PyUnicode_AS_UNICODE(intext);
}
else {
Base::Console().Message("** makeWireString bad text parameter.\n");
Base::Console().Message("** makeWireString bad text parameter.\n");
return NULL;
}
try {
CharList = FT2FC(unichars,pysize,dir,fontfile,height,track); // get list of wire chars
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.
PyErr_SetString(PyExc_Exception, "makeWireString failed - Standard_DomainError");