Blender V2.61 - r43446

BLF_api.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version. 
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2009 Blender Foundation.
00019  * All rights reserved.
00020  *
00021  * 
00022  * Contributor(s): Blender Foundation
00023  *
00024  * ***** END GPL LICENSE BLOCK *****
00025  */
00026 
00032 #ifndef BLF_API_H
00033 #define BLF_API_H
00034 
00035 struct rctf;
00036 
00037 int BLF_init(int points, int dpi);
00038 void BLF_exit(void);
00039 
00040 void BLF_cache_clear(void);
00041 
00042 int BLF_load(const char *name);
00043 int BLF_load_mem(const char *name, unsigned char *mem, int mem_size);
00044 
00045 int BLF_load_unique(const char *name);
00046 int BLF_load_mem_unique(const char *name, unsigned char *mem, int mem_size);
00047 
00048 void BLF_unload(const char *name);
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, const double m[16]);
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 /* Add a path to the font dir paths. */
00182 void BLF_dir_add(const char *path);
00183 
00184 /* Remove a path from the font dir paths. */
00185 void BLF_dir_rem(const char *path);
00186 
00187 /* Return an array with all the font dir (this can be used for filesel) */
00188 char **BLF_dir_get(int *ndir);
00189 
00190 /* Free the data return by BLF_dir_get. */
00191 void BLF_dir_free(char **dirs, int count);
00192 
00193 /* font->flags. */
00194 #define BLF_ROTATION (1<<0)
00195 #define BLF_CLIPPING (1<<1)
00196 #define BLF_SHADOW (1<<2)
00197 #define BLF_KERNING_DEFAULT (1<<3)
00198 #define BLF_MATRIX (1<<4)
00199 #define BLF_ASPECT (1<<5)
00200 
00201 #define BLF_DRAW_STR_DUMMY_MAX 1024
00202 
00203 // XXX, bad design
00204 extern int blf_mono_font;
00205 extern int blf_mono_font_render; // dont mess drawing with render threads.
00206 
00207 #endif /* BLF_API_H */