- Trying to fix something I caused:
Added a function call to creator.c that is needed by exppython, but forgot to add the function also to the old bpython implementation. Thanks, Hos! - Addition in Draw.Text and Draw.GetStringWidth (Python Draw methods): Now script writers can select the font size: normal, small or tiny.
This commit is contained in:
@@ -40,6 +40,7 @@ struct _object; // forward declaration for PyObject !
|
||||
|
||||
void BPY_start_python(void);
|
||||
void BPY_end_python(void);
|
||||
void BPY_syspath_append_pythondir(void);
|
||||
int BPY_Err_getLinenumber(void);
|
||||
const char *BPY_Err_getFilename(void);
|
||||
void BPY_Err_Handle(struct Text *text);
|
||||
|
@@ -231,6 +231,17 @@ void init_syspath(void)
|
||||
BPY_debug(("append done\n"));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Description: This function adds the user defined folder for Python */
|
||||
/* scripts to sys.path. This is done in init_syspath, too, but */
|
||||
/* when Blender's main() runs BPY_start_python(), U.pythondir */
|
||||
/* isn't set yet, so we provide this function to be executed */
|
||||
/* after U.pythondir is defined. */
|
||||
/*****************************************************************************/
|
||||
void BPY_syspath_append_pythondir(void)
|
||||
{
|
||||
syspath_append(Py_BuildValue("s", U.pythondir));
|
||||
}
|
||||
|
||||
#define FILENAME_LENGTH 24
|
||||
typedef struct _ScriptError {
|
||||
|
@@ -623,13 +623,23 @@ static PyObject *Method_String (PyObject *self, PyObject *args)
|
||||
static PyObject *Method_GetStringWidth (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *text;
|
||||
char *font_str = NULL;
|
||||
struct BMF_Font *font;
|
||||
PyObject *width;
|
||||
|
||||
if (!PyArg_ParseTuple (args, "s", &text))
|
||||
if (!PyArg_ParseTuple(args, "s|s", &text, &font_str))
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected string argument");
|
||||
"expected one or two string arguments");
|
||||
|
||||
width = PyInt_FromLong(BMF_GetStringWidth (G.font, text));
|
||||
if (!font_str) font = (&G)->font;
|
||||
else if (!strcmp (font_str, "normal")) font = (&G)->font;
|
||||
else if (!strcmp (font_str, "small" )) font = (&G)->fonts;
|
||||
else if (!strcmp (font_str, "tiny" )) font = (&G)->fontss;
|
||||
else
|
||||
return EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"\"font\" must be: 'normal' (same as None), 'small' or 'tiny'.");
|
||||
|
||||
width = PyInt_FromLong(BMF_GetStringWidth (font, text));
|
||||
|
||||
if (!width)
|
||||
return EXPP_ReturnPyObjError (PyExc_MemoryError,
|
||||
@@ -641,12 +651,22 @@ static PyObject *Method_GetStringWidth (PyObject *self, PyObject *args)
|
||||
static PyObject *Method_Text (PyObject *self, PyObject *args)
|
||||
{
|
||||
char *text;
|
||||
char *font_str = NULL;
|
||||
struct BMF_Font *font;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", &text))
|
||||
if (!PyArg_ParseTuple(args, "s|s", &text, &font_str))
|
||||
return EXPP_ReturnPyObjError (PyExc_TypeError,
|
||||
"expected string argument");
|
||||
"expected one or two string arguments");
|
||||
|
||||
BMF_DrawString(G.font, text);
|
||||
if (!font_str) font = (&G)->font;
|
||||
else if (!strcmp (font_str, "normal")) font = (&G)->font;
|
||||
else if (!strcmp (font_str, "small" )) font = (&G)->fonts;
|
||||
else if (!strcmp (font_str, "tiny" )) font = (&G)->fontss;
|
||||
else
|
||||
return EXPP_ReturnPyObjError (PyExc_AttributeError,
|
||||
"\"font\" must be: 'normal' (same as None), 'small' or 'tiny'.");
|
||||
|
||||
BMF_DrawString(font, text);
|
||||
|
||||
return EXPP_incr_ret(Py_None);
|
||||
}
|
||||
|
Reference in New Issue
Block a user