From 9357f7b606262aa42cee0fc97dd4487b74ca9a29 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 23 May 2023 12:02:10 +1000 Subject: [PATCH] PyAPI: remove deprecated blf.size() dpi argument Scripts can be updated by scaling the font size, e.g. blf.size(id, size, dpi) -> blf.size(id, size * (dpi / 72.0)) --- doc/python_api/examples/blf.py | 2 +- scripts/templates_py/operator_modal_draw.py | 2 +- source/blender/python/generic/blf_py_api.c | 9 ++------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/doc/python_api/examples/blf.py b/doc/python_api/examples/blf.py index 24ac348881f..abcad480aed 100644 --- a/doc/python_api/examples/blf.py +++ b/doc/python_api/examples/blf.py @@ -37,7 +37,7 @@ def draw_callback_px(self, context): # BLF drawing routine font_id = font_info["font_id"] blf.position(font_id, 2, 80, 0) - blf.size(font_id, 50) + blf.size(font_id, 50.0) blf.draw(font_id, "Hello World") diff --git a/scripts/templates_py/operator_modal_draw.py b/scripts/templates_py/operator_modal_draw.py index 77371a75605..46c8c1dd242 100644 --- a/scripts/templates_py/operator_modal_draw.py +++ b/scripts/templates_py/operator_modal_draw.py @@ -11,7 +11,7 @@ def draw_callback_px(self, context): # draw some text blf.position(font_id, 15, 30, 0) - blf.size(font_id, 20, 72) + blf.size(font_id, 20.0) blf.draw(font_id, "Hello Word " + str(len(self.mouse_path))) # 50% alpha, 2 pixel width line diff --git a/source/blender/python/generic/blf_py_api.c b/source/blender/python/generic/blf_py_api.c index bd86dea082b..47a2289f87c 100644 --- a/source/blender/python/generic/blf_py_api.c +++ b/source/blender/python/generic/blf_py_api.c @@ -61,18 +61,13 @@ PyDoc_STRVAR(py_blf_size_doc, " :type dpi: int\n"); static PyObject *py_blf_size(PyObject *UNUSED(self), PyObject *args) { - int fontid, dpi = -1; + int fontid; float size; - if (!PyArg_ParseTuple(args, "if|i:blf.size", &fontid, &size, &dpi)) { + if (!PyArg_ParseTuple(args, "if:blf.size", &fontid, &size)) { return NULL; } - if (dpi != -1) { - size *= (float)dpi / 72.0f; - PyErr_WarnEx(PyExc_DeprecationWarning, "'dpi' is deprecated and assumed to be always 72.", 1); - } - BLF_size(fontid, size); Py_RETURN_NONE;