24 #define PY_SSIZE_T_CLEAN
29 #include "../../blenfont/BLF_api.h"
36 ".. function:: position(fontid, x, y, z)\n"
38 " Set the position for drawing text.\n"
40 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
42 " :type fontid: int\n"
43 " :arg x: X axis position to draw the text.\n"
45 " :arg y: Y axis position to draw the text.\n"
47 " :arg z: Z axis position to draw the text.\n"
55 if (!PyArg_ParseTuple(args,
"ifff:blf.position", &fontid, &
x, &
y, &
z)) {
65 ".. function:: size(fontid, size, dpi)\n"
67 " Set the size and dpi for drawing text.\n"
69 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
71 " :type fontid: int\n"
72 " :arg size: Point size of the font.\n"
74 " :arg dpi: dots per inch value to use for drawing.\n"
78 int fontid,
size, dpi;
80 if (!PyArg_ParseTuple(args,
"iii:blf.size", &fontid, &
size, &dpi)) {
90 ".. function:: aspect(fontid, aspect)\n"
92 " Set the aspect for drawing text.\n"
94 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
96 " :type fontid: int\n"
97 " :arg aspect: The aspect ratio for text drawing to use.\n"
98 " :type aspect: float\n");
104 if (!PyArg_ParseTuple(args,
"if:blf.aspect", &fontid, &aspect)) {
114 ".. function:: color(fontid, r, g, b, a)\n"
116 " Set the color for drawing text.\n"
118 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
120 " :type fontid: int\n"
121 " :arg r: red channel 0.0 - 1.0.\n"
123 " :arg g: green channel 0.0 - 1.0.\n"
125 " :arg b: blue channel 0.0 - 1.0.\n"
127 " :arg a: alpha channel 0.0 - 1.0.\n"
128 " :type a: float\n");
134 if (!PyArg_ParseTuple(
135 args,
"iffff:blf.color", &fontid, &rgba[0], &rgba[1], &rgba[2], &rgba[3])) {
146 ".. function:: blur(fontid, radius)\n"
148 " Set the blur radius for drawing text.\n"
150 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
152 " :type fontid: int\n"
153 " :arg radius: The radius for blurring text (in pixels).\n"
154 " :type radius: int\n");
155 static PyObject *py_blf_blur(PyObject *
UNUSED(
self), PyObject *args)
159 if (!PyArg_ParseTuple(args,
"ii:blf.blur", &fontid, &blur)) {
163 BLF_blur(fontid, blur);
170 ".. function:: draw(fontid, text)\n"
172 " Draw text in the current context.\n"
174 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
176 " :type fontid: int\n"
177 " :arg text: the text to draw.\n"
178 " :type text: string\n");
182 Py_ssize_t text_length;
185 if (!PyArg_ParseTuple(args,
"is#:blf.draw", &fontid, &text, &text_length)) {
195 ".. function:: dimensions(fontid, text)\n"
197 " Return the width and height of the text.\n"
199 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
201 " :type fontid: int\n"
202 " :arg text: the text to draw.\n"
203 " :type text: string\n"
204 " :return: the width and height of the text.\n"
205 " :rtype: tuple of 2 floats\n");
209 float r_width, r_height;
213 if (!PyArg_ParseTuple(args,
"is:blf.dimensions", &fontid, &text)) {
219 ret = PyTuple_New(2);
225 ".. function:: clipping(fontid, xmin, ymin, xmax, ymax)\n"
227 " Set the clipping, enable/disable using CLIPPING.\n"
229 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
231 " :type fontid: int\n"
232 " :arg xmin: Clip the drawing area by these bounds.\n"
233 " :type xmin: float\n"
234 " :arg ymin: Clip the drawing area by these bounds.\n"
235 " :type ymin: float\n"
236 " :arg xmax: Clip the drawing area by these bounds.\n"
237 " :type xmax: float\n"
238 " :arg ymax: Clip the drawing area by these bounds.\n"
239 " :type ymax: float\n");
242 float xmin, ymin, xmax, ymax;
245 if (!PyArg_ParseTuple(args,
"iffff:blf.clipping", &fontid, &xmin, &ymin, &xmax, &ymax)) {
255 ".. function:: word_wrap(fontid, wrap_width)\n"
257 " Set the wrap width, enable/disable using WORD_WRAP.\n"
259 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
261 " :type fontid: int\n"
262 " :arg wrap_width: The width (in pixels) to wrap words at.\n"
263 " :type wrap_width: int\n");
269 if (!PyArg_ParseTuple(args,
"ii:blf.word_wrap", &fontid, &
wrap_width)) {
279 ".. function:: disable(fontid, option)\n"
283 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
285 " :type fontid: int\n"
286 " :arg option: One of ROTATION, CLIPPING, SHADOW or KERNING_DEFAULT.\n"
287 " :type option: int\n");
292 if (!PyArg_ParseTuple(args,
"ii:blf.disable", &fontid, &option)) {
302 ".. function:: enable(fontid, option)\n"
306 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
308 " :type fontid: int\n"
309 " :arg option: One of ROTATION, CLIPPING, SHADOW or KERNING_DEFAULT.\n"
310 " :type option: int\n");
315 if (!PyArg_ParseTuple(args,
"ii:blf.enable", &fontid, &option)) {
325 ".. function:: rotation(fontid, angle)\n"
327 " Set the text rotation angle, enable/disable using ROTATION.\n"
329 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
331 " :type fontid: int\n"
332 " :arg angle: The angle for text drawing to use.\n"
333 " :type angle: float\n");
339 if (!PyArg_ParseTuple(args,
"if:blf.rotation", &fontid, &
angle)) {
349 ".. function:: shadow(fontid, level, r, g, b, a)\n"
351 " Shadow options, enable/disable using SHADOW .\n"
353 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
355 " :type fontid: int\n"
356 " :arg level: The blur level, can be 3, 5 or 0.\n"
357 " :type level: int\n"
358 " :arg r: Shadow color (red channel 0.0 - 1.0).\n"
360 " :arg g: Shadow color (green channel 0.0 - 1.0).\n"
362 " :arg b: Shadow color (blue channel 0.0 - 1.0).\n"
364 " :arg a: Shadow color (alpha channel 0.0 - 1.0).\n"
365 " :type a: float\n");
371 if (!PyArg_ParseTuple(
372 args,
"iiffff:blf.shadow", &fontid, &level, &rgba[0], &rgba[1], &rgba[2], &rgba[3])) {
376 if (!
ELEM(level, 0, 3, 5)) {
377 PyErr_SetString(PyExc_TypeError,
"blf.shadow expected arg to be in (0, 3, 5)");
387 ".. function:: shadow_offset(fontid, x, y)\n"
389 " Set the offset for shadow text.\n"
391 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
393 " :type fontid: int\n"
394 " :arg x: Vertical shadow offset value in pixels.\n"
396 " :arg y: Horizontal shadow offset value in pixels.\n"
397 " :type y: float\n");
402 if (!PyArg_ParseTuple(args,
"iii:blf.shadow_offset", &fontid, &
x, &
y)) {
412 ".. function:: load(filename)\n"
414 " Load a new font.\n"
416 " :arg filename: the filename of the font.\n"
417 " :type filename: string\n"
418 " :return: the new font's fontid or -1 if there was an error.\n"
419 " :rtype: integer\n");
422 const char *filename;
424 if (!PyArg_ParseTuple(args,
"s:blf.load", &filename)) {
428 return PyLong_FromLong(
BLF_load(filename));
432 ".. function:: unload(filename)\n"
434 " Unload an existing font.\n"
436 " :arg filename: the filename of the font.\n"
437 " :type filename: string\n");
440 const char *filename;
442 if (!PyArg_ParseTuple(args,
"s:blf.unload", &filename)) {
453 {
"aspect", (PyCFunction)
py_blf_aspect, METH_VARARGS, py_blf_aspect_doc},
455 {
"blur", (PyCFunction)py_blf_blur, METH_VARARGS, py_blf_blur_doc},
457 {
"clipping", (PyCFunction)
py_blf_clipping, METH_VARARGS, py_blf_clipping_doc},
458 {
"word_wrap", (PyCFunction)
py_blf_word_wrap, METH_VARARGS, py_blf_word_wrap_doc},
459 {
"disable", (PyCFunction)
py_blf_disable, METH_VARARGS, py_blf_disable_doc},
460 {
"dimensions", (PyCFunction)
py_blf_dimensions, METH_VARARGS, py_blf_dimensions_doc},
461 {
"draw", (PyCFunction)
py_blf_draw, METH_VARARGS, py_blf_draw_doc},
462 {
"enable", (PyCFunction)
py_blf_enable, METH_VARARGS, py_blf_enable_doc},
463 {
"position", (PyCFunction)
py_blf_position, METH_VARARGS, py_blf_position_doc},
464 {
"rotation", (PyCFunction)
py_blf_rotation, METH_VARARGS, py_blf_rotation_doc},
465 {
"shadow", (PyCFunction)
py_blf_shadow, METH_VARARGS, py_blf_shadow_doc},
467 {
"size", (PyCFunction)
py_blf_size, METH_VARARGS, py_blf_size_doc},
468 {
"color", (PyCFunction)
py_blf_color, METH_VARARGS, py_blf_color_doc},
469 {
"load", (PyCFunction)
py_blf_load, METH_VARARGS, py_blf_load_doc},
470 {
"unload", (PyCFunction)
py_blf_unload, METH_VARARGS, py_blf_unload_doc},
474 PyDoc_STRVAR(BLF_doc,
"This module provides access to Blender's text drawing functions.");
476 PyModuleDef_HEAD_INIT,
493 PyModule_AddIntConstant(submodule,
"ROTATION",
BLF_ROTATION);
494 PyModule_AddIntConstant(submodule,
"CLIPPING",
BLF_CLIPPING);
495 PyModule_AddIntConstant(submodule,
"SHADOW",
BLF_SHADOW);
497 PyModule_AddIntConstant(submodule,
"WORD_WRAP",
BLF_WORD_WRAP);
void BLF_aspect(int fontid, float x, float y, float z)
#define BLF_KERNING_DEFAULT
void BLF_color4fv(int fontid, const float rgba[4])
void BLF_shadow_offset(int fontid, int x, int y)
void BLF_width_and_height(int fontid, const char *str, size_t len, float *r_width, float *r_height) ATTR_NONNULL()
void BLF_shadow(int fontid, int level, const float rgba[4]) ATTR_NONNULL(3)
void BLF_draw(int fontid, const char *str, size_t len) ATTR_NONNULL(2)
void BLF_disable(int fontid, int option)
void BLF_rotation(int fontid, float angle)
void BLF_unload(const char *name) ATTR_NONNULL()
void BLF_size(int fontid, int size, int dpi)
void BLF_enable(int fontid, int option)
int BLF_load(const char *name) ATTR_NONNULL()
void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax)
void BLF_wordwrap(int fontid, int wrap_width)
void BLF_position(int fontid, float x, float y, float z)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
static PyObject * py_blf_word_wrap(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_blf_load(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_blf_dimensions(PyObject *UNUSED(self), PyObject *args)
static struct PyModuleDef BLF_module_def
static PyObject * py_blf_draw(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_blf_clipping(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_blf_aspect(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_blf_position(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_blf_shadow_offset(PyObject *UNUSED(self), PyObject *args)
static PyMethodDef BLF_methods[]
static PyObject * py_blf_enable(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_blf_rotation(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_blf_unload(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_blf_shadow(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_blf_disable(PyObject *UNUSED(self), PyObject *args)
PyDoc_STRVAR(py_blf_position_doc, ".. function:: position(fontid, x, y, z)\n" "\n" " Set the position for drawing text.\n" "\n" " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default " "font use 0.\n" " :type fontid: int\n" " :arg x: X axis position to draw the text.\n" " :type x: float\n" " :arg y: Y axis position to draw the text.\n" " :type y: float\n" " :arg z: Z axis position to draw the text.\n" " :type z: float\n")
PyObject * BPyInit_blf(void)
static PyObject * py_blf_size(PyObject *UNUSED(self), PyObject *args)
static PyObject * py_blf_color(PyObject *UNUSED(self), PyObject *args)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
#define PyTuple_SET_ITEMS(op_arg,...)
int wrap_width(const struct SpaceText *st, struct ARegion *region)