2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2010-02-28 11:18:54 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
2019-02-18 08:08:12 +11:00
|
|
|
/** \file
|
|
|
|
* \ingroup pygen
|
2011-11-05 08:40:07 +00:00
|
|
|
*
|
|
|
|
* This file defines the 'bgl' module, used for drawing text in OpenGL.
|
2011-02-27 20:10:08 +00:00
|
|
|
*/
|
|
|
|
|
2019-10-16 15:55:47 +11:00
|
|
|
/* Future-proof, See https://docs.python.org/3/c-api/arg.html#strings-and-buffers */
|
|
|
|
#define PY_SSIZE_T_CLEAN
|
|
|
|
|
2010-12-09 17:31:42 +00:00
|
|
|
#include "blf_py_api.h"
|
2020-03-19 09:33:03 +01:00
|
|
|
#include <Python.h>
|
2010-02-28 11:18:54 +00:00
|
|
|
|
|
|
|
#include "../../blenfont/BLF_api.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
|
2015-06-18 06:11:02 +10:00
|
|
|
#include "python_utildefines.h"
|
2015-01-06 16:42:22 +11:00
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_position_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: position(fontid, x, y, z)\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" Set the position 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 x: X axis position to draw the text.\n"
|
|
|
|
" :type x: float\n"
|
|
|
|
" :arg y: Y axis position to draw the text.\n"
|
|
|
|
" :type y: float\n"
|
|
|
|
" :arg z: Z axis position to draw the text.\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :type z: float\n");
|
2010-02-28 11:18:54 +00:00
|
|
|
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_position(PyObject *UNUSED(self), PyObject *args)
|
2010-02-28 11:18:54 +00:00
|
|
|
{
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int fontid;
|
2010-02-28 11:18:54 +00:00
|
|
|
float x, y, z;
|
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "ifff:blf.position", &fontid, &x, &y, &z)) {
|
2010-02-28 11:18:54 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2010-02-28 11:18:54 +00:00
|
|
|
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
BLF_position(fontid, x, y, z);
|
2010-02-28 11:18:54 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_size_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: size(fontid, size, dpi)\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
"\n"
|
2010-02-28 11:54:48 +00:00
|
|
|
" Set the size and dpi for drawing text.\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
|
|
|
|
"font use 0.\n"
|
|
|
|
" :type fontid: int\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
" :arg size: Point size of the font.\n"
|
|
|
|
" :type size: int\n"
|
|
|
|
" :arg dpi: dots per inch value to use for drawing.\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :type dpi: int\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_size(PyObject *UNUSED(self), PyObject *args)
|
2010-02-28 11:18:54 +00:00
|
|
|
{
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int fontid, size, dpi;
|
2010-02-28 11:18:54 +00:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "iii:blf.size", &fontid, &size, &dpi)) {
|
2010-02-28 11:18:54 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2010-02-28 11:18:54 +00:00
|
|
|
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
BLF_size(fontid, size, dpi);
|
2010-02-28 11:18:54 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_aspect_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: aspect(fontid, aspect)\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
"\n"
|
|
|
|
" Set the aspect for drawing text.\n"
|
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
|
|
|
|
"font use 0.\n"
|
|
|
|
" :type fontid: int\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
" :arg aspect: The aspect ratio for text drawing to use.\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :type aspect: float\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_aspect(PyObject *UNUSED(self), PyObject *args)
|
2010-02-28 11:18:54 +00:00
|
|
|
{
|
|
|
|
float aspect;
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int fontid;
|
2010-02-28 11:18:54 +00:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "if:blf.aspect", &fontid, &aspect)) {
|
2010-02-28 11:18:54 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2010-02-28 11:18:54 +00:00
|
|
|
|
Change the BLF_aspect function to handle 3d text.
This is need to properly handle 3d text (dalai work on GE), before
the BLF_aspect only take one argument, and the result was a call to:
glScalef(aspect, aspect, 1.0)
Now the three value are store in the font (x, y and z) and also
need to be enable using BLF_enable(BLF_ASPECT).
By default all the code that don't have BLF_ASPECT enable work with
a scale of 1.0 (so nothing change to the current UI).
I also remove all the call of BLF_aspect(fontid, 1.0) found in
the editors, because is disable by default, so no need any more.
Campbell the only thing to check is the python api, right now
I modify the api to from:
BLF_aspect(fontid, aspect)
to:
BLF_aspect(fontid, aspect, aspect, 1.0)
This is to avoid break the api, but now you need add the BLF_ASPECT
option to the function py_blf_enable and in some point change
py_blf_aspect to take 3 arguments.
2010-12-09 22:27:55 +00:00
|
|
|
BLF_aspect(fontid, aspect, aspect, 1.0);
|
2010-02-28 11:18:54 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2018-06-21 13:01:24 +02:00
|
|
|
PyDoc_STRVAR(py_blf_color_doc,
|
2018-10-22 14:55:18 +02:00
|
|
|
".. function:: color(fontid, r, g, b, a)\n"
|
2018-06-21 13:01:24 +02:00
|
|
|
"\n"
|
|
|
|
" Set the color 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 r: red channel 0.0 - 1.0.\n"
|
|
|
|
" :type r: float\n"
|
|
|
|
" :arg g: green channel 0.0 - 1.0.\n"
|
|
|
|
" :type g: float\n"
|
|
|
|
" :arg b: blue channel 0.0 - 1.0.\n"
|
|
|
|
" :type b: float\n"
|
|
|
|
" :arg a: alpha channel 0.0 - 1.0.\n"
|
|
|
|
" :type a: float\n");
|
|
|
|
static PyObject *py_blf_color(PyObject *UNUSED(self), PyObject *args)
|
|
|
|
{
|
|
|
|
int fontid;
|
|
|
|
float rgba[4];
|
|
|
|
|
|
|
|
if (!PyArg_ParseTuple(
|
|
|
|
args, "iffff:blf.color", &fontid, &rgba[0], &rgba[1], &rgba[2], &rgba[3])) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
BLF_color4fv(fontid, rgba);
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2016-10-15 19:40:41 -04:00
|
|
|
#if BLF_BLUR_ENABLE
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_blur_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: blur(fontid, radius)\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
"\n"
|
|
|
|
" Set the blur radius for drawing text.\n"
|
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
|
|
|
|
"font use 0.\n"
|
|
|
|
" :type fontid: int\n"
|
2010-02-28 11:54:48 +00:00
|
|
|
" :arg radius: The radius for blurring text (in pixels).\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :type radius: int\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_blur(PyObject *UNUSED(self), PyObject *args)
|
2010-02-28 11:18:54 +00:00
|
|
|
{
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int blur, fontid;
|
2010-02-28 11:18:54 +00:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "ii:blf.blur", &fontid, &blur)) {
|
2010-02-28 11:18:54 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2010-02-28 11:18:54 +00:00
|
|
|
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
BLF_blur(fontid, blur);
|
2010-02-28 11:18:54 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
2016-10-15 19:40:41 -04:00
|
|
|
#endif
|
2010-02-28 11:18:54 +00:00
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_draw_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: draw(fontid, text)\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
"\n"
|
|
|
|
" Draw text in the current context.\n"
|
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
|
|
|
|
"font use 0.\n"
|
|
|
|
" :type fontid: int\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
" :arg text: the text to draw.\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :type text: string\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_draw(PyObject *UNUSED(self), PyObject *args)
|
2010-02-28 11:18:54 +00:00
|
|
|
{
|
2014-04-27 00:21:23 +10:00
|
|
|
const char *text;
|
2019-10-16 15:55:47 +11:00
|
|
|
Py_ssize_t text_length;
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int fontid;
|
2010-02-28 11:18:54 +00:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "is#:blf.draw", &fontid, &text, &text_length)) {
|
2010-02-28 11:18:54 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2010-02-28 11:18:54 +00:00
|
|
|
|
2020-02-20 15:38:58 +11:00
|
|
|
BLF_draw(fontid, text, (uint)text_length);
|
2010-02-28 11:18:54 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_dimensions_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: dimensions(fontid, text)\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
"\n"
|
2010-07-20 10:41:08 +00:00
|
|
|
" Return the width and height of the text.\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
|
|
|
|
"font use 0.\n"
|
|
|
|
" :type fontid: int\n"
|
2010-02-28 11:18:54 +00:00
|
|
|
" :arg text: the text to draw.\n"
|
|
|
|
" :type text: string\n"
|
|
|
|
" :return: the width and height of the text.\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :rtype: tuple of 2 floats\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_dimensions(PyObject *UNUSED(self), PyObject *args)
|
2010-02-28 11:18:54 +00:00
|
|
|
{
|
2014-04-27 00:21:23 +10:00
|
|
|
const char *text;
|
2010-02-28 11:18:54 +00:00
|
|
|
float r_width, r_height;
|
|
|
|
PyObject *ret;
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int fontid;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "is:blf.dimensions", &fontid, &text)) {
|
2010-02-28 11:18:54 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-12-02 20:33:45 +11:00
|
|
|
BLF_width_and_height(fontid, text, INT_MAX, &r_width, &r_height);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-03-16 21:39:56 +00:00
|
|
|
ret = PyTuple_New(2);
|
2015-01-06 16:42:22 +11:00
|
|
|
PyTuple_SET_ITEMS(ret, PyFloat_FromDouble(r_width), PyFloat_FromDouble(r_height));
|
2010-02-28 11:18:54 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_clipping_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: clipping(fontid, xmin, ymin, xmax, ymax)\n"
|
2010-04-04 13:05:38 +00:00
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" Set the clipping, enable/disable using CLIPPING.\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 xmin: Clip the drawing area by these bounds.\n"
|
|
|
|
" :type xmin: float\n"
|
|
|
|
" :arg ymin: Clip the drawing area by these bounds.\n"
|
|
|
|
" :type ymin: float\n"
|
|
|
|
" :arg xmax: Clip the drawing area by these bounds.\n"
|
|
|
|
" :type xmax: float\n"
|
|
|
|
" :arg ymax: Clip the drawing area by these bounds.\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :type ymax: float\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_clipping(PyObject *UNUSED(self), PyObject *args)
|
2010-04-04 13:05:38 +00:00
|
|
|
{
|
|
|
|
float xmin, ymin, xmax, ymax;
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int fontid;
|
2010-04-04 13:05:38 +00:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "iffff:blf.clipping", &fontid, &xmin, &ymin, &xmax, &ymax)) {
|
2010-04-04 13:05:38 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2010-04-04 13:05:38 +00:00
|
|
|
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
BLF_clipping(fontid, xmin, ymin, xmax, ymax);
|
2010-04-04 13:05:38 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2015-09-18 20:10:26 +10:00
|
|
|
PyDoc_STRVAR(py_blf_word_wrap_doc,
|
|
|
|
".. function:: word_wrap(fontid, wrap_width)\n"
|
|
|
|
"\n"
|
|
|
|
" Set the wrap width, enable/disable using WORD_WRAP.\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 wrap_width: The width (in pixels) to wrap words at.\n"
|
|
|
|
" :type wrap_width: int\n");
|
|
|
|
static PyObject *py_blf_word_wrap(PyObject *UNUSED(self), PyObject *args)
|
|
|
|
{
|
|
|
|
int wrap_width;
|
|
|
|
int fontid;
|
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "ii:blf.word_wrap", &fontid, &wrap_width)) {
|
2015-09-18 20:10:26 +10:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2015-09-18 20:10:26 +10:00
|
|
|
|
|
|
|
BLF_wordwrap(fontid, wrap_width);
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_disable_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: disable(fontid, option)\n"
|
2010-04-04 13:05:38 +00:00
|
|
|
"\n"
|
|
|
|
" Disable option.\n"
|
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
|
|
|
|
"font use 0.\n"
|
|
|
|
" :type fontid: int\n"
|
2010-04-04 13:05:38 +00:00
|
|
|
" :arg option: One of ROTATION, CLIPPING, SHADOW or KERNING_DEFAULT.\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :type option: int\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_disable(PyObject *UNUSED(self), PyObject *args)
|
2010-04-04 13:05:38 +00:00
|
|
|
{
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int option, fontid;
|
2010-04-04 13:05:38 +00:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "ii:blf.disable", &fontid, &option)) {
|
2010-04-04 13:05:38 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2010-04-04 13:05:38 +00:00
|
|
|
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
BLF_disable(fontid, option);
|
2010-04-04 13:05:38 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_enable_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: enable(fontid, option)\n"
|
2010-04-04 13:05:38 +00:00
|
|
|
"\n"
|
|
|
|
" Enable option.\n"
|
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
|
|
|
|
"font use 0.\n"
|
|
|
|
" :type fontid: int\n"
|
2010-04-04 13:05:38 +00:00
|
|
|
" :arg option: One of ROTATION, CLIPPING, SHADOW or KERNING_DEFAULT.\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :type option: int\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_enable(PyObject *UNUSED(self), PyObject *args)
|
2010-04-04 13:05:38 +00:00
|
|
|
{
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int option, fontid;
|
2010-04-04 13:05:38 +00:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "ii:blf.enable", &fontid, &option)) {
|
2010-04-04 13:05:38 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2010-04-04 13:05:38 +00:00
|
|
|
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
BLF_enable(fontid, option);
|
2010-04-04 13:05:38 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_rotation_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: rotation(fontid, angle)\n"
|
2010-04-04 13:05:38 +00:00
|
|
|
"\n"
|
|
|
|
" Set the text rotation angle, enable/disable using ROTATION.\n"
|
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
|
|
|
|
"font use 0.\n"
|
|
|
|
" :type fontid: int\n"
|
2010-04-04 13:05:38 +00:00
|
|
|
" :arg angle: The angle for text drawing to use.\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :type angle: float\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_rotation(PyObject *UNUSED(self), PyObject *args)
|
2010-04-04 13:05:38 +00:00
|
|
|
{
|
|
|
|
float angle;
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int fontid;
|
2010-04-04 13:05:38 +00:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "if:blf.rotation", &fontid, &angle)) {
|
2010-04-04 13:05:38 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2018-06-04 08:54:17 +02:00
|
|
|
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
BLF_rotation(fontid, angle);
|
2010-04-04 13:05:38 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_shadow_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: shadow(fontid, level, r, g, b, a)\n"
|
2010-04-04 13:05:38 +00:00
|
|
|
"\n"
|
|
|
|
" Shadow options, enable/disable using SHADOW .\n"
|
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" :arg fontid: The id of the typeface as returned by :func:`blf.load`, for default "
|
|
|
|
"font use 0.\n"
|
|
|
|
" :type fontid: int\n"
|
2010-04-04 13:05:38 +00:00
|
|
|
" :arg level: The blur level, can be 3, 5 or 0.\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" :type level: int\n"
|
|
|
|
" :arg r: Shadow color (red channel 0.0 - 1.0).\n"
|
|
|
|
" :type r: float\n"
|
|
|
|
" :arg g: Shadow color (green channel 0.0 - 1.0).\n"
|
|
|
|
" :type g: float\n"
|
|
|
|
" :arg b: Shadow color (blue channel 0.0 - 1.0).\n"
|
2010-05-17 07:33:37 +00:00
|
|
|
" :type b: float\n"
|
|
|
|
" :arg a: Shadow color (alpha channel 0.0 - 1.0).\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :type a: float\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_shadow(PyObject *UNUSED(self), PyObject *args)
|
2010-04-04 13:05:38 +00:00
|
|
|
{
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int level, fontid;
|
2016-04-22 20:02:03 +10:00
|
|
|
float rgba[4];
|
2010-04-04 13:05:38 +00:00
|
|
|
|
2016-04-22 20:02:03 +10:00
|
|
|
if (!PyArg_ParseTuple(
|
|
|
|
args, "iiffff:blf.shadow", &fontid, &level, &rgba[0], &rgba[1], &rgba[2], &rgba[3])) {
|
2010-04-04 13:05:38 +00:00
|
|
|
return NULL;
|
2016-04-22 20:02:03 +10:00
|
|
|
}
|
2010-04-04 13:05:38 +00:00
|
|
|
|
2020-11-06 12:51:49 +11:00
|
|
|
if (!ELEM(level, 0, 3, 5)) {
|
2010-04-04 13:05:38 +00:00
|
|
|
PyErr_SetString(PyExc_TypeError, "blf.shadow expected arg to be in (0, 3, 5)");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2016-04-22 20:02:03 +10:00
|
|
|
BLF_shadow(fontid, level, rgba);
|
2010-04-04 13:05:38 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_shadow_offset_doc,
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
".. function:: shadow_offset(fontid, x, y)\n"
|
2010-04-04 13:05:38 +00:00
|
|
|
"\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" Set the offset for shadow 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 x: Vertical shadow offset value in pixels.\n"
|
|
|
|
" :type x: float\n"
|
|
|
|
" :arg y: Horizontal shadow offset value in pixels.\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :type y: float\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_shadow_offset(PyObject *UNUSED(self), PyObject *args)
|
2010-04-04 13:05:38 +00:00
|
|
|
{
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
int x, y, fontid;
|
2010-04-04 13:05:38 +00:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "iii:blf.shadow_offset", &fontid, &x, &y)) {
|
2010-04-04 13:05:38 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2010-04-04 13:05:38 +00:00
|
|
|
|
BugFix:
[#20854] PROPERTIES STAMP: Rendering stamp flickers in output renders
Blenfont was not thread safe, that is why one thread can change
the font properties (size, dpi, color, etc) at the same time
that the stamp draw on the image, and then the problem.
To make blenfont thread safe I have to change two important things:
1) Every BLF_* function take one argument, the font id.
2) We have two new function to make font "thread safe":
BLF_load_unique
BLF_load_mem_unique
This two function are for case like stamp, that need and own font
that don't share the glyph cache, so can draw without problem
in a different thread.
Why the BLF_*_unique function ?
Because blenfont keep only one copy of a font and keep a list of
"glyph cache". Every glyph cache have size and dpi, so if two
different thread access the same font at the same time, they can
change value and finish with something like the stamp problem.
Why don't remove the glyph cache ?
Because if we do that, we finish with a font object for every size
and dpi, and the stamp is really a special case that happen in
the rendering process, so I really thing is better keep the
glyph cache and make this two new function to handle this
special case.
(When I say "font object" I mean have the same freetype font multiple
times just to have differents size and dpi)
As Matt point we still can have one case that two thread access
the BLF_*_unique function at the same time, but I am looking to
fix this with some class of thread lock.
For now I test and work fine, so if some one found problem, please
let me know.
Campbell I have to change the python api (python/generic/blf_api.c)
to the new syntax, so maybe you can take a look at this.
2010-04-22 10:56:45 +00:00
|
|
|
BLF_shadow_offset(fontid, x, y);
|
2010-04-04 13:05:38 +00:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
2011-05-24 16:05:51 +00:00
|
|
|
PyDoc_STRVAR(py_blf_load_doc,
|
2010-05-05 06:38:49 +00:00
|
|
|
".. function:: load(filename)\n"
|
|
|
|
"\n"
|
|
|
|
" Load a new font.\n"
|
|
|
|
"\n"
|
|
|
|
" :arg filename: the filename of the font.\n"
|
2010-05-17 07:33:37 +00:00
|
|
|
" :type filename: string\n"
|
2010-05-05 06:38:49 +00:00
|
|
|
" :return: the new font's fontid or -1 if there was an error.\n"
|
2011-05-24 16:05:51 +00:00
|
|
|
" :rtype: integer\n");
|
2010-10-13 23:25:08 +00:00
|
|
|
static PyObject *py_blf_load(PyObject *UNUSED(self), PyObject *args)
|
2010-05-05 06:38:49 +00:00
|
|
|
{
|
2014-04-27 00:21:23 +10:00
|
|
|
const char *filename;
|
2010-05-05 06:38:49 +00:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "s:blf.load", &filename)) {
|
2010-05-05 06:38:49 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2010-05-05 06:38:49 +00:00
|
|
|
|
|
|
|
return PyLong_FromLong(BLF_load(filename));
|
|
|
|
}
|
|
|
|
|
2011-09-21 16:06:47 +00:00
|
|
|
PyDoc_STRVAR(py_blf_unload_doc,
|
|
|
|
".. function:: unload(filename)\n"
|
2011-05-30 11:03:16 +00:00
|
|
|
"\n"
|
2011-09-21 16:06:47 +00:00
|
|
|
" Unload an existing font.\n"
|
2011-05-30 11:03:16 +00:00
|
|
|
"\n"
|
2011-09-21 16:06:47 +00:00
|
|
|
" :arg filename: the filename of the font.\n"
|
|
|
|
" :type filename: string\n");
|
|
|
|
static PyObject *py_blf_unload(PyObject *UNUSED(self), PyObject *args)
|
2011-05-30 11:03:16 +00:00
|
|
|
{
|
2014-04-27 00:21:23 +10:00
|
|
|
const char *filename;
|
2011-09-21 16:06:47 +00:00
|
|
|
|
2019-03-30 06:12:48 +11:00
|
|
|
if (!PyArg_ParseTuple(args, "s:blf.unload", &filename)) {
|
2011-09-21 16:06:47 +00:00
|
|
|
return NULL;
|
2019-03-30 06:12:48 +11:00
|
|
|
}
|
2011-09-21 16:06:47 +00:00
|
|
|
|
|
|
|
BLF_unload(filename);
|
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
2011-05-30 11:03:16 +00:00
|
|
|
}
|
2011-06-20 10:07:46 +00:00
|
|
|
|
2010-02-28 11:18:54 +00:00
|
|
|
/*----------------------------MODULE INIT-------------------------*/
|
2011-02-13 10:52:18 +00:00
|
|
|
static PyMethodDef BLF_methods[] = {
|
2010-02-28 11:18:54 +00:00
|
|
|
{"aspect", (PyCFunction)py_blf_aspect, METH_VARARGS, py_blf_aspect_doc},
|
2016-10-15 19:40:41 -04:00
|
|
|
#if BLF_BLUR_ENABLE
|
2010-02-28 11:18:54 +00:00
|
|
|
{"blur", (PyCFunction)py_blf_blur, METH_VARARGS, py_blf_blur_doc},
|
2016-10-15 19:40:41 -04:00
|
|
|
#endif
|
2010-04-04 13:05:38 +00:00
|
|
|
{"clipping", (PyCFunction)py_blf_clipping, METH_VARARGS, py_blf_clipping_doc},
|
2015-09-18 20:10:26 +10:00
|
|
|
{"word_wrap", (PyCFunction)py_blf_word_wrap, METH_VARARGS, py_blf_word_wrap_doc},
|
2010-04-04 13:05:38 +00:00
|
|
|
{"disable", (PyCFunction)py_blf_disable, METH_VARARGS, py_blf_disable_doc},
|
2010-02-28 11:18:54 +00:00
|
|
|
{"dimensions", (PyCFunction)py_blf_dimensions, METH_VARARGS, py_blf_dimensions_doc},
|
2010-04-04 13:05:38 +00:00
|
|
|
{"draw", (PyCFunction)py_blf_draw, METH_VARARGS, py_blf_draw_doc},
|
|
|
|
{"enable", (PyCFunction)py_blf_enable, METH_VARARGS, py_blf_enable_doc},
|
2010-12-10 00:20:32 +00:00
|
|
|
{"position", (PyCFunction)py_blf_position, METH_VARARGS, py_blf_position_doc},
|
2010-04-04 13:05:38 +00:00
|
|
|
{"rotation", (PyCFunction)py_blf_rotation, METH_VARARGS, py_blf_rotation_doc},
|
|
|
|
{"shadow", (PyCFunction)py_blf_shadow, METH_VARARGS, py_blf_shadow_doc},
|
|
|
|
{"shadow_offset", (PyCFunction)py_blf_shadow_offset, METH_VARARGS, py_blf_shadow_offset_doc},
|
|
|
|
{"size", (PyCFunction)py_blf_size, METH_VARARGS, py_blf_size_doc},
|
2018-06-21 13:01:24 +02:00
|
|
|
{"color", (PyCFunction)py_blf_color, METH_VARARGS, py_blf_color_doc},
|
2010-05-05 06:38:49 +00:00
|
|
|
{"load", (PyCFunction)py_blf_load, METH_VARARGS, py_blf_load_doc},
|
2011-09-21 16:06:47 +00:00
|
|
|
{"unload", (PyCFunction)py_blf_unload, METH_VARARGS, py_blf_unload_doc},
|
2019-02-03 14:01:45 +11:00
|
|
|
{NULL, NULL, 0, NULL},
|
2010-02-28 11:18:54 +00:00
|
|
|
};
|
|
|
|
|
2019-06-21 09:50:23 +10:00
|
|
|
PyDoc_STRVAR(BLF_doc, "This module provides access to Blender's text drawing functions.");
|
2010-02-28 11:18:54 +00:00
|
|
|
static struct PyModuleDef BLF_module_def = {
|
|
|
|
PyModuleDef_HEAD_INIT,
|
2010-02-28 14:57:26 +00:00
|
|
|
"blf", /* m_name */
|
2010-02-28 11:18:54 +00:00
|
|
|
BLF_doc, /* m_doc */
|
|
|
|
0, /* m_size */
|
|
|
|
BLF_methods, /* m_methods */
|
2011-02-13 10:52:18 +00:00
|
|
|
NULL, /* m_reload */
|
|
|
|
NULL, /* m_traverse */
|
|
|
|
NULL, /* m_clear */
|
|
|
|
NULL, /* m_free */
|
2010-02-28 11:18:54 +00:00
|
|
|
};
|
|
|
|
|
2010-10-29 22:59:39 +00:00
|
|
|
PyObject *BPyInit_blf(void)
|
2010-02-28 11:18:54 +00:00
|
|
|
{
|
|
|
|
PyObject *submodule;
|
|
|
|
|
|
|
|
submodule = PyModule_Create(&BLF_module_def);
|
|
|
|
|
2010-04-04 13:05:38 +00:00
|
|
|
PyModule_AddIntConstant(submodule, "ROTATION", BLF_ROTATION);
|
|
|
|
PyModule_AddIntConstant(submodule, "CLIPPING", BLF_CLIPPING);
|
|
|
|
PyModule_AddIntConstant(submodule, "SHADOW", BLF_SHADOW);
|
|
|
|
PyModule_AddIntConstant(submodule, "KERNING_DEFAULT", BLF_KERNING_DEFAULT);
|
2015-09-18 20:10:26 +10:00
|
|
|
PyModule_AddIntConstant(submodule, "WORD_WRAP", BLF_WORD_WRAP);
|
2018-07-31 16:57:05 +10:00
|
|
|
PyModule_AddIntConstant(submodule, "MONOCHROME", BLF_MONOCHROME);
|
2010-04-04 13:05:38 +00:00
|
|
|
|
2010-10-29 22:59:39 +00:00
|
|
|
return submodule;
|
2010-05-29 21:31:57 +00:00
|
|
|
}
|