4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * The Original Code is Copyright (C) 2009 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
29 /** \file blender/blenfont/BLF_api.h
39 int BLF_init(int points, int dpi);
42 void BLF_cache_clear(void);
44 char* BLF_gettext(const char *msgid);
46 int BLF_load(const char *name);
47 int BLF_load_mem(const char *name, unsigned char *mem, int mem_size);
49 int BLF_load_unique(const char *name);
50 int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size);
52 /* Attach a file with metrics information from memory. */
53 void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size);
55 void BLF_aspect(int fontid, float x, float y, float z);
56 void BLF_position(int fontid, float x, float y, float z);
57 void BLF_size(int fontid, int size, int dpi);
59 /* Set a 4x4 matrix to be multiplied before draw the text.
60 * Remember that you need call BLF_enable(BLF_MATRIX)
63 * The order of the matrix is like GL:
65 | m[0] m[4] m[8] m[12] |
66 | m[1] m[5] m[9] m[13] |
67 | m[2] m[6] m[10] m[14] |
68 | m[3] m[7] m[11] m[15] |
71 void BLF_matrix(int fontid, double *m);
73 /* Draw the string using the default font, size and dpi. */
74 void BLF_draw_default(float x, float y, float z, const char *str, size_t len);
75 void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len);
77 /* Draw the string using the current font. */
78 void BLF_draw(int fontid, const char *str, size_t len);
79 void BLF_draw_ascii(int fontid, const char *str, size_t len);
82 * This function return the bounding box of the string
83 * and are not multiplied by the aspect.
85 void BLF_boundbox(int fontid, const char *str, struct rctf *box);
88 * The next both function return the width and height
89 * of the string, using the current font and both value
90 * are multiplied by the aspect of the font.
92 float BLF_width(int fontid, const char *str);
93 float BLF_height(int fontid, const char *str);
96 * Return dimensions of the font without any sample text.
98 float BLF_height_max(int fontid);
99 float BLF_width_max(int fontid);
100 float BLF_descender(int fontid);
101 float BLF_ascender(int fontid);
104 * The following function return the width and height of the string, but
105 * just in one call, so avoid extra freetype2 stuff.
107 void BLF_width_and_height(int fontid, const char *str, float *width, float *height);
110 * For fixed width fonts only, returns the width of a
113 float BLF_fixed_width(int fontid);
116 * and this two function return the width and height
117 * of the string, using the default font and both value
118 * are multiplied by the aspect of the font.
120 float BLF_width_default(const char *str);
121 float BLF_height_default(const char *str);
124 * Set rotation for default font.
126 void BLF_rotation_default(float angle);
129 * Enable/disable options to the default font.
131 void BLF_enable_default(int option);
132 void BLF_disable_default(int option);
135 * By default, rotation and clipping are disable and
136 * have to be enable/disable using BLF_enable/disable.
138 void BLF_rotation(int fontid, float angle);
139 void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax);
140 void BLF_clipping_default(float xmin, float ymin, float xmax, float ymax);
141 void BLF_blur(int fontid, int size);
143 void BLF_enable(int fontid, int option);
144 void BLF_disable(int fontid, int option);
147 * Shadow options, level is the blur level, can be 3, 5 or 0 and
148 * the other argument are the rgba color.
149 * Take care that shadow need to be enable using BLF_enable!!.
151 void BLF_shadow(int fontid, int level, float r, float g, float b, float a);
154 * Set the offset for shadow text, this is the current cursor
155 * position plus this offset, don't need call BLF_position before
156 * this function, the current position is calculate only on
157 * BLF_draw, so it's safe call this whenever you like.
159 void BLF_shadow_offset(int fontid, int x, int y);
162 * Set the buffer, size and number of channels to draw, one thing to take care is call
163 * this function with NULL pointer when we finish, for example:
164 * BLF_buffer(my_fbuf, my_cbuf, 100, 100, 4);
166 * ... set color, position and draw ...
168 * BLF_buffer(NULL, NULL, 0, 0, 0);
170 void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch);
173 * Set the color to be used for text.
175 void BLF_buffer_col(int fontid, float r, float g, float b, float a);
178 * Draw the string into the buffer, this function draw in both buffer, float and unsigned char _BUT_
179 * it's not necessary set both buffer, NULL is valid here.
181 void BLF_draw_buffer(int fontid, const char *str);
184 * Search the path directory to the locale files, this try all
185 * the case for Linux, Win and Mac.
187 void BLF_lang_init(void);
189 /* Set the current locale. */
190 void BLF_lang_set(const char *);
192 /* Set the current encoding name. */
193 void BLF_lang_encoding_name(const char *str);
195 void BLF_lang_encoding(const char *str);
197 /* Add a path to the font dir paths. */
198 void BLF_dir_add(const char *path);
200 /* Remove a path from the font dir paths. */
201 void BLF_dir_rem(const char *path);
203 /* Return an array with all the font dir (this can be used for filesel) */
204 char **BLF_dir_get(int *ndir);
206 /* Free the data return by BLF_dir_get. */
207 void BLF_dir_free(char **dirs, int count);
210 #define BLF_ROTATION (1<<0)
211 #define BLF_CLIPPING (1<<1)
212 #define BLF_SHADOW (1<<2)
213 #define BLF_KERNING_DEFAULT (1<<3)
214 #define BLF_MATRIX (1<<4)
215 #define BLF_ASPECT (1<<5)
218 extern int blf_mono_font;
219 extern int blf_mono_font_render; // dont mess drawing with render threads.
222 extern int blf_unifont;
223 #define _(msgid) BLF_gettext(msgid)
224 #define N_(msgid) msgid
226 #endif /* BLF_API_H */