Add support for using BLF to draw into an ImBuf image buffer.
Once the imbuf context has been set, draw calls for that font_id will draw into the image.
This works by binding an imbuf to BLF which is then used as the target when drawing.
```
with blf.bind_imbuf(font_id, imbuf):
blf.draw_buffer(font_id, text)
```
See the example in the Python API documentation for reference.
The following BLF API's have been added to support a Python context manager.
- `BLF_buffer_state_push`.
- `BLF_buffer_state_pop`
- `BLF_buffer_state_free`
Ref !135772
21 lines
350 B
C++
21 lines
350 B
C++
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
/** \file
|
|
* \ingroup pygen
|
|
*/
|
|
|
|
#include <Python.h>
|
|
|
|
struct ImBuf;
|
|
|
|
PyObject *BPyInit_imbuf();
|
|
|
|
extern PyTypeObject Py_ImBuf_Type;
|
|
|
|
/** Return the #ImBuf or null with an error set. */
|
|
ImBuf *BPy_ImBuf_FromPyObject(PyObject *py_imbuf);
|