diff options
author | Campbell Barton <ideasman42@gmail.com> | 2006-08-06 13:51:40 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2006-08-06 13:51:40 +0400 |
commit | aaec0005452e17ba06e727736b6f92c13550bf7a (patch) | |
tree | 0e842b57cbd5a0fa7ff316eef0307a7c9fcdf35d /source/blender/python/api2_2x/Font.c | |
parent | 80f5a232d9ebddd37afadaccc030b74dd26d93cc (diff) |
Made Font.c's pack/unpack work like Sound.c's
Diffstat (limited to 'source/blender/python/api2_2x/Font.c')
-rw-r--r-- | source/blender/python/api2_2x/Font.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/source/blender/python/api2_2x/Font.c b/source/blender/python/api2_2x/Font.c index d5381730433..142ee038bff 100644 --- a/source/blender/python/api2_2x/Font.c +++ b/source/blender/python/api2_2x/Font.c @@ -66,12 +66,15 @@ struct PyMethodDef M_Font_methods[] = { }; /*--------------- Python BPy_Font methods declarations:-------------------*/ -static PyObject *Font_pack( BPy_Font * self, PyObject * args ); +static PyObject *Font_pack( BPy_Font * self ); +static PyObject *Font_unpack( BPy_Font * self, PyObject * args ); /*--------------- Python BPy_Font methods table:--------------------------*/ static PyMethodDef BPy_Font_methods[] = { - {"pack", ( PyCFunction ) Font_pack, METH_VARARGS, - "() - pack/unpack Font"}, + {"pack", ( PyCFunction ) Font_pack, METH_NOARGS, + "() - pack this Font"}, + {"unpack", ( PyCFunction ) Font_unpack, METH_VARARGS, + "(mode) - unpack this packed font"}, {NULL, NULL, 0, NULL} }; @@ -227,7 +230,6 @@ static int Font_setName( BPy_Font * self, PyObject * value ) static int Font_setFilename( BPy_Font * self, PyObject * value ) { char *name = NULL; - int namelen = 0; /* max len is FILE_MAXDIR = 160 chars like done in DNA_image_types.h */ @@ -244,19 +246,28 @@ static int Font_setFilename( BPy_Font * self, PyObject * value ) /*--------------- BPy_Font.pack()---------------------------------*/ -static PyObject *Font_pack( BPy_Font * self, PyObject * args ) +static PyObject *Font_pack( BPy_Font * self ) { - int pack= 0; - if( !PyArg_ParseTuple( args, "i", &pack ) ) + if( !self->font->packedfile ) + self->font->packedfile = newPackedFile(self->font->name); + return EXPP_incr_ret( Py_None ); +} + +/*--------------- BPy_Font.unpack()---------------------------------*/ +static PyObject *Font_unpack( BPy_Font * self, PyObject * args ) +{ + int mode= 0; + VFont *font= self->font; + + if( !PyArg_ParseTuple( args, "i", &mode ) ) return ( EXPP_ReturnPyObjError ( PyExc_AttributeError, - "expected int argument" ) ); - if( pack && !self->font->packedfile ) - self->font->packedfile = newPackedFile(self->font->name); - else if (self->font->packedfile) - if (unpackVFont(self->font, PF_ASK) == RET_OK) - G.fileflags &= ~G_AUTOPACK; + "expected int argument from Blender.UnpackModes" ) ); + if (font->packedfile) + if (unpackVFont(font, mode) == RET_ERROR) + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "error unpacking font" ); return EXPP_incr_ret( Py_None ); } |