2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2009-01-29 05:19:27 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* 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,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-01-29 05:19:27 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2009 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:42:42 +00:00
|
|
|
/** \file blender/blenfont/BLF_api.h
|
|
|
|
* \ingroup blf
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#ifndef __BLF_API_H__
|
|
|
|
#define __BLF_API_H__
|
2009-01-29 05:19:27 +00:00
|
|
|
|
2.5: Text Editor back.
There was very little structure in this code, using many globals
and duplicated code. Now it should be better structured. Most
things should work, the main parts that are not back yet are the
python plugins and markers. Notes:
* Blenfont is used for drawing the text, nicely anti-aliased.
* A monospace truetype font was added, since that is needed for
the text editor. It's Bitstream Vera Sans Mono. This is the
default gnome terminal font, but it doesn't fit entirely well
with the other font I think, can be changed easily of course.
* Clipboard copy/cut/paste now always uses the system clipboard,
the code for the own cut buffer was removed.
* The interface buttons should support copy/cut/paste again now
as well.
* WM_clipboard_text_get/WM_clipboard_text_set were added to the
windowmanager code.
* Find panel is now a kind of second header, instead of a panel.
This needs especially a way to start editing the text field
immediately on open still.
* Operators are independent of the actual space when possible,
was a bit of puzzling but got it solved nice with notifiers,
and some lazy init for syntax highlight in the drawing code.
* RNA was created for the text editor space and used for buttons.
* Operators:
* New, Open, Reload, Save, Save As, Make Internal
* Run Script, Refresh Pyconstraints
* Copy, Cut, Paste
* Convert Whitespace, Uncomment, Comment, Indent, Unindent
* Line Break, Insert
* Next Marker, Previous Marker, Clear All Markers, Mark All
* Select Line, Select All
* Jump, Move, Move Select, Delete, Toggle Overwrite
* Scroll, Scroll Bar, Set Cursor, Line Number
* Find and Replace, Find, Replace, Find Set Selected,
Replace Set Selected
* To 3D Object
* Resolve Conflict
2009-02-28 23:33:35 +00:00
|
|
|
struct rctf;
|
|
|
|
|
2009-05-05 23:10:32 +00:00
|
|
|
int BLF_init(int points, int dpi);
|
2009-02-17 16:56:29 +00:00
|
|
|
void BLF_exit(void);
|
|
|
|
|
2010-11-26 22:12:46 +00:00
|
|
|
void BLF_cache_clear(void);
|
|
|
|
|
2010-11-11 07:51:12 +00:00
|
|
|
int BLF_load(const char *name);
|
|
|
|
int BLF_load_mem(const char *name, unsigned char *mem, int mem_size);
|
2009-02-17 16:56:29 +00:00
|
|
|
|
2010-11-11 07:51:12 +00:00
|
|
|
int BLF_load_unique(const char *name);
|
|
|
|
int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size);
|
2009-05-08 21:24:58 +00:00
|
|
|
|
2011-09-21 15:14:47 +00:00
|
|
|
void BLF_unload(const char *name);
|
|
|
|
|
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
|
|
|
/* Attach a file with metrics information from memory. */
|
|
|
|
void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size);
|
New Bitmap draw mode for Freetype2 fonts.
The library can load any font supported by the Freetype2 library or
used the internal bitmap font.
With both types it's possible draw the text as texture or bitmap,
and using texture it's possible rotate, scale and clipping text.
Still have things to fix/add, but I think it's ready to move-on
and start droping the old api, most of (if it's not all) the
editors/interface/text.c will be remove, but some things still
has to be define, like:
* Where is store the fonts ? (default font, panel font, filesel font, etc)
I mean, every space have own fonts ? or we keep it on the context ?
It's not a really problem from the blenfont side, because every font
have reference number, so it's load only the first time.
* What we do about gettext ?
Keep the old system that call gettext inside the blenfont or replace
it for _() in the Blender source ?
Also things like pupmen has to be take care, if we want translate the menu.
Ok, time to sleep, back tomorrow to start moving the things :)
2009-04-07 08:42:28 +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
|
|
|
void BLF_aspect(int fontid, float x, float y, float z);
|
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
|
|
|
void BLF_position(int fontid, float x, float y, float z);
|
|
|
|
void BLF_size(int fontid, int size, int dpi);
|
2009-05-05 23:10:32 +00:00
|
|
|
|
2010-12-09 04:36:58 +00:00
|
|
|
/* Set a 4x4 matrix to be multiplied before draw the text.
|
|
|
|
* Remember that you need call BLF_enable(BLF_MATRIX)
|
|
|
|
* to enable this.
|
|
|
|
*
|
|
|
|
* The order of the matrix is like GL:
|
2012-03-09 18:28:30 +00:00
|
|
|
*
|
|
|
|
* | m[0] m[4] m[8] m[12] |
|
|
|
|
* | m[1] m[5] m[9] m[13] |
|
|
|
|
* | m[2] m[6] m[10] m[14] |
|
|
|
|
* | m[3] m[7] m[11] m[15] |
|
|
|
|
*
|
2010-12-09 04:36:58 +00:00
|
|
|
*/
|
2011-09-18 10:34:13 +00:00
|
|
|
void BLF_matrix(int fontid, const double m[16]);
|
2010-12-09 04:36:58 +00:00
|
|
|
|
2009-05-05 23:10:32 +00:00
|
|
|
/* Draw the string using the default font, size and dpi. */
|
2010-11-11 06:35:45 +00:00
|
|
|
void BLF_draw_default(float x, float y, float z, const char *str, size_t len);
|
|
|
|
void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len);
|
2009-05-05 23:10:32 +00:00
|
|
|
|
|
|
|
/* Draw the string using the current font. */
|
2010-11-11 06:35:45 +00:00
|
|
|
void BLF_draw(int fontid, const char *str, size_t len);
|
|
|
|
void BLF_draw_ascii(int fontid, const char *str, size_t len);
|
2009-02-17 16:56:29 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* This function return the bounding box of the string
|
New Bitmap draw mode for Freetype2 fonts.
The library can load any font supported by the Freetype2 library or
used the internal bitmap font.
With both types it's possible draw the text as texture or bitmap,
and using texture it's possible rotate, scale and clipping text.
Still have things to fix/add, but I think it's ready to move-on
and start droping the old api, most of (if it's not all) the
editors/interface/text.c will be remove, but some things still
has to be define, like:
* Where is store the fonts ? (default font, panel font, filesel font, etc)
I mean, every space have own fonts ? or we keep it on the context ?
It's not a really problem from the blenfont side, because every font
have reference number, so it's load only the first time.
* What we do about gettext ?
Keep the old system that call gettext inside the blenfont or replace
it for _() in the Blender source ?
Also things like pupmen has to be take care, if we want translate the menu.
Ok, time to sleep, back tomorrow to start moving the things :)
2009-04-07 08:42:28 +00:00
|
|
|
* and are not multiplied by the aspect.
|
|
|
|
*/
|
2010-11-11 07:51:12 +00:00
|
|
|
void BLF_boundbox(int fontid, const char *str, struct rctf *box);
|
New Bitmap draw mode for Freetype2 fonts.
The library can load any font supported by the Freetype2 library or
used the internal bitmap font.
With both types it's possible draw the text as texture or bitmap,
and using texture it's possible rotate, scale and clipping text.
Still have things to fix/add, but I think it's ready to move-on
and start droping the old api, most of (if it's not all) the
editors/interface/text.c will be remove, but some things still
has to be define, like:
* Where is store the fonts ? (default font, panel font, filesel font, etc)
I mean, every space have own fonts ? or we keep it on the context ?
It's not a really problem from the blenfont side, because every font
have reference number, so it's load only the first time.
* What we do about gettext ?
Keep the old system that call gettext inside the blenfont or replace
it for _() in the Blender source ?
Also things like pupmen has to be take care, if we want translate the menu.
Ok, time to sleep, back tomorrow to start moving the things :)
2009-04-07 08:42:28 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* The next both function return the width and height
|
New Bitmap draw mode for Freetype2 fonts.
The library can load any font supported by the Freetype2 library or
used the internal bitmap font.
With both types it's possible draw the text as texture or bitmap,
and using texture it's possible rotate, scale and clipping text.
Still have things to fix/add, but I think it's ready to move-on
and start droping the old api, most of (if it's not all) the
editors/interface/text.c will be remove, but some things still
has to be define, like:
* Where is store the fonts ? (default font, panel font, filesel font, etc)
I mean, every space have own fonts ? or we keep it on the context ?
It's not a really problem from the blenfont side, because every font
have reference number, so it's load only the first time.
* What we do about gettext ?
Keep the old system that call gettext inside the blenfont or replace
it for _() in the Blender source ?
Also things like pupmen has to be take care, if we want translate the menu.
Ok, time to sleep, back tomorrow to start moving the things :)
2009-04-07 08:42:28 +00:00
|
|
|
* of the string, using the current font and both value
|
|
|
|
* are multiplied by the aspect of the font.
|
|
|
|
*/
|
2010-11-11 07:51:12 +00:00
|
|
|
float BLF_width(int fontid, const char *str);
|
|
|
|
float BLF_height(int fontid, const char *str);
|
New Bitmap draw mode for Freetype2 fonts.
The library can load any font supported by the Freetype2 library or
used the internal bitmap font.
With both types it's possible draw the text as texture or bitmap,
and using texture it's possible rotate, scale and clipping text.
Still have things to fix/add, but I think it's ready to move-on
and start droping the old api, most of (if it's not all) the
editors/interface/text.c will be remove, but some things still
has to be define, like:
* Where is store the fonts ? (default font, panel font, filesel font, etc)
I mean, every space have own fonts ? or we keep it on the context ?
It's not a really problem from the blenfont side, because every font
have reference number, so it's load only the first time.
* What we do about gettext ?
Keep the old system that call gettext inside the blenfont or replace
it for _() in the Blender source ?
Also things like pupmen has to be take care, if we want translate the menu.
Ok, time to sleep, back tomorrow to start moving the things :)
2009-04-07 08:42:28 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* Return dimensions of the font without any sample text. */
|
2011-05-04 15:09:48 +00:00
|
|
|
float BLF_height_max(int fontid);
|
|
|
|
float BLF_width_max(int fontid);
|
|
|
|
float BLF_descender(int fontid);
|
|
|
|
float BLF_ascender(int fontid);
|
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* The following function return the width and height of the string, but
|
2009-08-18 19:26:53 +00:00
|
|
|
* just in one call, so avoid extra freetype2 stuff.
|
|
|
|
*/
|
2010-11-11 07:51:12 +00:00
|
|
|
void BLF_width_and_height(int fontid, const char *str, float *width, float *height);
|
2009-07-12 02:06:15 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* For fixed width fonts only, returns the width of a
|
2009-07-12 02:06:15 +00:00
|
|
|
* character.
|
|
|
|
*/
|
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
|
|
|
float BLF_fixed_width(int fontid);
|
2009-07-12 02:06:15 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* and this two function return the width and height
|
2009-05-05 23:10:32 +00:00
|
|
|
* of the string, using the default font and both value
|
|
|
|
* are multiplied by the aspect of the font.
|
|
|
|
*/
|
2010-11-11 07:51:12 +00:00
|
|
|
float BLF_width_default(const char *str);
|
|
|
|
float BLF_height_default(const char *str);
|
2009-05-05 23:10:32 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* Set rotation for default font. */
|
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
|
|
|
void BLF_rotation_default(float angle);
|
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* Enable/disable options to the default font. */
|
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
|
|
|
void BLF_enable_default(int option);
|
|
|
|
void BLF_disable_default(int option);
|
2009-07-02 18:12:46 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* By default, rotation and clipping are disable and
|
New Bitmap draw mode for Freetype2 fonts.
The library can load any font supported by the Freetype2 library or
used the internal bitmap font.
With both types it's possible draw the text as texture or bitmap,
and using texture it's possible rotate, scale and clipping text.
Still have things to fix/add, but I think it's ready to move-on
and start droping the old api, most of (if it's not all) the
editors/interface/text.c will be remove, but some things still
has to be define, like:
* Where is store the fonts ? (default font, panel font, filesel font, etc)
I mean, every space have own fonts ? or we keep it on the context ?
It's not a really problem from the blenfont side, because every font
have reference number, so it's load only the first time.
* What we do about gettext ?
Keep the old system that call gettext inside the blenfont or replace
it for _() in the Blender source ?
Also things like pupmen has to be take care, if we want translate the menu.
Ok, time to sleep, back tomorrow to start moving the things :)
2009-04-07 08:42:28 +00:00
|
|
|
* have to be enable/disable using BLF_enable/disable.
|
|
|
|
*/
|
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
|
|
|
void BLF_rotation(int fontid, float angle);
|
|
|
|
void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax);
|
2010-04-23 22:08:11 +00:00
|
|
|
void BLF_clipping_default(float xmin, float ymin, float xmax, float 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
|
|
|
void BLF_blur(int fontid, int size);
|
2009-02-20 05:42:44 +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
|
|
|
void BLF_enable(int fontid, int option);
|
|
|
|
void BLF_disable(int fontid, int option);
|
2009-02-19 16:39:36 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* Shadow options, level is the blur level, can be 3, 5 or 0 and
|
2009-06-23 16:27:35 +00:00
|
|
|
* the other argument are the rgba color.
|
2012-03-12 09:22:16 +00:00
|
|
|
* Take care that shadow need to be enable using BLF_enable!!!
|
2009-06-23 16:27:35 +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
|
|
|
void BLF_shadow(int fontid, int level, float r, float g, float b, float a);
|
2009-06-23 16:27:35 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* Set the offset for shadow text, this is the current cursor
|
2009-06-23 16:27:35 +00:00
|
|
|
* position plus this offset, don't need call BLF_position before
|
|
|
|
* this function, the current position is calculate only on
|
|
|
|
* BLF_draw, so it's safe call this whenever you like.
|
|
|
|
*/
|
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
|
|
|
void BLF_shadow_offset(int fontid, int x, int y);
|
2009-06-23 16:27:35 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* Set the buffer, size and number of channels to draw, one thing to take care is call
|
2009-08-18 19:26:53 +00:00
|
|
|
* this function with NULL pointer when we finish, for example:
|
|
|
|
*
|
2012-03-12 09:22:16 +00:00
|
|
|
* BLF_buffer(my_fbuf, my_cbuf, 100, 100, 4);
|
2009-08-18 19:26:53 +00:00
|
|
|
*
|
2012-03-12 09:22:16 +00:00
|
|
|
* ... set color, position and draw ...
|
|
|
|
*
|
|
|
|
* BLF_buffer(NULL, NULL, 0, 0, 0);
|
2009-08-18 19:26:53 +00:00
|
|
|
*/
|
2011-04-30 08:54:06 +00:00
|
|
|
void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* Set the color to be used for text. */
|
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
|
|
|
void BLF_buffer_col(int fontid, float r, float g, float b, float a);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* Draw the string into the buffer, this function draw in both buffer, float and unsigned char _BUT_
|
2009-08-18 19:26:53 +00:00
|
|
|
* it's not necessary set both buffer, NULL is valid here.
|
|
|
|
*/
|
2010-11-11 07:51:12 +00:00
|
|
|
void BLF_draw_buffer(int fontid, const char *str);
|
2009-08-18 19:26:53 +00:00
|
|
|
|
2009-02-09 07:15:22 +00:00
|
|
|
/* Add a path to the font dir paths. */
|
|
|
|
void BLF_dir_add(const char *path);
|
|
|
|
|
|
|
|
/* Remove a path from the font dir paths. */
|
|
|
|
void BLF_dir_rem(const char *path);
|
|
|
|
|
|
|
|
/* Return an array with all the font dir (this can be used for filesel) */
|
|
|
|
char **BLF_dir_get(int *ndir);
|
|
|
|
|
|
|
|
/* Free the data return by BLF_dir_get. */
|
|
|
|
void BLF_dir_free(char **dirs, int count);
|
|
|
|
|
2009-02-20 05:42:44 +00:00
|
|
|
/* font->flags. */
|
2009-03-02 05:20:48 +00:00
|
|
|
#define BLF_ROTATION (1<<0)
|
|
|
|
#define BLF_CLIPPING (1<<1)
|
2009-07-10 20:18:19 +00:00
|
|
|
#define BLF_SHADOW (1<<2)
|
2009-07-10 22:16:25 +00:00
|
|
|
#define BLF_KERNING_DEFAULT (1<<3)
|
2010-12-09 04:36:58 +00:00
|
|
|
#define BLF_MATRIX (1<<4)
|
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
|
|
|
#define BLF_ASPECT (1<<5)
|
2009-02-20 05:42:44 +00:00
|
|
|
|
2012-01-11 12:33:51 +00:00
|
|
|
#define BLF_DRAW_STR_DUMMY_MAX 1024
|
|
|
|
|
2012-03-12 09:22:16 +00:00
|
|
|
/* XXX, bad design */
|
2010-11-26 16:33:42 +00:00
|
|
|
extern int blf_mono_font;
|
2012-03-12 09:22:16 +00:00
|
|
|
extern int blf_mono_font_render; /* dont mess drawing with render threads. */
|
2010-11-26 16:33:42 +00:00
|
|
|
|
2012-02-17 18:59:41 +00:00
|
|
|
#endif /* __BLF_API_H__ */
|