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 int BLF_load(const char *name);
45 int BLF_load_mem(const char *name, unsigned char *mem, int mem_size);
47 int BLF_load_unique(const char *name);
48 int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size);
50 /* Attach a file with metrics information from memory. */
51 void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size);
53 void BLF_aspect(int fontid, float x, float y, float z);
54 void BLF_position(int fontid, float x, float y, float z);
55 void BLF_size(int fontid, int size, int dpi);
57 /* Set a 4x4 matrix to be multiplied before draw the text.
58 * Remember that you need call BLF_enable(BLF_MATRIX)
61 * The order of the matrix is like GL:
63 | m[0] m[4] m[8] m[12] |
64 | m[1] m[5] m[9] m[13] |
65 | m[2] m[6] m[10] m[14] |
66 | m[3] m[7] m[11] m[15] |
69 void BLF_matrix(int fontid, double *m);
71 /* Draw the string using the default font, size and dpi. */
72 void BLF_draw_default(float x, float y, float z, const char *str, size_t len);
73 void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len);
75 /* Draw the string using the current font. */
76 void BLF_draw(int fontid, const char *str, size_t len);
77 void BLF_draw_ascii(int fontid, const char *str, size_t len);
80 * This function return the bounding box of the string
81 * and are not multiplied by the aspect.
83 void BLF_boundbox(int fontid, const char *str, struct rctf *box);
86 * The next both function return the width and height
87 * of the string, using the current font and both value
88 * are multiplied by the aspect of the font.
90 float BLF_width(int fontid, const char *str);
91 float BLF_height(int fontid, const char *str);
94 * The following function return the width and height of the string, but
95 * just in one call, so avoid extra freetype2 stuff.
97 void BLF_width_and_height(int fontid, const char *str, float *width, float *height);
100 * For fixed width fonts only, returns the width of a
103 float BLF_fixed_width(int fontid);
106 * and this two function return the width and height
107 * of the string, using the default font and both value
108 * are multiplied by the aspect of the font.
110 float BLF_width_default(const char *str);
111 float BLF_height_default(const char *str);
114 * Set rotation for default font.
116 void BLF_rotation_default(float angle);
119 * Enable/disable options to the default font.
121 void BLF_enable_default(int option);
122 void BLF_disable_default(int option);
125 * By default, rotation and clipping are disable and
126 * have to be enable/disable using BLF_enable/disable.
128 void BLF_rotation(int fontid, float angle);
129 void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax);
130 void BLF_clipping_default(float xmin, float ymin, float xmax, float ymax);
131 void BLF_blur(int fontid, int size);
133 void BLF_enable(int fontid, int option);
134 void BLF_disable(int fontid, int option);
137 * Shadow options, level is the blur level, can be 3, 5 or 0 and
138 * the other argument are the rgba color.
139 * Take care that shadow need to be enable using BLF_enable!!.
141 void BLF_shadow(int fontid, int level, float r, float g, float b, float a);
144 * Set the offset for shadow text, this is the current cursor
145 * position plus this offset, don't need call BLF_position before
146 * this function, the current position is calculate only on
147 * BLF_draw, so it's safe call this whenever you like.
149 void BLF_shadow_offset(int fontid, int x, int y);
152 * Set the buffer, size and number of channels to draw, one thing to take care is call
153 * this function with NULL pointer when we finish, for example:
154 * BLF_buffer(my_fbuf, my_cbuf, 100, 100, 4);
156 * ... set color, position and draw ...
158 * BLF_buffer(NULL, NULL, 0, 0, 0);
160 void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch);
163 * Set the color to be used for text.
165 void BLF_buffer_col(int fontid, float r, float g, float b, float a);
168 * Draw the string into the buffer, this function draw in both buffer, float and unsigned char _BUT_
169 * it's not necessary set both buffer, NULL is valid here.
171 void BLF_draw_buffer(int fontid, const char *str);
174 * Search the path directory to the locale files, this try all
175 * the case for Linux, Win and Mac.
177 void BLF_lang_init(void);
179 /* Set the current locale. */
180 void BLF_lang_set(const char *);
182 /* Set the current encoding name. */
183 void BLF_lang_encoding_name(const char *str);
185 void BLF_lang_encoding(const char *str);
187 /* Add a path to the font dir paths. */
188 void BLF_dir_add(const char *path);
190 /* Remove a path from the font dir paths. */
191 void BLF_dir_rem(const char *path);
193 /* Return an array with all the font dir (this can be used for filesel) */
194 char **BLF_dir_get(int *ndir);
196 /* Free the data return by BLF_dir_get. */
197 void BLF_dir_free(char **dirs, int count);
200 #define BLF_ROTATION (1<<0)
201 #define BLF_CLIPPING (1<<1)
202 #define BLF_SHADOW (1<<2)
203 #define BLF_KERNING_DEFAULT (1<<3)
204 #define BLF_MATRIX (1<<4)
205 #define BLF_ASPECT (1<<5)
208 extern int blf_mono_font;
209 extern int blf_mono_font_render; // dont mess drawing with render threads.
211 #endif /* BLF_API_H */