|
Blender
V2.59
|
00001 /* 00002 * $Id: BLF_api.h 36487 2011-05-04 15:09:48Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2009 Blender Foundation. 00021 * All rights reserved. 00022 * 00023 * 00024 * Contributor(s): Blender Foundation 00025 * 00026 * ***** END GPL LICENSE BLOCK ***** 00027 */ 00028 00034 #ifndef BLF_API_H 00035 #define BLF_API_H 00036 00037 struct rctf; 00038 00039 int BLF_init(int points, int dpi); 00040 void BLF_exit(void); 00041 00042 void BLF_cache_clear(void); 00043 00044 int BLF_load(const char *name); 00045 int BLF_load_mem(const char *name, unsigned char *mem, int mem_size); 00046 00047 int BLF_load_unique(const char *name); 00048 int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size); 00049 00050 /* Attach a file with metrics information from memory. */ 00051 void BLF_metrics_attach(int fontid, unsigned char *mem, int mem_size); 00052 00053 void BLF_aspect(int fontid, float x, float y, float z); 00054 void BLF_position(int fontid, float x, float y, float z); 00055 void BLF_size(int fontid, int size, int dpi); 00056 00057 /* Set a 4x4 matrix to be multiplied before draw the text. 00058 * Remember that you need call BLF_enable(BLF_MATRIX) 00059 * to enable this. 00060 * 00061 * The order of the matrix is like GL: 00062 00063 | m[0] m[4] m[8] m[12] | 00064 | m[1] m[5] m[9] m[13] | 00065 | m[2] m[6] m[10] m[14] | 00066 | m[3] m[7] m[11] m[15] | 00067 00068 */ 00069 void BLF_matrix(int fontid, double *m); 00070 00071 /* Draw the string using the default font, size and dpi. */ 00072 void BLF_draw_default(float x, float y, float z, const char *str, size_t len); 00073 void BLF_draw_default_ascii(float x, float y, float z, const char *str, size_t len); 00074 00075 /* Draw the string using the current font. */ 00076 void BLF_draw(int fontid, const char *str, size_t len); 00077 void BLF_draw_ascii(int fontid, const char *str, size_t len); 00078 00079 /* 00080 * This function return the bounding box of the string 00081 * and are not multiplied by the aspect. 00082 */ 00083 void BLF_boundbox(int fontid, const char *str, struct rctf *box); 00084 00085 /* 00086 * The next both function return the width and height 00087 * of the string, using the current font and both value 00088 * are multiplied by the aspect of the font. 00089 */ 00090 float BLF_width(int fontid, const char *str); 00091 float BLF_height(int fontid, const char *str); 00092 00093 /* 00094 * Return dimensions of the font without any sample text. 00095 */ 00096 float BLF_height_max(int fontid); 00097 float BLF_width_max(int fontid); 00098 float BLF_descender(int fontid); 00099 float BLF_ascender(int fontid); 00100 00101 /* 00102 * The following function return the width and height of the string, but 00103 * just in one call, so avoid extra freetype2 stuff. 00104 */ 00105 void BLF_width_and_height(int fontid, const char *str, float *width, float *height); 00106 00107 /* 00108 * For fixed width fonts only, returns the width of a 00109 * character. 00110 */ 00111 float BLF_fixed_width(int fontid); 00112 00113 /* 00114 * and this two function return the width and height 00115 * of the string, using the default font and both value 00116 * are multiplied by the aspect of the font. 00117 */ 00118 float BLF_width_default(const char *str); 00119 float BLF_height_default(const char *str); 00120 00121 /* 00122 * Set rotation for default font. 00123 */ 00124 void BLF_rotation_default(float angle); 00125 00126 /* 00127 * Enable/disable options to the default font. 00128 */ 00129 void BLF_enable_default(int option); 00130 void BLF_disable_default(int option); 00131 00132 /* 00133 * By default, rotation and clipping are disable and 00134 * have to be enable/disable using BLF_enable/disable. 00135 */ 00136 void BLF_rotation(int fontid, float angle); 00137 void BLF_clipping(int fontid, float xmin, float ymin, float xmax, float ymax); 00138 void BLF_clipping_default(float xmin, float ymin, float xmax, float ymax); 00139 void BLF_blur(int fontid, int size); 00140 00141 void BLF_enable(int fontid, int option); 00142 void BLF_disable(int fontid, int option); 00143 00144 /* 00145 * Shadow options, level is the blur level, can be 3, 5 or 0 and 00146 * the other argument are the rgba color. 00147 * Take care that shadow need to be enable using BLF_enable!!. 00148 */ 00149 void BLF_shadow(int fontid, int level, float r, float g, float b, float a); 00150 00151 /* 00152 * Set the offset for shadow text, this is the current cursor 00153 * position plus this offset, don't need call BLF_position before 00154 * this function, the current position is calculate only on 00155 * BLF_draw, so it's safe call this whenever you like. 00156 */ 00157 void BLF_shadow_offset(int fontid, int x, int y); 00158 00159 /* 00160 * Set the buffer, size and number of channels to draw, one thing to take care is call 00161 * this function with NULL pointer when we finish, for example: 00162 * BLF_buffer(my_fbuf, my_cbuf, 100, 100, 4); 00163 * 00164 * ... set color, position and draw ... 00165 * 00166 * BLF_buffer(NULL, NULL, 0, 0, 0); 00167 */ 00168 void BLF_buffer(int fontid, float *fbuf, unsigned char *cbuf, int w, int h, int nch); 00169 00170 /* 00171 * Set the color to be used for text. 00172 */ 00173 void BLF_buffer_col(int fontid, float r, float g, float b, float a); 00174 00175 /* 00176 * Draw the string into the buffer, this function draw in both buffer, float and unsigned char _BUT_ 00177 * it's not necessary set both buffer, NULL is valid here. 00178 */ 00179 void BLF_draw_buffer(int fontid, const char *str); 00180 00181 /* 00182 * Search the path directory to the locale files, this try all 00183 * the case for Linux, Win and Mac. 00184 */ 00185 void BLF_lang_init(void); 00186 00187 /* Set the current locale. */ 00188 void BLF_lang_set(const char *); 00189 00190 /* Set the current encoding name. */ 00191 void BLF_lang_encoding_name(const char *str); 00192 00193 void BLF_lang_encoding(const char *str); 00194 00195 /* Add a path to the font dir paths. */ 00196 void BLF_dir_add(const char *path); 00197 00198 /* Remove a path from the font dir paths. */ 00199 void BLF_dir_rem(const char *path); 00200 00201 /* Return an array with all the font dir (this can be used for filesel) */ 00202 char **BLF_dir_get(int *ndir); 00203 00204 /* Free the data return by BLF_dir_get. */ 00205 void BLF_dir_free(char **dirs, int count); 00206 00207 /* font->flags. */ 00208 #define BLF_ROTATION (1<<0) 00209 #define BLF_CLIPPING (1<<1) 00210 #define BLF_SHADOW (1<<2) 00211 #define BLF_KERNING_DEFAULT (1<<3) 00212 #define BLF_MATRIX (1<<4) 00213 #define BLF_ASPECT (1<<5) 00214 00215 // XXX, bad design 00216 extern int blf_mono_font; 00217 extern int blf_mono_font_render; // dont mess drawing with render threads. 00218 00219 #endif /* BLF_API_H */