mirror of
https://github.com/blender/blender
synced 2026-11-22 03:45:13 +03:00
This commit bumps the `ios` branch from 5.0.0 alpha to 5.1.2 release. I merged v5.0-release first then v5.1-release. So it was a sequential merge. I'm just waiting to the approval of continuing development. The stuff that are missing (those are so close to implement): - #145484 iOS: Keyboard Input Support: https://projects.blender.org/blender/blender/pulls/145484 - #145702 iOS: Add clipboard Image: https://projects.blender.org/blender/blender/pulls/145702 - Fix QOS threading - Expose Downloads - UIScene Migration `make deps` needs to run two times. (still hacky....) OSL occurs racing conditions. Disclaimer: I used AI for searching in Documentation of Deps. So the implementation is by hand. **SACRED PINKY FINGER PROMISE** Pull Request: https://projects.blender.org/blender/blender/pulls/161073
29 lines
689 B
Python
29 lines
689 B
Python
"""
|
|
Drawing Text to an Image
|
|
++++++++++++++++++++++++
|
|
|
|
Example showing how text can be drawn into an image.
|
|
This can be done by binding an image buffer (:mod:`imbuf`) to the font's ID.
|
|
"""
|
|
|
|
import blf
|
|
import imbuf
|
|
|
|
image_size = 512, 512
|
|
font_size = 20
|
|
|
|
ibuf = imbuf.new(image_size)
|
|
|
|
font_id = blf.load("/path/to/font.ttf")
|
|
|
|
blf.color(font_id, 1.0, 1.0, 1.0, 1.0)
|
|
blf.size(font_id, font_size)
|
|
blf.position(font_id, 0, image_size[1] - font_size, 0)
|
|
|
|
blf.enable(font_id, blf.WORD_WRAP)
|
|
blf.word_wrap(font_id, image_size[0])
|
|
|
|
with blf.bind_imbuf(font_id, ibuf, display_name="sRGB"):
|
|
blf.draw_buffer(font_id, "Lots of wrapped text. " * 50)
|
|
|
|
imbuf.write(ibuf, filepath="/path/to/image.png")
|