12#define PY_SSIZE_T_CLEAN
29 ".. function:: position(fontid, x, y, z)\n"
31 " Set the position for drawing text.\n"
33 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
35 " :type fontid: int\n"
36 " :arg x: X axis position to draw the text.\n"
38 " :arg y: Y axis position to draw the text.\n"
40 " :arg z: Z axis position to draw the text.\n"
48 if (!PyArg_ParseTuple(args,
"ifff:blf.position", &fontid, &x, &y, &
z)) {
60 ".. function:: size(fontid, size)\n"
62 " Set the size for drawing text.\n"
64 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
66 " :type fontid: int\n"
67 " :arg size: Point size of the font.\n"
68 " :type size: float\n");
74 if (!PyArg_ParseTuple(args,
"if:blf.size", &fontid, &size)) {
86 ".. function:: aspect(fontid, aspect)\n"
88 " Set the aspect for drawing text.\n"
90 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
92 " :type fontid: int\n"
93 " :arg aspect: The aspect ratio for text drawing to use.\n"
94 " :type aspect: float\n");
100 if (!PyArg_ParseTuple(args,
"if:blf.aspect", &fontid, &aspect)) {
112 ".. function:: color(fontid, r, g, b, a)\n"
114 " Set the color for drawing text.\n"
116 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
118 " :type fontid: int\n"
119 " :arg r: red channel 0.0 - 1.0.\n"
121 " :arg g: green channel 0.0 - 1.0.\n"
123 " :arg b: blue channel 0.0 - 1.0.\n"
125 " :arg a: alpha channel 0.0 - 1.0.\n"
126 " :type a: float\n");
132 if (!PyArg_ParseTuple(args,
"iffff:blf.color", &fontid, &rgba[0], &rgba[1], &rgba[2], &rgba[3]))
145 ".. function:: draw(fontid, text)\n"
147 " Draw text in the current context.\n"
149 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
151 " :type fontid: int\n"
152 " :arg text: the text to draw.\n"
153 " :type text: str\n");
157 Py_ssize_t text_length;
160 if (!PyArg_ParseTuple(args,
"is#:blf.draw", &fontid, &text, &text_length)) {
171 py_blf_dimensions_doc,
172 ".. function:: dimensions(fontid, text)\n"
174 " Return the width and height of the text.\n"
176 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
178 " :type fontid: int\n"
179 " :arg text: the text to draw.\n"
181 " :return: the width and height of the text.\n"
182 " :rtype: tuple[float, float]\n");
186 float r_width, r_height;
190 if (!PyArg_ParseTuple(args,
"is:blf.dimensions", &fontid, &text)) {
196 ret = PyTuple_New(2);
204 ".. function:: clipping(fontid, xmin, ymin, xmax, ymax)\n"
206 " Set the clipping, enable/disable using CLIPPING.\n"
208 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
210 " :type fontid: int\n"
211 " :arg xmin: Clip the drawing area by these bounds.\n"
212 " :type xmin: float\n"
213 " :arg ymin: Clip the drawing area by these bounds.\n"
214 " :type ymin: float\n"
215 " :arg xmax: Clip the drawing area by these bounds.\n"
216 " :type xmax: float\n"
217 " :arg ymax: Clip the drawing area by these bounds.\n"
218 " :type ymax: float\n");
221 float xmin, ymin, xmax, ymax;
224 if (!PyArg_ParseTuple(args,
"iffff:blf.clipping", &fontid, &xmin, &ymin, &xmax, &ymax)) {
235 py_blf_word_wrap_doc,
236 ".. function:: word_wrap(fontid, wrap_width)\n"
238 " Set the wrap width, enable/disable using WORD_WRAP.\n"
240 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
242 " :type fontid: int\n"
243 " :arg wrap_width: The width (in pixels) to wrap words at.\n"
244 " :type wrap_width: int\n");
250 if (!PyArg_ParseTuple(args,
"ii:blf.word_wrap", &fontid, &wrap_width)) {
262 ".. function:: disable(fontid, option)\n"
266 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
268 " :type fontid: int\n"
269 " :arg option: One of ROTATION, CLIPPING, SHADOW or KERNING_DEFAULT.\n"
270 " :type option: int\n");
275 if (!PyArg_ParseTuple(args,
"ii:blf.disable", &fontid, &option)) {
287 ".. function:: enable(fontid, option)\n"
291 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
293 " :type fontid: int\n"
294 " :arg option: One of ROTATION, CLIPPING, SHADOW or KERNING_DEFAULT.\n"
295 " :type option: int\n");
300 if (!PyArg_ParseTuple(args,
"ii:blf.enable", &fontid, &option)) {
312 ".. function:: rotation(fontid, angle)\n"
314 " Set the text rotation angle, enable/disable using ROTATION.\n"
316 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
318 " :type fontid: int\n"
319 " :arg angle: The angle for text drawing to use.\n"
320 " :type angle: float\n");
326 if (!PyArg_ParseTuple(args,
"if:blf.rotation", &fontid, &angle)) {
338 ".. function:: shadow(fontid, level, r, g, b, a)\n"
340 " Shadow options, enable/disable using SHADOW .\n"
342 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
344 " :type fontid: int\n"
345 " :arg level: The blur level (0, 3, 5) or outline (6).\n"
346 " :type level: int\n"
347 " :arg r: Shadow color (red channel 0.0 - 1.0).\n"
349 " :arg g: Shadow color (green channel 0.0 - 1.0).\n"
351 " :arg b: Shadow color (blue channel 0.0 - 1.0).\n"
353 " :arg a: Shadow color (alpha channel 0.0 - 1.0).\n"
354 " :type a: float\n");
360 if (!PyArg_ParseTuple(
361 args,
"iiffff:blf.shadow", &fontid, &level, &rgba[0], &rgba[1], &rgba[2], &rgba[3]))
366 if (!
ELEM(level, 0, 3, 5, 6)) {
367 PyErr_SetString(PyExc_TypeError,
"blf.shadow expected arg to be in (0, 3, 5, 6)");
378 py_blf_shadow_offset_doc,
379 ".. function:: shadow_offset(fontid, x, y)\n"
381 " Set the offset for shadow text.\n"
383 " :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
385 " :type fontid: int\n"
386 " :arg x: Vertical shadow offset value in pixels.\n"
388 " :arg y: Horizontal shadow offset value in pixels.\n"
389 " :type y: float\n");
394 if (!PyArg_ParseTuple(args,
"iii:blf.shadow_offset", &fontid, &x, &y)) {
406 ".. function:: load(filepath)\n"
408 " Load a new font.\n"
410 " :arg filepath: the filepath of the font.\n"
411 " :type filepath: str | bytes\n"
412 " :return: the new font's fontid or -1 if there was an error.\n"
417 if (!PyArg_ParseTuple(args,
428 return PyLong_FromLong(font_id);
434 ".. function:: unload(filepath)\n"
436 " Unload an existing font.\n"
438 " :arg filepath: the filepath of the font.\n"
439 " :type filepath: str | bytes\n");
443 if (!PyArg_ParseTuple(args,
460 {
"aspect", (PyCFunction)
py_blf_aspect, METH_VARARGS, py_blf_aspect_doc},
461 {
"clipping", (PyCFunction)
py_blf_clipping, METH_VARARGS, py_blf_clipping_doc},
462 {
"word_wrap", (PyCFunction)
py_blf_word_wrap, METH_VARARGS, py_blf_word_wrap_doc},
463 {
"disable", (PyCFunction)
py_blf_disable, METH_VARARGS, py_blf_disable_doc},
464 {
"dimensions", (PyCFunction)
py_blf_dimensions, METH_VARARGS, py_blf_dimensions_doc},
465 {
"draw", (PyCFunction)
py_blf_draw, METH_VARARGS, py_blf_draw_doc},
466 {
"enable", (PyCFunction)
py_blf_enable, METH_VARARGS, py_blf_enable_doc},
467 {
"position", (PyCFunction)
py_blf_position, METH_VARARGS, py_blf_position_doc},
468 {
"rotation", (PyCFunction)
py_blf_rotation, METH_VARARGS, py_blf_rotation_doc},
469 {
"shadow", (PyCFunction)
py_blf_shadow, METH_VARARGS, py_blf_shadow_doc},
471 {
"size", (PyCFunction)
py_blf_size, METH_VARARGS, py_blf_size_doc},
472 {
"color", (PyCFunction)
py_blf_color, METH_VARARGS, py_blf_color_doc},
473 {
"load", (PyCFunction)
py_blf_load, METH_VARARGS, py_blf_load_doc},
474 {
"unload", (PyCFunction)
py_blf_unload, METH_VARARGS, py_blf_unload_doc},
475 {
nullptr,
nullptr, 0,
nullptr},
481 "This module provides access to Blender's text drawing functions.");
483 PyModuleDef_HEAD_INIT,
500 PyModule_AddIntConstant(submodule,
"ROTATION",
BLF_ROTATION);
501 PyModule_AddIntConstant(submodule,
"CLIPPING",
BLF_CLIPPING);
502 PyModule_AddIntConstant(submodule,
"SHADOW",
BLF_SHADOW);
503 PyModule_AddIntConstant(submodule,
"WORD_WRAP",
BLF_WORD_WRAP);
void BLF_size(int fontid, float size)
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4]=nullptr)
void BLF_aspect(int fontid, float x, float y, float z)
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
void BLF_width_and_height(int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL()
void BLF_color4fv(int fontid, const float rgba[4])
void BLF_shadow_offset(int fontid, int x, int y)
void BLF_disable(int fontid, int option)
void BLF_rotation(int fontid, float angle)
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
int BLF_load(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLF_enable(int fontid, int option)
int void BLF_unload(const char *filepath) ATTR_NONNULL(1)
void BLF_wordwrap(int fontid, int wrap_width)
void BLF_position(int fontid, float x, float y, float z)
static double angle(const Eigen::Vector3d &v1, const Eigen::Vector3d &v2)
static PyObject * py_blf_word_wrap(PyObject *, PyObject *args)
static PyObject * py_blf_enable(PyObject *, PyObject *args)
static PyObject * py_blf_aspect(PyObject *, PyObject *args)
static PyModuleDef BLF_module_def
static PyObject * py_blf_color(PyObject *, PyObject *args)
static PyObject * py_blf_shadow_offset(PyObject *, PyObject *args)
static PyMethodDef BLF_methods[]
static PyObject * py_blf_unload(PyObject *, PyObject *args)
static PyObject * py_blf_load(PyObject *, PyObject *args)
static PyObject * py_blf_shadow(PyObject *, PyObject *args)
static PyObject * py_blf_dimensions(PyObject *, PyObject *args)
static PyObject * py_blf_clipping(PyObject *, PyObject *args)
static PyObject * py_blf_rotation(PyObject *, PyObject *args)
static PyObject * py_blf_disable(PyObject *, PyObject *args)
static PyObject * py_blf_draw(PyObject *, PyObject *args)
static PyObject * py_blf_size(PyObject *, 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")
static PyObject * py_blf_position(PyObject *, PyObject *args)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
int PyC_ParseUnicodeAsBytesAndSize(PyObject *o, void *p)
#define PyTuple_SET_ITEMS(op_arg,...)