Page MenuHome

Text3d_patch_6

Authored By
Joilnen Leite (pidhash)
Nov 13 2013, 12:58 PM
Size
14 KB
Subscribers
None

Text3d_patch_6

Index: blender/source/blender/python/api2_2x/Text3d.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Text3d.c,v
retrieving revision 1.4
diff -u -p -r1.4 Text3d.c
--- blender/source/blender/python/api2_2x/Text3d.c 19 Mar 2005 03:24:00 -0000 1.4
+++ blender/source/blender/python/api2_2x/Text3d.c 21 Mar 2005 18:33:39 -0000
@@ -30,6 +30,19 @@
*
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
+
+#include <stdio.h>
+
+#include <BLI_arithb.h>
+#include <BLI_blenlib.h>
+#include <BKE_main.h>
+#include <BKE_displist.h>
+#include <BKE_global.h>
+#include <BKE_object.h>
+#include <BKE_library.h>
+#include <BKE_curve.h>
+#include <BKE_utildefines.h>
+
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_view3d_types.h"
@@ -46,18 +59,25 @@
#include "constant.h"
#include "Types.h"
+
//no prototypes declared in header files - external linkage outside of python
extern VFont *get_builtin_font(void);
extern void freedisplist(struct ListBase *lb);
+extern VFont *get_builtin_font(void);
+extern VFont *give_vfontpointer(int);
+extern VFont *exist_vfont(char *str);
+extern VFont *load_vfont(char *name);
+
/*****************************************************************************/
/* Python API function prototypes for the Text3D module. */
/*****************************************************************************/
static PyObject *M_Text3d_New( PyObject * self, PyObject * args );
static PyObject *M_Text3d_Get( PyObject * self, PyObject * args );
+static PyObject *M_Text3d_LoadFont (PyObject * self, PyObject * args );
/*****************************************************************************/
-/* Python callback function prototypes for the Text3D module.
+/* Python callback function prototypes for the Text3D module. */
/*****************************************************************************/
static PyObject *return_ModuleConstant( char *constant_name);
static PyObject *generate_ModuleIntConstant(char *name, int value);
@@ -68,6 +88,7 @@ static PyObject *generate_ModuleIntConst
struct PyMethodDef M_Text3d_methods[] = {
{"New", ( PyCFunction ) M_Text3d_New, METH_VARARGS, NULL},
{"Get", ( PyCFunction ) M_Text3d_Get, METH_VARARGS, NULL},
+ {"LoadFont", ( PyCFunction ) M_Text3d_LoadFont, METH_VARARGS, NULL},
{NULL, NULL, 0, NULL}
};
@@ -116,6 +137,12 @@ static PyObject *Text3d_getYoffset( BPy_
static PyObject *Text3d_setYoffset( BPy_Text3d * self, PyObject * args );
static PyObject *Text3d_getAlignment( BPy_Text3d * self );
static PyObject *Text3d_setAlignment( BPy_Text3d * self, PyObject * args );
+static PyObject *Text3d_getTextOnCurve( BPy_Text3d * self );
+static PyObject *Text3d_setTextOnCurve( BPy_Text3d * self, PyObject * args );
+static PyObject *Text3d_getFont( BPy_Text3d * self );
+static PyObject *Text3d_setFont( BPy_Text3d * self, PyObject * args );
+static PyObject *Text3d_getObFamily( BPy_Text3d * self );
+static PyObject *Text3d_setObFamily( BPy_Text3d * self, PyObject * args );
/*****************************************************************************/
/* Python BPy_Text3d methods table: */
@@ -133,61 +160,74 @@ static PyMethodDef BPy_Text3d_methods[]
{"getText", ( PyCFunction ) Text3d_getText,
METH_NOARGS, "() - Gets Text3d Data"},
{"getDrawMode", ( PyCFunction ) Text3d_getDrawMode,
- METH_NOARGS, "() - Return the font drawing mode"},
+ METH_NOARGS, "() - Return the font drawing mode"},
{"setDrawMode", ( PyCFunction ) Text3d_setDrawMode,
- METH_VARARGS, "(int) - Set the font drawing mode"},
+ METH_VARARGS, "(int) - Set the font drawing mode"},
{"getUVorco", ( PyCFunction ) Text3d_getUVorco,
- METH_NOARGS, "() - Return wether UV coords are used for Texture mapping"},
+ METH_NOARGS, "() - Return wether UV coords are used for Texture mapping"},
{"setUVorco", ( PyCFunction ) Text3d_setUVorco,
- METH_VARARGS, "() - Set the font to use UV coords for Texture mapping"},
+ METH_VARARGS, "() - Set the font to use UV coords for Texture mapping"},
{"getBevelAmount", ( PyCFunction ) Text3d_getBevelAmount,
- METH_NOARGS, "() - Return bevel resolution"},
+ METH_NOARGS, "() - Return bevel resolution"},
{"setBevelAmount", ( PyCFunction ) Text3d_setBevelAmount,
- METH_VARARGS, "() - Sets bevel resolution"},
+ METH_VARARGS, "() - Sets bevel resolution"},
{"getDefaultResolution", ( PyCFunction ) Text3d_getDefaultResolution,
- METH_NOARGS, "() - Return Default text resolution"},
+ METH_NOARGS, "() - Return Default text resolution"},
{"setDefaultResolution", ( PyCFunction ) Text3d_setDefaultResolution,
- METH_VARARGS, "() - Sets Default text Resolution"},
+ METH_VARARGS, "() - Sets Default text Resolution"},
{"getWidth", ( PyCFunction ) Text3d_getWidth,
- METH_NOARGS, "() - Return curve width"},
+ METH_NOARGS, "() - Return curve width"},
{"setWidth", ( PyCFunction ) Text3d_setWidth,
- METH_VARARGS, "(int) - Sets curve width"},
+ METH_VARARGS, "(int) - Sets curve width"},
{"getExtrudeDepth", ( PyCFunction ) Text3d_getExtrudeDepth,
- METH_NOARGS, "() - Gets Text3d ExtrudeDepth"},
+ METH_NOARGS, "() - Gets Text3d ExtrudeDepth"},
{"setExtrudeDepth", ( PyCFunction ) Text3d_setExtrudeDepth,
- METH_VARARGS, "() - Sets Text3d ExtrudeDepth"},
+ METH_VARARGS, "() - Sets Text3d ExtrudeDepth"},
{"getExtrudeBevelDepth", ( PyCFunction ) Text3d_getExtrudeBevelDepth,
- METH_NOARGS, "() - Gets Text3d ExtrudeBevelDepth"},
+ METH_NOARGS, "() - Gets Text3d ExtrudeBevelDepth"},
{"setExtrudeBevelDepth", ( PyCFunction ) Text3d_setExtrudeBevelDepth,
- METH_VARARGS, "() - Sets Text3d ExtrudeBevelDepth"},
+ METH_VARARGS, "() - Sets Text3d ExtrudeBevelDepth"},
{"getShear", ( PyCFunction ) Text3d_getShear,
- METH_NOARGS, "() - Gets Text3d Shear Data"},
+ METH_NOARGS, "() - Gets Text3d Shear Data"},
{"setShear", ( PyCFunction ) Text3d_setShear,
- METH_VARARGS, "() - Sets Text3d Shear Data"},
+ METH_VARARGS, "() - Sets Text3d Shear Data"},
{"getSize", ( PyCFunction ) Text3d_getSize,
- METH_NOARGS, "() - Gets Text3d Size Data"},
+ METH_NOARGS, "() - Gets Text3d Size Data"},
{"setSize", ( PyCFunction ) Text3d_setSize,
- METH_VARARGS, "() - Sets Text3d Size Data"},
+ METH_VARARGS, "() - Sets Text3d Size Data"},
{"getLineSeparation", ( PyCFunction ) Text3d_getLineSeparation,
- METH_NOARGS, "() - Gets Text3d LineSeparation Data"},
+ METH_NOARGS, "() - Gets Text3d LineSeparation Data"},
{"setLineSeparation", ( PyCFunction ) Text3d_setLineSeparation,
- METH_VARARGS, "() - Sets Text3d LineSeparation Data"},
+ METH_VARARGS, "() - Sets Text3d LineSeparation Data"},
{"getSpacing", ( PyCFunction ) Text3d_getSpacing,
- METH_NOARGS, "() - Gets Text3d letter spacing"},
+ METH_NOARGS, "() - Gets Text3d letter spacing"},
{"setSpacing", ( PyCFunction ) Text3d_setSpacing,
- METH_VARARGS, "() - Sets Text3d letter spacing"},
+ METH_VARARGS, "() - Sets Text3d letter spacing"},
{"getXoffset", ( PyCFunction ) Text3d_getXoffset,
- METH_NOARGS, "() - Gets Text3d Xoffset Data"},
+ METH_NOARGS, "() - Gets Text3d Xoffset Data"},
{"setXoffset", ( PyCFunction ) Text3d_setXoffset,
- METH_VARARGS, "() - Sets Text3d Xoffset Data"},
+ METH_VARARGS, "() - Sets Text3d Xoffset Data"},
{"getYoffset", ( PyCFunction ) Text3d_getYoffset,
- METH_NOARGS, "() - Gets Text3d Yoffset Data"},
+ METH_NOARGS, "() - Gets Text3d Yoffset Data"},
{"setYoffset", ( PyCFunction ) Text3d_setYoffset,
- METH_VARARGS, "() - Sets Text3d Yoffset Data"},
+ METH_VARARGS, "() - Sets Text3d Yoffset Data"},
{"getAlignment", ( PyCFunction ) Text3d_getAlignment,
- METH_NOARGS, "() - Gets Text3d Alignment Data"},
+ METH_NOARGS, "() - Gets Text3d Alignment Data"},
{"setAlignment", ( PyCFunction ) Text3d_setAlignment,
- METH_VARARGS, "() - Sets Text3d Alignment Data"},
+ METH_VARARGS, "() - Sets Text3d Alignment Data"},
+ {"getTextOnCurve", ( PyCFunction ) Text3d_getTextOnCurve,
+ METH_NOARGS, "() - Gets Text3d TextOnCurve Data"},
+ {"setTextOnCurve", ( PyCFunction ) Text3d_setTextOnCurve,
+ METH_VARARGS, "() - Sets TextOnCurve Data"},
+ {"getObFamily", ( PyCFunction ) Text3d_getObFamily,
+ METH_NOARGS, "() - Gets Text3d ObFamily Data"},
+ {"setObFamily", ( PyCFunction ) Text3d_setObFamily,
+ METH_VARARGS, "() - Sets Text3d ObFamily Data"},
+ {"getFont", ( PyCFunction ) Text3d_getFont,
+ METH_NOARGS, "() - Gets font list for Text3d"},
+ {"setFont", ( PyCFunction ) Text3d_setFont,
+ METH_VARARGS, "() - Sets font for Text3d"},
+
{NULL, NULL, 0, NULL}
};
@@ -196,7 +236,7 @@ static PyMethodDef BPy_Text3d_methods[]
/*****************************************************************************/
PyTypeObject Text3d_Type = {
PyObject_HEAD_INIT( NULL )
- 0, /* ob_size */
+ 0, /* ob_size */
"Text3d", /* tp_name */
sizeof( BPy_Text3d ), /* tp_basicsize */
0, /* tp_itemsize */
@@ -248,9 +288,9 @@ PyObject *M_Text3d_New( PyObject * self,
"expected string argument or no argument" ) );
bltext3d = add_curve( OB_FONT ); /* first create the Curve Data in Blender */
- bltext3d->vfont= get_builtin_font();
+ bltext3d->vfont= (VFont*) get_builtin_font();
bltext3d->vfont->id.us++;
- bltext3d->str= MEM_mallocN(12, "str");
+ bltext3d->str= (char*) MEM_mallocN(12, "str");
strcpy(bltext3d->str, "Text");
bltext3d->pos= 4;
@@ -278,7 +318,7 @@ PyObject *M_Text3d_New( PyObject * self,
return ( PyObject * ) pytext3d;
}
-PyObject *M_Text3d_Get( PyObject * self, PyObject * args )
+static PyObject *M_Text3d_Get( PyObject * self, PyObject * args )
{
char *name = NULL;
Text3d *curv_iter;
@@ -432,7 +472,7 @@ struct Text3d *Text3d_FromPyObject( PyOb
BPy_Text3d *blen_obj;
blen_obj = ( BPy_Text3d * ) py_obj;
- return ((struct Text3d*) blen_obj->curve );
+ return ((Text3d*) blen_obj->curve );
}
static PyObject *return_ModuleConstant( char *constant_name){
@@ -465,6 +505,14 @@ static PyObject *Text3d_setName( BPy_Tex
return Curve_setName( (BPy_Curve*)self,args );
}
+static PyObject *Text3d_getText( BPy_Text3d * self )
+{
+ if ( strlen(self->curve->str) )
+ return PyString_FromString (self->curve->str);
+ else
+ return Py_None;
+}
+
static PyObject *Text3d_setText( BPy_Text3d * self, PyObject * args )
{
char *text;
@@ -481,14 +529,93 @@ static PyObject *Text3d_setText( BPy_Tex
return Py_None;
}
-static PyObject *Text3d_getText( BPy_Text3d * self )
+static PyObject *Text3d_getTextOnCurve( BPy_Text3d * self )
{
- if ( strlen(self->curve->str) )
- return PyString_FromString (self->curve->str);
- else
+ if( self->curve->textoncurve )
+ return PyString_FromString (self->textoncurve);
+ return Py_None;
+}
+
+static PyObject *Text3d_setTextOnCurve( BPy_Text3d * self, PyObject * args )
+{
+ char *curvename;
+ if( !PyArg_ParseTuple( args, "s", &curvename ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string argument" ) );
+ test_obpoin_but (curvename, &self->curve->textoncurve);
+ if(self->curve->textoncurve && self->curve->textoncurve->type!=OB_CURVE) {
+ error("Only Curve Objects");
+ self->curve->textoncurve= 0;
return Py_None;
+ }
+ if (&self->curve->textoncurve)
+ self->textoncurve= curvename;
+ else
+ *self->textoncurve= '\0';
+ return Py_None;
}
+static PyObject *Text3d_getObFamily( BPy_Text3d * self )
+{
+ if (self->curve->vfont)
+ return PyString_FromString (self->curve->family);
+ return Py_None;
+}
+
+static PyObject *Text3d_setObFamily( BPy_Text3d * self, PyObject * args )
+{
+ char *family;
+ if( !PyArg_ParseTuple( args, "s", &family ) )
+ return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
+ "expected string argument" ) );
+ BLI_strncpy (self->curve->family, family, 23);
+ return Py_None;
+}
+
+static PyObject *Text3d_getFont( BPy_Text3d * self )
+{
+ if (self)
+ return PyString_FromString (self->curve->vfont->name);
+}
+
+static PyObject *Text3d_setFont( BPy_Text3d * self, PyObject * args )
+{
+ char *fontfile= NULL;
+ VFont *vf;
+ if( !PyArg_ParseTuple( args, "s", &fontfile ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string" );
+ vf= exist_vfont(fontfile);
+ if (vf) {
+ id_us_plus((ID *)vf);
+ self->curve->vfont->id.us--;
+ self->curve->vfont= vf;
+ }
+ else {
+ load_vfont (fontfile);
+ vf= exist_vfont(fontfile);
+ if (vf) {
+ id_us_plus((ID *)vf);
+ self->curve->vfont->id.us--;
+ self->curve->vfont= vf;
+ }
+ }
+ return Py_None;
+}
+
+static PyObject *M_Text3d_LoadFont( PyObject * self, PyObject * args )
+{
+ char *fontfile;
+ if( !PyArg_ParseTuple( args, "s", &fontfile ) )
+ return EXPP_ReturnPyObjError( PyExc_TypeError,
+ "expected a string" );
+ if( exist_vfont(fontfile) )
+ return Py_None;
+ load_vfont (fontfile);
+ return Py_None;
+}
+
+
static PyObject* Text3d_getDrawMode(BPy_Text3d* self)
{
PyObject *tuple = NULL;
@@ -852,3 +979,5 @@ static PyObject *Text3d_setAlignment( BP
return EXPP_incr_ret( Py_None );
}
+
+
Index: blender/source/blender/src/buttons_editing.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/buttons_editing.c,v
retrieving revision 1.98
diff -u -p -r1.98 buttons_editing.c
--- blender/source/blender/src/buttons_editing.c 21 Mar 2005 01:34:27 -0000 1.98
+++ blender/source/blender/src/buttons_editing.c 21 Mar 2005 18:37:29 -0000
@@ -767,7 +767,7 @@ static short give_vfontnr(VFont *vfont)
return -1;
}
-static VFont *give_vfontpointer(int nr) /* nr= button */
+VFont *give_vfontpointer(int nr) /* nr= button */
{
VFont *vf;
short tel= 1;
@@ -781,7 +781,7 @@ static VFont *give_vfontpointer(int nr)
return G.main->vfont.first;
}
-static VFont *exist_vfont(char *str)
+VFont *exist_vfont(char *str)
{
VFont *vf;
@@ -824,7 +824,7 @@ static char *give_vfontbutstr(void)
return str;
}
-static void load_buts_vfont(char *name)
+void load_buts_vfont(char *name)
{
VFont *vf;
Curve *cu;
@@ -875,7 +875,6 @@ void do_fontbuts(unsigned short event)
sa= closest_bigger_area();
areawinset(sa->win);
-
activate_fileselect(FILE_SPECIAL, "SELECT FONT", str, load_buts_vfont);
break;

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
f6/05/33ae62167426a110729f17e9de1e

Event Timeline