Blender V2.61 - r43446

blf_internal_types.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) 2008 Blender Foundation.
00019  * All rights reserved.
00020  * 
00021  * Contributor(s): Blender Foundation.
00022  *
00023  * ***** END GPL LICENSE BLOCK *****
00024  */
00025 
00031 #ifndef BLF_INTERNAL_TYPES_H
00032 #define BLF_INTERNAL_TYPES_H
00033 
00034 typedef struct GlyphCacheBLF {
00035     struct GlyphCacheBLF *next;
00036     struct GlyphCacheBLF *prev;
00037 
00038     /* font size. */
00039     int size;
00040 
00041     /* and dpi. */
00042     int dpi;
00043 
00044     /* and the glyphs. */
00045     ListBase bucket[257];
00046 
00047     /* fast ascii lookup */
00048     struct GlyphBLF *glyph_ascii_table[256];
00049 
00050     /* texture array, to draw the glyphs. */
00051     GLuint *textures;
00052 
00053     /* size of the array. */
00054     int ntex;
00055 
00056     /* and the last texture, aka. the current texture. */
00057     int cur_tex;
00058 
00059     /* like bftgl, we draw every glyph in a big texture, so this is the
00060      * current position inside the texture.
00061      */
00062     int x_offs;
00063     int y_offs;
00064 
00065     /* and the space from one to other. */
00066     unsigned int pad;
00067 
00068     /* and the bigger glyph in the font. */
00069     int max_glyph_width;
00070     int max_glyph_height;
00071 
00072     /* next two integer power of two, to build the texture. */
00073     int p2_width;
00074     int p2_height;
00075 
00076     /* number of glyphs in the font. */
00077     int num_glyphs;
00078 
00079     /* number of glyphs that we load here. */
00080     int rem_glyphs;
00081 
00082     /* ascender and descender value. */
00083     float ascender;
00084     float descender;
00085 } GlyphCacheBLF;
00086 
00087 typedef struct GlyphBLF {
00088     struct GlyphBLF *next;
00089     struct GlyphBLF *prev;
00090 
00091     /* and the character, as UTF8 */
00092     unsigned int c;
00093 
00094     /* freetype2 index, to speed-up the search. */
00095     FT_UInt idx;
00096 
00097     /* glyph box. */
00098     rctf box;
00099 
00100     /* advance size. */
00101     float advance;
00102 
00103     /* texture id where this glyph is store. */
00104     GLuint tex;
00105 
00106     /* position inside the texture where this glyph is store. */
00107     int xoff;
00108     int yoff;
00109 
00110     /* Bitmap data, from freetype. Take care that this
00111      * can be NULL.
00112      */
00113     unsigned char *bitmap;
00114 
00115     /* glyph width and height. */
00116     int width;
00117     int height;
00118     int pitch;
00119 
00120     /* uv coords. */
00121     float uv[2][2];
00122 
00123     /* X and Y bearing of the glyph.
00124      * The X bearing is from the origin to the glyph left bbox edge.
00125      * The Y bearing is from the baseline to the top of the glyph edge.
00126      */
00127     float pos_x;
00128     float pos_y;
00129 
00130     /* with value of zero mean that we need build the texture. */
00131     short build_tex;
00132 } GlyphBLF;
00133 
00134 typedef struct FontBLF {
00135     /* font name. */
00136     char *name;
00137 
00138     /* filename or NULL. */
00139     char *filename;
00140 
00141     /* aspect ratio or scale. */
00142     float aspect[3];
00143 
00144     /* initial position for draw the text. */
00145     float pos[3];
00146 
00147     /* angle in degrees. */
00148     float angle;
00149     
00150     /* blur: 3 or 5 large kernel */
00151     int blur;
00152 
00153     /* shadow level. */
00154     int shadow;
00155 
00156     /* and shadow offset. */
00157     int shadow_x;
00158     int shadow_y;
00159 
00160     /* shadow color. */
00161     float shadow_col[4];
00162 
00163     /* store color here when drawing shadow or blur. */
00164     float orig_col[4];
00165 
00166     /* Multiplied this matrix with the current one before
00167      * draw the text! see blf_draw__start.
00168      */
00169     double m[16];
00170 
00171     /* clipping rectangle. */
00172     rctf clip_rec;
00173 
00174     /* font dpi (default 72). */
00175     int dpi;
00176 
00177     /* font size. */
00178     int size;
00179 
00180     /* max texture size. */
00181     int max_tex_size;
00182 
00183     /* current opengl texture  bind, avoids calling glGet */
00184     int tex_bind_state;
00185 
00186     /* font options. */
00187     int flags;
00188 
00189     /* list of glyph cache for this font. */
00190     ListBase cache;
00191 
00192     /* current glyph cache, size and dpi. */
00193     GlyphCacheBLF *glyph_cache;
00194 
00195     /* freetype2 lib handle. */
00196     FT_Library ft_lib;
00197 
00198     /* freetype2 face. */
00199     FT_Face face;
00200 
00201     /* for draw to buffer, always set this to NULL after finish! */
00202     float *b_fbuf;
00203 
00204     /* the same but unsigned char */
00205     unsigned char *b_cbuf;
00206 
00207     /* buffer size, keep signed so comparisons with negative values work */
00208     int bw;
00209     int bh;
00210 
00211     /* number of channels. */
00212     int bch;
00213 
00214     /* and the color, the alphas is get from the glyph! */
00215     float b_col[4];
00216 } FontBLF;
00217 
00218 typedef struct DirBLF {
00219     struct DirBLF *next;
00220     struct DirBLF *prev;
00221 
00222     /* full path where search fonts. */
00223     char *path;
00224 } DirBLF;
00225 
00226 #endif /* BLF_INTERNAL_TYPES_H */