12#define PY_SSIZE_T_CLEAN
47 ".. function:: position(fontid, x, y, z)\n"
49 " Set the position for drawing text.\n"
51 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
53 " :type fontid: int\n"
54 " :param x: X axis position to draw the text.\n"
56 " :param y: Y axis position to draw the text.\n"
58 " :param z: Z axis position to draw the text (typically 0).\n"
65 if (!PyArg_ParseTuple(args,
87 ".. function:: size(fontid, size)\n"
89 " Set the size for drawing text.\n"
91 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
93 " :type fontid: int\n"
94 " :param size: Point size of the font.\n"
95 " :type size: float\n");
101 if (!PyArg_ParseTuple(args,
119 ".. function:: aspect(fontid, aspect)\n"
121 " Set the aspect for drawing text.\n"
123 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
125 " :type fontid: int\n"
126 " :param aspect: The aspect ratio for non-uniform scaling of text.\n"
127 " :type aspect: float\n");
133 if (!PyArg_ParseTuple(args,
151 ".. function:: color(fontid, r, g, b, a)\n"
153 " Set the color for drawing text.\n"
155 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
157 " :type fontid: int\n"
158 " :param r: Red channel 0.0 - 1.0.\n"
160 " :param g: Green channel 0.0 - 1.0.\n"
162 " :param b: Blue channel 0.0 - 1.0.\n"
164 " :param a: Alpha channel 0.0 - 1.0.\n"
165 " :type a: float\n");
171 if (!PyArg_ParseTuple(args,
199 ".. function:: draw(fontid, text)\n"
201 " Draw text in the current context.\n"
203 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
205 " :type fontid: int\n"
206 " :param text: The text to draw.\n"
207 " :type text: str\n");
211 Py_ssize_t text_length;
214 if (!PyArg_ParseTuple(args,
232 py_blf_draw_buffer_doc,
233 ".. function:: draw_buffer(fontid, text)\n"
235 " Draw text into the image buffer bound via :func:`blf.bind_imbuf`.\n"
237 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
239 " :type fontid: int\n"
240 " :param text: The text to draw into the bound image buffer.\n"
241 " :type text: str\n");
245 Py_ssize_t text_length;
248 if (!PyArg_ParseTuple(args,
266 py_blf_dimensions_doc,
267 ".. function:: dimensions(fontid, text)\n"
269 " Return the width and height of the text.\n"
271 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
273 " :type fontid: int\n"
274 " :param text: The text to measure.\n"
276 " :return: The width and height of the text.\n"
277 " :rtype: tuple[float, float]\n");
285 if (!PyArg_ParseTuple(args,
297 ret = PyTuple_New(2);
305 ".. function:: clipping(fontid, xmin, ymin, xmax, ymax)\n"
307 " Set the clipping, enable/disable using :data:`CLIPPING`.\n"
309 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
311 " :type fontid: int\n"
312 " :param xmin: Left edge of the clipping rectangle.\n"
313 " :type xmin: float\n"
314 " :param ymin: Bottom edge of the clipping rectangle.\n"
315 " :type ymin: float\n"
316 " :param xmax: Right edge of the clipping rectangle.\n"
317 " :type xmax: float\n"
318 " :param ymax: Top edge of the clipping rectangle.\n"
319 " :type ymax: float\n");
322 float xmin, ymin, xmax, ymax;
325 if (!PyArg_ParseTuple(args,
348 py_blf_word_wrap_doc,
349 ".. function:: word_wrap(fontid, wrap_width)\n"
351 " Set the wrap width, enable/disable using :data:`WORD_WRAP`.\n"
353 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
355 " :type fontid: int\n"
356 " :param wrap_width: The width (in pixels) to wrap words at.\n"
357 " :type wrap_width: int\n");
363 if (!PyArg_ParseTuple(args,
381 ".. function:: disable(fontid, option)\n"
383 " Disable a font drawing option.\n"
385 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
387 " :type fontid: int\n"
388 " :param option: One of :data:`ROTATION`, :data:`CLIPPING`, "
389 ":data:`SHADOW`, :data:`MONOCHROME` or :data:`WORD_WRAP`.\n"
390 " :type option: int\n");
395 if (!PyArg_ParseTuple(args,
413 ".. function:: enable(fontid, option)\n"
415 " Enable a font drawing option.\n"
417 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
419 " :type fontid: int\n"
420 " :param option: One of :data:`ROTATION`, :data:`CLIPPING`, "
421 ":data:`SHADOW`, :data:`MONOCHROME` or :data:`WORD_WRAP`.\n"
422 " :type option: int\n");
427 if (!PyArg_ParseTuple(args,
445 ".. function:: rotation(fontid, angle)\n"
447 " Set the text rotation angle, enable/disable using :data:`ROTATION`.\n"
449 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
451 " :type fontid: int\n"
452 " :param angle: The angle for text drawing to use (in radians).\n"
453 " :type angle: float\n");
459 if (!PyArg_ParseTuple(args,
477 ".. function:: shadow(fontid, level, r, g, b, a)\n"
479 " Shadow options, enable/disable using :data:`SHADOW`.\n"
481 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
483 " :type fontid: int\n"
484 " :param level: The shadow type: 0 for none, 3 for 3x3 blur, 5 for 5x5 blur "
485 "or 6 for outline. Other values raise a :exc:`TypeError`.\n"
486 " :type level: int\n"
487 " :param r: Shadow color (red channel 0.0 - 1.0).\n"
489 " :param g: Shadow color (green channel 0.0 - 1.0).\n"
491 " :param b: Shadow color (blue channel 0.0 - 1.0).\n"
493 " :param a: Shadow color (alpha channel 0.0 - 1.0).\n"
494 " :type a: float\n");
500 if (!PyArg_ParseTuple(args,
518 if (!
ELEM(level, 0, 3, 5, 6)) {
519 PyErr_SetString(PyExc_TypeError,
"blf.shadow expected arg to be in (0, 3, 5, 6)");
530 py_blf_shadow_offset_doc,
531 ".. function:: shadow_offset(fontid, x, y)\n"
533 " Set the offset for shadow text, enable/disable using :data:`SHADOW`.\n"
535 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
537 " :type fontid: int\n"
538 " :param x: Horizontal shadow offset value in pixels.\n"
540 " :param y: Vertical shadow offset value in pixels.\n"
546 if (!PyArg_ParseTuple(args,
550 ":blf.shadow_offset",
566 ".. function:: load(filepath)\n"
568 " Load a new font.\n"
570 " :param filepath: The filepath of the font.\n"
571 " :type filepath: str | bytes\n"
572 " :return: The new font's fontid or -1 if there was an error.\n"
577 if (!PyArg_ParseTuple(args,
588 return PyLong_FromLong(font_id);
594 ".. function:: unload(filepath)\n"
596 " Unload an existing font.\n"
598 " :param filepath: The filepath of the font.\n"
599 " :type filepath: str | bytes\n");
603 if (!PyArg_ParseTuple(args,
627 PyErr_SetString(PyExc_ValueError,
628 "BLFImBufContext.__enter__: unable to enter the same context more than once");
633 if (ibuf ==
nullptr) {
638 if (buffer_state ==
nullptr) {
639 PyErr_Format(PyExc_ValueError,
"bind_imbuf: unknown fontid %d", self->
fontid);
657 PyErr_SetString(PyExc_ValueError,
658 "BLFImBufContext.__exit__: called without a matching __enter__");
678 PyObject_GC_UnTrack(self);
680 PyObject_GC_Del(self);
697# pragma clang diagnostic push
698# pragma clang diagnostic ignored "-Wcast-function-type"
700# pragma GCC diagnostic push
701# pragma GCC diagnostic ignored "-Wcast-function-type"
713# pragma clang diagnostic pop
715# pragma GCC diagnostic pop
721 BPyBLFImBufContext_Type_doc,
722 "Context manager returned by :func:`blf.bind_imbuf` that binds an image buffer\n"
723 "as the destination for text drawing.");
726 PyVarObject_HEAD_INIT(
nullptr, 0)
745 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
746 BPyBLFImBufContext_Type_doc,
779 py_blf_bind_imbuf_doc,
780 ".. function:: bind_imbuf(fontid, imbuf, *, display_name=None)\n"
782 " Context manager to draw text into an image buffer instead of the GPU's context.\n"
784 " :param fontid: The id of the typeface as returned by :func:`blf.load`, for default "
786 " :type fontid: int\n"
787 " :param imbuf: The image to draw into.\n"
788 " :type imbuf: :class:`imbuf.types.ImBuf`\n"
789 " :param display_name: Ignored (formerly a color-space transform name), "
790 "kept for backwards compatibility.\n"
791 " :type display_name: str | None\n"
793 " :return: The BLF ImBuf context manager.\n"
794 " :rtype: :class:`blf.types.BLFImBufContext`\n");
798 PyObject *py_imbuf =
nullptr;
799 const char *display_name =
nullptr;
801 static const char *_keywords[] = {
808 static _PyArg_Parser _parser = {
817 if (!_PyArg_ParseTupleAndKeywordsFast(
818 args, kwds, &_parser, &fontid, &
Py_ImBuf_Type, &py_imbuf, &display_name))
828 ret->py_imbuf = Py_NewRef(py_imbuf);
830 ret->fontid = fontid;
831 ret->buffer_state =
nullptr;
833 PyObject_GC_Track(
ret);
835 return reinterpret_cast<PyObject *
>(
ret);
842# pragma clang diagnostic push
843# pragma clang diagnostic ignored "-Wcast-function-type"
845# pragma GCC diagnostic push
846# pragma GCC diagnostic ignored "-Wcast-function-type"
852 {
"aspect",
static_cast<PyCFunction
>(
py_blf_aspect), METH_VARARGS, py_blf_aspect_doc},
853 {
"clipping",
static_cast<PyCFunction
>(
py_blf_clipping), METH_VARARGS, py_blf_clipping_doc},
854 {
"word_wrap",
static_cast<PyCFunction
>(
py_blf_word_wrap), METH_VARARGS, py_blf_word_wrap_doc},
855 {
"disable",
static_cast<PyCFunction
>(
py_blf_disable), METH_VARARGS, py_blf_disable_doc},
859 py_blf_dimensions_doc},
860 {
"draw",
static_cast<PyCFunction
>(
py_blf_draw), METH_VARARGS, py_blf_draw_doc},
864 py_blf_draw_buffer_doc},
865 {
"enable",
static_cast<PyCFunction
>(
py_blf_enable), METH_VARARGS, py_blf_enable_doc},
866 {
"position",
static_cast<PyCFunction
>(
py_blf_position), METH_VARARGS, py_blf_position_doc},
867 {
"rotation",
static_cast<PyCFunction
>(
py_blf_rotation), METH_VARARGS, py_blf_rotation_doc},
868 {
"shadow",
static_cast<PyCFunction
>(
py_blf_shadow), METH_VARARGS, py_blf_shadow_doc},
872 py_blf_shadow_offset_doc},
873 {
"size",
static_cast<PyCFunction
>(
py_blf_size), METH_VARARGS, py_blf_size_doc},
874 {
"color",
static_cast<PyCFunction
>(
py_blf_color), METH_VARARGS, py_blf_color_doc},
875 {
"load",
static_cast<PyCFunction
>(
py_blf_load), METH_VARARGS, py_blf_load_doc},
876 {
"unload",
static_cast<PyCFunction
>(
py_blf_unload), METH_VARARGS, py_blf_unload_doc},
880 METH_VARARGS | METH_KEYWORDS,
881 py_blf_bind_imbuf_doc},
883 {
nullptr,
nullptr, 0,
nullptr},
888# pragma clang diagnostic pop
890# pragma GCC diagnostic pop
897 "This module provides access to Blender's text drawing functions.");
917 "This module provides access to font drawing types.");
949 PyObject *sys_modules = PyImport_GetModuleDict();
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE btScalar angle(const btVector3 &v) const
Return the angle between this and another vector.
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
void BLF_shadow_offset(int fontid, int x, int y)
void BLF_aspect(int fontid, float x, float y, float z)
void BLF_position(int fontid, float x, float y, float z)
static PyObject * py_blf_dimensions(PyObject *, PyObject *args)
static PyObject * py_blf_draw_buffer(PyObject *, PyObject *args)
static PyObject * py_blf_draw(PyObject *, PyObject *args)
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4]=nullptr)
static int py_blf_bind_imbuf_traverse(BPyBLFImBufContext *self, visitproc visit, void *arg)
static PyMethodDef py_blf_bind_imbuf_methods[]
void BLF_wordwrap(int fontid, int wrap_width, BLFWrapMode mode=BLFWrapMode::Minimal)
void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int channel_count, const ColorSpace *colorspace)
static PyObject * py_blf_load(PyObject *, PyObject *args)
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
static PyObject * py_blf_unload(PyObject *, PyObject *args)
static PyObject * py_blf_aspect(PyObject *, PyObject *args)
PyTypeObject Py_ImBuf_Type
static PyObject * py_blf_disable(PyObject *, PyObject *args)
static PyModuleDef BLF_types_module_def
static PyObject * py_blf_word_wrap(PyObject *, PyObject *args)
void BLF_disable(int fontid, FontFlags flag)
static PyObject * py_blf_position(PyObject *, PyObject *args)
static PyObject * py_blf_rotation(PyObject *, PyObject *args)
static PyModuleDef BLF_module_def
void BLF_size(int fontid, float size)
int BLF_load(const char *filepath) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
static PyObject * py_blf_bind_imbuf_exit(BPyBLFImBufContext *self, PyObject *)
void BLF_buffer_state_pop(BLFBufferState *buffer_state)
static int py_blf_bind_imbuf_clear(BPyBLFImBufContext *self)
static PyObject * py_blf_enable(PyObject *, PyObject *args)
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
int PyC_ParseUnicodeAsBytesAndSize(PyObject *o, void *p)
static PyObject * py_blf_bind_imbuf_enter(BPyBLFImBufContext *self)
int void BLF_unload(const char *filepath) ATTR_NONNULL(1)
static PyMethodDef BLF_methods[]
static PyObject * py_blf_clipping(PyObject *, PyObject *args)
static PyObject * py_blf_size(PyObject *, PyObject *args)
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
static PyObject * py_blf_bind_imbuf(PyObject *, PyObject *args, PyObject *kwds)
BLFBufferState * BLF_buffer_state_push(int fontid)
static PyObject * py_blf_color(PyObject *, PyObject *args)
void BLF_buffer_col(int fontid, const float srgb_color[4]) ATTR_NONNULL(2)
static PyObject * py_blf_shadow(PyObject *, PyObject *args)
int PyC_Module_AddToSysModules(PyObject *sys_modules, PyObject *module)
static void py_blf_bind_imbuf_dealloc(BPyBLFImBufContext *self)
void BLF_draw_buffer(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
void BLF_buffer_state_free(BLFBufferState *buffer_state)
static PyObject * BPyInit_blf_types()
static PyObject * py_blf_shadow_offset(PyObject *, PyObject *args)
static PyTypeObject BPyBLFImBufContext_Type
void BLF_width_and_height(int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL()
void BLF_rotation(int fontid, float angle)
ImBuf * BPy_ImBuf_FromPyObject(PyObject *py_imbuf)
void BLF_enable(int fontid, FontFlags flag)
void BLF_color4fv(int fontid, const float rgba[4])
header-only compatibility defines.
#define PyTuple_SET_ITEMS(op_arg,...)
BLFBufferState * buffer_state
PyObject_HEAD PyObject * py_imbuf
const ColorSpace * colorspace
ImBufByteBuffer byte_buffer
uint8_t * byte_data_for_write()
float * float_data_for_write()