intraFont.h

説明を見る。
00001 /*
00002  * intraFont.h
00003  * This file is used to display the PSP's internal font (pgf and bwfon firmware files)
00004  * intraFont Version 0.31 by BenHur - http://www.psp-programming.com/benhur
00005  *
00006  * Uses parts of pgeFont by InsertWittyName - http://insomniac.0x89.org
00007  *
00008  * This work is licensed under the Creative Commons Attribution-Share Alike 3.0 License.
00009  * See LICENSE for more details.
00010  *
00011  */
00012 
00013 #ifndef __INTRAFONT_H__
00014 #define __INTRAFONT_H__
00015 
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019 
00020 #include "intrafont_wrapper.h"
00021 
00022 #include "libccc.h"
00023 
00024 
00025 #define INTRAFONT_ADVANCE_H        0x00000000 //default: advance horizontaly from one char to the next
00026 #define INTRAFONT_ADVANCE_V        0x00000100
00027 #define INTRAFONT_ALIGN_LEFT       0x00000000 //default: left-align the text
00028 #define INTRAFONT_ALIGN_CENTER     0x00000200
00029 #define INTRAFONT_ALIGN_RIGHT      0x00000400
00030 #define INTRAFONT_ALIGN_FULL       0x00000600 //full justify text to width set by intraFontSetTextWidth()
00031 #define INTRAFONT_SCROLL_LEFT      0x00002000 //in intraFontPrintColumn if text does not fit text is scrolled to the left 
00032                                               //(requires redrawing at ‾60 FPS with x position returned by previous call to intraFontPrintColumn())
00033 #define INTRAFONT_SCROLL_SEESAW    0x00002200 //in intraFontPrintColumn if text does not fit text is scrolled left and right
00034 #define INTRAFONT_SCROLL_RIGHT     0x00002400 //in intraFontPrintColumn if text does not fit text is scrolled to the right
00035 #define INTRAFONT_SCROLL_THROUGH   0x00002600 //in intraFontPrintColumn if text does not fit text is scrolled through (to the left)
00036 #define INTRAFONT_WIDTH_VAR        0x00000000 //default: variable-width
00037 #define INTRAFONT_WIDTH_FIX        0x00000800 //set your custom fixed witdh to 24 pixels: INTRAFONT_WIDTH_FIX | 24 
00038                                               //(max is 255, set to 0 to use default fixed width, this width will be scaled by size)
00039 #define INTRAFONT_ACTIVE           0x00001000 //assumes the font-texture resides inside sceGuTex already, prevents unecessary reloading -> very small speed-gain                                       
00040 #define INTRAFONT_CACHE_MED        0x00000000 //default: 256x256 texture (enough to cache about 100 chars)
00041 #define INTRAFONT_CACHE_LARGE      0x00004000 //512x512 texture(enough to cache all chars of ltn0.pgf or ... or ltn15.pgf or kr0.pgf)
00042 #define INTRAFONT_CACHE_ASCII      0x00008000 //try to cache all ASCII chars during fontload (uses less memory and is faster to draw text, but slower to load font)
00043                                               //if it fails: (because the cache is too small) it will automatically switch to chache on-the-fly with a medium texture
00044                                               //if it succeeds: (all chars and shadows fit into chache) it will free some now unneeded memory
00045 #define INTRAFONT_CACHE_ALL        0x0000C000 //try to cache all chars during fontload (uses less memory and is faster to draw text, but slower to load font)
00046                                               //if it fails: (because the cache is too small) it will automatically switch to chache on-the-fly with a large texture
00047                                               //if it succeeds: (all chars and shadows fit into chache) it will free some now unneeded memory
00048 #define INTRAFONT_STRING_ASCII     (0x00010000*CCC_CP000)  //default: interpret strings as ascii text (ISO/IEC 8859-1)
00049 #define INTRAFONT_STRING_CP437     (0x00010000*CCC_CP437)  //interpret strings as ascii text (codepage 437)
00050 #define INTRAFONT_STRING_CP850     (0x00010000*CCC_CP850)  //interpret strings as ascii text (codepage 850)
00051 #define INTRAFONT_STRING_CP866     (0x00010000*CCC_CP866)  //interpret strings as ascii text (codepage 866)
00052 #define INTRAFONT_STRING_SJIS      (0x00010000*CCC_CP932)  //interpret strings as shifted-jis (used for japanese)
00053 #define INTRAFONT_STRING_GBK       (0x00010000*CCC_CP936)  //interpret strings as GBK (used for simplified chinese)
00054 #define INTRAFONT_STRING_KOR       (0x00010000*CCC_CP949)  //interpret strings as Korean codepage 949
00055 #define INTRAFONT_STRING_BIG5      (0x00010000*CCC_CP950)  //interpret strings as BIG5 (used for traditional chinese)
00056 #define INTRAFONT_STRING_CP1251    (0x00010000*CCC_CP1251) //interpret strings as ascii text (codepage windows-1251)
00057 #define INTRAFONT_STRING_CP1252    (0x00010000*CCC_CP1252) //interpret strings as ascii text (codepage windows-1252)
00058 #define INTRAFONT_STRING_UTF8      (0x00010000*CCC_CPUTF8) //interpret strings as UTF-8
00059 
00060 #define FILETYPE_PGF      0x00
00061 #define FILETYPE_BWFON    0x01
00062 #define PGF_BMP_H_ROWS    0x01
00063 #define PGF_BMP_V_ROWS    0x02
00064 #define PGF_BMP_OVERLAY   0x03
00065 #define PGF_NO_EXTRA1     0x04
00066 #define PGF_NO_EXTRA2     0x08
00067 #define PGF_NO_EXTRA3     0x10
00068 #define PGF_CHARGLYPH     0x20
00069 #define PGF_SHADOWGLYPH   0x40 //warning: this flag is not contained in the metric header flags and is only provided for simpler call to intraFontGetGlyph - ONLY check with (flags & PGF_CHARGLYPH)
00070 #define PGF_CACHED        0x80
00071 #define PGF_WIDTH_MASK    0x000000FF
00072 #define PGF_OPTIONS_MASK  0x00003FFF
00073 #define PGF_ALIGN_MASK    0x00000600
00074 #define PGF_SCROLL_MASK   0x00002600
00075 #define PGF_CACHE_MASK    0x0000C000
00076 #define PGF_STRING_MASK   0x00FF0000
00077 
00078 
00079 typedef struct {
00080     unsigned short x;         //in pixels
00081     unsigned short y;         //in pixels
00082     unsigned char width;      //in pixels
00083     unsigned char height;     //in pixels
00084     char left;                //in pixels
00085     char top;                 //in pixels
00086     unsigned char flags;
00087     unsigned short shadowID;  //to look up in shadowmap
00088     char advance;             //in quarterpixels
00089     unsigned long ptr;        //offset 
00090 } Glyph;
00091 
00092 typedef struct {
00093     unsigned short x;         //in pixels
00094     unsigned short y;         //in pixels
00095     unsigned char flags;
00096 } GlyphBW;
00097 
00098 typedef struct {
00099     unsigned short header_start;
00100     unsigned short header_len;
00101     char pgf_id[4];
00102     unsigned long revision;
00103     unsigned long version;
00104     unsigned long charmap_len;
00105     unsigned long charptr_len;
00106     unsigned long charmap_bpe;
00107     unsigned long charptr_bpe;
00108     unsigned char junk00[21];
00109     unsigned char family[64];
00110     unsigned char style[64];
00111     unsigned char junk01[1];
00112     unsigned short charmap_min;
00113     unsigned short charmap_max;
00114     unsigned char junk02[50];
00115     unsigned long fixedsize[2];
00116     unsigned char junk03[14];
00117     unsigned char table1_len;
00118     unsigned char table2_len;
00119     unsigned char table3_len;
00120     unsigned char advance_len;
00121     unsigned char junk04[102];
00122     unsigned long shadowmap_len;
00123     unsigned long shadowmap_bpe;
00124     unsigned char junk05[4];
00125     unsigned long shadowscale[2];
00126     //currently no need ;
00127 } PGF_Header;
00128 
00129 typedef struct intraFont {
00130     char* filename;
00131     unsigned char fileType;          
00132     unsigned char* fontdata;
00133     
00134     unsigned char* texture;          
00135     unsigned int texWidth;           
00136     unsigned int texHeight;             
00137     unsigned short texX;
00138     unsigned short texY;
00139     unsigned short texYSize;
00140     
00141     unsigned short n_chars;
00142     char advancex;                   
00143     char advancey;                   
00144     unsigned char charmap_compr_len;
00145     unsigned short* charmap_compr;  
00146     unsigned short* charmap;            
00147     Glyph* glyph;                    
00148     GlyphBW* glyphBW;
00149     
00150     unsigned short n_shadows;
00151     unsigned char shadowscale;       
00152     Glyph* shadowGlyph;                 
00153     
00154     float size;
00155     unsigned int color;
00156     unsigned int shadowColor;
00157     unsigned int options;
00158 
00159     struct intraFont* altFont;
00160 } intraFont;
00161 int intraFontInit(void);
00162 void intraFontShutdown(void);
00163 intraFont* intraFontLoad(const char *filename,unsigned int options);
00164 void intraFontUnload(intraFont *font);
00165 void intraFontActivate(intraFont *font);
00166 void intraFontSetStyle(intraFont *font, float size, unsigned int color, unsigned int shadowColor, unsigned int options);
00167 void intraFontSetEncoding(intraFont *font, unsigned int options);
00168 void intraFontSetAltFont(intraFont *font, intraFont *altFont);
00169 float intraFontPrintUCS2        (intraFont *font, float x, float y, const unsigned short *text);
00170 float intraFontPrintUCS2Ex      (intraFont *font, float x, float y, const unsigned short *text, int length);
00171 float intraFontPrintColumnUCS2  (intraFont *font, float x, float y, float width, const unsigned short *text);
00172 float intraFontPrintColumnUCS2Ex(intraFont *font, float x, float y, float width, const unsigned short *text, int length);
00173 float intraFontPrint        (intraFont *font, float x, float y, const char *text);
00174 float intraFontPrintEx      (intraFont *font, float x, float y, const char *text, int length);
00175 float intraFontPrintColumn  (intraFont *font, float x, float y, float width, const char *text);
00176 float intraFontPrintColumnEx(intraFont *font, float x, float y, float width, const char *text, int length);
00177 float intraFontPrintf        (intraFont *font, float x, float y, const char *text, ...);
00178 float intraFontMeasureText  (intraFont *font, const char *text);
00179 float intraFontMeasureTextEx(intraFont *font, const char *text, int length);
00180 float intraFontMeasureTextUCS2  (intraFont *font, const unsigned short *text); 
00181 float intraFontMeasureTextUCS2Ex(intraFont *font, const unsigned short *text, int length); 
00182 #ifdef __cplusplus
00183 }
00184 #endif // __cplusplus
00185 
00186 #endif // __INTRAFONT_H__

DX Library Portableに対してTue Dec 22 07:43:44 2009に生成されました。  doxygen 1.6.1