include/liqfont.h

00001 /* liqbase
00002  * Copyright (C) 2008 Gary Birkett
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License version 2
00006  * as published by the Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful,
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011  * GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * along with this program; if not, write to the Free Software
00015  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00016  */
00017 
00018 /*
00019  *
00020  * Header for font glyph buffering routines
00021  *
00022  */
00023 
00024 
00025 #ifndef liqfont_H
00026 #define liqfont_H
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 typedef struct 
00033 {
00034         //int                   refcount;
00035         int                             glyphindex;
00036         int                             glyphw;
00037         int                             glyphh;
00038         int                             glyphbaseline;          //
00039         char           *glyphdata;                      // allocate any used
00040 } liqfontglyph;
00041 
00042 liqfontglyph * liqfontglyph_alloc(int glyphindex,int width,int height);
00043 //void liqfontglyph_release(liqfontglyph *self);
00044 void liqfontglyph_free(liqfontglyph *self);
00045 
00046 
00047 
00048 
00049 
00050 
00051 
00052 typedef struct liqfont     liqfont;
00053 typedef struct liqfontview liqfontview;
00054 
00055 struct liqfontview 
00056 {
00057         int usagecount;
00058         liqfont *       font;
00059         float                   scalew;                         // actual realized cache size
00060         float                   scaleh;
00061         liqfontglyph    *glyphbuffer[256];      // allocate any used
00062         int                             pixelheight;            // maximum glyphwidth   use this for obtaining boundary
00063         void                    *ftface;
00064 };
00065 
00066 
00067 
00068 
00069 // use the cache functions for speed :)
00070 liqfontview *   liqfontview_newfromscale(liqfont *font,float scalew,float scaleh);
00071 liqfontview *   liqfontview_new();
00072 liqfontview *   liqfontview_hold(liqfontview *self);
00073 void                    liqfontview_release(liqfontview *self);
00074 void                    liqfontview_free(liqfontview *self);            // do not use directly
00075 void                    liqfontview_close(liqfontview *self);
00076 liqfontglyph *  liqfontview_getglyph(liqfontview *self,int glyphindex); // release afterwards : liqfontviewglyph_release
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 
00085 struct liqfont
00086 {
00087         int usagecount;
00088         char *                  name;
00089         char *                  style;
00090         char *                  filename;
00091         int                             size;
00092         int                             rotation;                       // 0/90/180/270 currently fixed to 0, but capable of others with tweaks
00093         liqfontview *   viewcache[32];          // each available rendered view
00094         int             viewcacheused;
00095         liqfontview *   viewcachecurrent;       // current actual set in stone view of this font :)     
00096 };
00097 
00098 // use the cache functions for speed :)
00099 liqfont *liqfont_cache_getttf(char *name,int size,int rotation);
00100 void     liqfont_cache_release(liqfont *self);
00101 liqfont * liqfont_newfromfilettf(char *name,int size,int rotation);
00102 
00103 liqfont *liqfont_new();
00104 liqfont *liqfont_hold(liqfont *self);
00105 void liqfont_release(liqfont *self);
00106 
00107 void liqfont_free(liqfont *self);               // do not use directly
00108 
00109 void liqfont_close(liqfont *self);
00110 //int liqfont_openblank(liqfont *self,char *name,int size,int rotation,float scalew,float scaleh);
00111 
00112 
00113 int liqfont_setview(liqfont *self,float scalew,float scaleh);
00114 
00115 liqfontglyph *liqfont_getglyph(liqfont *self,int glyphindex);   // release afterwards : liqfontglyph_release
00116 int liqfont_getglyphwidth(liqfont *self,int glyphindex);                // automatic handling
00117 
00118 int liqfont_textfitinside(liqfont *self,char *data,int availablewidth);
00119 int liqfont_textwidth(liqfont *self,char *data);
00120 int liqfont_textwidthn(liqfont *self,char *data,int datalen);
00121 int liqfont_textheight(liqfont *self);
00122 
00123 
00124 #ifdef __cplusplus
00125 }
00126 #endif
00127 
00128 #endif

Generated on Sat May 23 23:03:13 2009 for libliqbase by  doxygen 1.5.1