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))
This commit is contained in:
Campbell Barton
2023-05-23 12:02:10 +10:00
parent 7fbac7e235
commit 9357f7b606
3 changed files with 4 additions and 9 deletions

View File

@@ -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")

View File

@@ -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

View File

@@ -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;