2009-01-29 06:19:27 +01:00
|
|
|
/**
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2008 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Blender Foundation.
|
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef BLF_INTERNAL_TYPES_H
|
|
|
|
#define BLF_INTERNAL_TYPES_H
|
|
|
|
|
2009-02-17 17:56:29 +01:00
|
|
|
typedef struct GlyphCacheBLF {
|
|
|
|
struct GlyphCacheBLF *next;
|
|
|
|
struct GlyphCacheBLF *prev;
|
2009-02-09 08:15:22 +01:00
|
|
|
|
|
|
|
/* font size. */
|
|
|
|
int size;
|
|
|
|
|
|
|
|
/* and dpi. */
|
|
|
|
int dpi;
|
|
|
|
|
|
|
|
/* and the glyphs. */
|
|
|
|
ListBase bucket[257];
|
|
|
|
|
|
|
|
/* texture array, to draw the glyphs. */
|
|
|
|
GLuint *textures;
|
|
|
|
|
|
|
|
/* size of the array. */
|
|
|
|
int ntex;
|
|
|
|
|
|
|
|
/* and the last texture, aka. the current texture. */
|
|
|
|
int cur_tex;
|
|
|
|
|
|
|
|
/* like bftgl, we draw every glyph in a big texture, so this is the
|
|
|
|
* current position inside the texture.
|
|
|
|
*/
|
|
|
|
int x_offs;
|
|
|
|
int y_offs;
|
|
|
|
|
|
|
|
/* and the space from one to other. */
|
|
|
|
unsigned int pad;
|
|
|
|
|
|
|
|
/* and the bigger glyph in the font. */
|
|
|
|
int max_glyph_width;
|
|
|
|
int max_glyph_height;
|
|
|
|
|
|
|
|
/* next two integer power of two, to build the texture. */
|
|
|
|
int p2_width;
|
|
|
|
int p2_height;
|
|
|
|
|
|
|
|
/* number of glyphs in the font. */
|
|
|
|
int num_glyphs;
|
|
|
|
|
|
|
|
/* number of glyphs that we load here. */
|
|
|
|
int rem_glyphs;
|
|
|
|
|
|
|
|
/* ascender and descender value. */
|
|
|
|
float ascender;
|
|
|
|
float descender;
|
|
|
|
} GlyphCacheBLF;
|
|
|
|
|
New Bitmap draw mode for Freetype2 fonts.
The library can load any font supported by the Freetype2 library or
used the internal bitmap font.
With both types it's possible draw the text as texture or bitmap,
and using texture it's possible rotate, scale and clipping text.
Still have things to fix/add, but I think it's ready to move-on
and start droping the old api, most of (if it's not all) the
editors/interface/text.c will be remove, but some things still
has to be define, like:
* Where is store the fonts ? (default font, panel font, filesel font, etc)
I mean, every space have own fonts ? or we keep it on the context ?
It's not a really problem from the blenfont side, because every font
have reference number, so it's load only the first time.
* What we do about gettext ?
Keep the old system that call gettext inside the blenfont or replace
it for _() in the Blender source ?
Also things like pupmen has to be take care, if we want translate the menu.
Ok, time to sleep, back tomorrow to start moving the things :)
2009-04-07 10:42:28 +02:00
|
|
|
typedef struct GlyphTextureBLF {
|
2009-02-09 08:15:22 +01:00
|
|
|
/* texture id where this glyph is store. */
|
|
|
|
GLuint tex;
|
|
|
|
|
|
|
|
/* position inside the texture where this glyph is store. */
|
|
|
|
int xoff;
|
|
|
|
int yoff;
|
|
|
|
|
|
|
|
/* glyph width and height. */
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
|
|
|
|
/* uv coords. */
|
|
|
|
float uv[2][2];
|
|
|
|
|
|
|
|
/* X and Y bearing of the glyph.
|
|
|
|
* The X bearing is from the origin to the glyph left bbox edge.
|
|
|
|
* The Y bearing is from the baseline to the top of the glyph edge.
|
|
|
|
*/
|
|
|
|
float pos_x;
|
|
|
|
float pos_y;
|
New Bitmap draw mode for Freetype2 fonts.
The library can load any font supported by the Freetype2 library or
used the internal bitmap font.
With both types it's possible draw the text as texture or bitmap,
and using texture it's possible rotate, scale and clipping text.
Still have things to fix/add, but I think it's ready to move-on
and start droping the old api, most of (if it's not all) the
editors/interface/text.c will be remove, but some things still
has to be define, like:
* Where is store the fonts ? (default font, panel font, filesel font, etc)
I mean, every space have own fonts ? or we keep it on the context ?
It's not a really problem from the blenfont side, because every font
have reference number, so it's load only the first time.
* What we do about gettext ?
Keep the old system that call gettext inside the blenfont or replace
it for _() in the Blender source ?
Also things like pupmen has to be take care, if we want translate the menu.
Ok, time to sleep, back tomorrow to start moving the things :)
2009-04-07 10:42:28 +02:00
|
|
|
} GlyphTextureBLF;
|
|
|
|
|
|
|
|
typedef struct GlyphBitmapBLF {
|
|
|
|
/* image data. */
|
|
|
|
unsigned char *image;
|
|
|
|
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int pitch;
|
|
|
|
|
|
|
|
float pos_x;
|
|
|
|
float pos_y;
|
|
|
|
} GlyphBitmapBLF;
|
|
|
|
|
|
|
|
typedef struct GlyphBLF {
|
|
|
|
struct GlyphBLF *next;
|
|
|
|
struct GlyphBLF *prev;
|
|
|
|
|
|
|
|
/* and the character, as UTF8 */
|
|
|
|
unsigned int c;
|
|
|
|
|
|
|
|
/* glyph box. */
|
|
|
|
rctf box;
|
|
|
|
|
|
|
|
/* advance size. */
|
|
|
|
float advance;
|
|
|
|
|
|
|
|
/* texture information. */
|
|
|
|
GlyphTextureBLF *tex_data;
|
|
|
|
|
|
|
|
/* bitmap information. */
|
|
|
|
GlyphBitmapBLF *bitmap_data;
|
2009-02-09 08:15:22 +01:00
|
|
|
} GlyphBLF;
|
|
|
|
|
|
|
|
typedef struct FontBLF {
|
2009-02-12 06:02:42 +01:00
|
|
|
/* font name. */
|
2009-02-09 08:15:22 +01:00
|
|
|
char *name;
|
2009-02-12 06:02:42 +01:00
|
|
|
|
|
|
|
/* filename or NULL. */
|
|
|
|
char *filename;
|
2009-02-09 08:15:22 +01:00
|
|
|
|
2009-04-06 06:12:31 +02:00
|
|
|
/* draw mode, texture or bitmap. */
|
|
|
|
int mode;
|
|
|
|
|
2009-02-09 08:15:22 +01:00
|
|
|
/* reference count. */
|
|
|
|
int ref;
|
|
|
|
|
|
|
|
/* aspect ratio or scale. */
|
|
|
|
float aspect;
|
|
|
|
|
|
|
|
/* initial position for draw the text. */
|
|
|
|
float pos[3];
|
|
|
|
|
|
|
|
/* angle in degrees. */
|
2009-02-19 17:39:36 +01:00
|
|
|
float angle;
|
2009-04-10 16:27:29 +02:00
|
|
|
|
|
|
|
/* blur: 3 or 5 large kernel */
|
|
|
|
int blur;
|
|
|
|
|
2009-02-09 08:15:22 +01:00
|
|
|
/* this is the matrix that we load before rotate/scale/translate. */
|
|
|
|
float mat[4][4];
|
|
|
|
|
|
|
|
/* clipping rectangle. */
|
|
|
|
rctf clip_rec;
|
|
|
|
|
|
|
|
/* font dpi (default 72). */
|
|
|
|
int dpi;
|
|
|
|
|
|
|
|
/* font size. */
|
|
|
|
int size;
|
|
|
|
|
|
|
|
/* max texture size. */
|
|
|
|
int max_tex_size;
|
|
|
|
|
2009-02-20 06:42:44 +01:00
|
|
|
/* font options. */
|
|
|
|
int flags;
|
|
|
|
|
2009-02-09 08:15:22 +01:00
|
|
|
/* list of glyph cache for this font. */
|
|
|
|
ListBase cache;
|
|
|
|
|
|
|
|
/* current glyph cache, size and dpi. */
|
|
|
|
GlyphCacheBLF *glyph_cache;
|
2009-03-02 06:20:48 +01:00
|
|
|
|
|
|
|
/* engine data. */
|
|
|
|
void *engine;
|
2009-03-02 22:02:39 +01:00
|
|
|
|
|
|
|
/* engine functions. */
|
|
|
|
void (*size_set)(struct FontBLF *, int, int);
|
|
|
|
void (*draw)(struct FontBLF *, char *);
|
|
|
|
void (*boundbox_get)(struct FontBLF *, char *, rctf *);
|
|
|
|
float (*width_get)(struct FontBLF *, char *);
|
|
|
|
float (*height_get)(struct FontBLF *, char *);
|
|
|
|
void (*free)(struct FontBLF *);
|
2009-02-09 08:15:22 +01:00
|
|
|
} FontBLF;
|
|
|
|
|
2009-03-02 06:20:48 +01:00
|
|
|
typedef struct DirBLF {
|
|
|
|
struct DirBLF *next;
|
|
|
|
struct DirBLF *prev;
|
|
|
|
|
|
|
|
/* full path where search fonts. */
|
|
|
|
char *path;
|
|
|
|
} DirBLF;
|
2009-02-09 08:15:22 +01:00
|
|
|
|
2009-01-29 06:19:27 +01:00
|
|
|
#endif /* BLF_INTERNAL_TYPES_H */
|