BLF: Refactor of DPI

Correction of U.dpi to hold actual monitor DPI. Simplify font sizing by
omitting DPI as API argument, always using 72 internally.

See D15961 for more details.

Differential Revision: https://developer.blender.org/D15961

Reviewed by Campbell Barton
This commit is contained in:
2022-09-23 17:36:49 -07:00
parent 88a602bc64
commit cd1631b17d
34 changed files with 71 additions and 84 deletions

View File

@@ -48,27 +48,32 @@ static PyObject *py_blf_position(PyObject *UNUSED(self), PyObject *args)
}
PyDoc_STRVAR(py_blf_size_doc,
".. function:: size(fontid, size, dpi)\n"
".. function:: size(fontid, size, dpi=72)\n"
"\n"
" Set the size and DPI for drawing text.\n"
" Set the size for drawing text.\n"
"\n"
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
"font use 0.\n"
" :type fontid: int\n"
" :arg size: Point size of the font.\n"
" :type size: float\n"
" :arg dpi: dots per inch value to use for drawing.\n"
" :arg dpi: DEPRECATED: Defaults to 72 when omitted.\n"
" :type dpi: int\n");
static PyObject *py_blf_size(PyObject *UNUSED(self), PyObject *args)
{
int fontid, dpi;
int fontid, dpi = -1;
float size;
if (!PyArg_ParseTuple(args, "ifi:blf.size", &fontid, &size, &dpi)) {
if (!PyArg_ParseTuple(args, "if|i:blf.size", &fontid, &size, &dpi)) {
return NULL;
}
BLF_size(fontid, size, dpi);
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;
}