PSP2SDK
dirty-f9e4f2d
The free SDK for PSP2
|
00001 00012 #ifndef _PSP2_PGF_H_ 00013 #define _PSP2_PGF_H_ 00014 00015 #include <psp2/types.h> 00016 #include <stdint.h> 00017 00018 #ifdef __cplusplus 00019 extern "C" { 00020 #endif 00021 00022 /* typedef */ 00023 00024 typedef SceUID SceFontLibHandle; 00025 typedef SceUID SceFontHandle; 00026 00027 /* struct */ 00028 00029 enum { 00030 SCE_FONT_ERROR_OUT_OF_MEMORY = 0x80460001, 00031 SCE_FONT_ERROR_INVALID_LIBID = 0x80460002, 00032 SCE_FONT_ERROR_INVALID_PARAMETER = 0x80460003, 00033 SCE_FONT_ERROR_HANDLER_OPEN_FAILED = 0x80460005, 00034 SCE_FONT_ERROR_TOO_MANY_OPEN_FONTS = 0x80460009, 00035 SCE_FONT_ERROR_INVALID_FONT_DATA = 0x8046000a, 00036 }; 00037 00038 typedef struct SceSceFontNewLibParams { 00039 void *userData; 00040 unsigned int numFonts; 00041 void *cacheData; 00042 00043 // Driver callbacks. 00044 void *(*allocFunc)(void *, unsigned int); 00045 void (*freeFunc)(void *, void *); 00046 void *openFunc; 00047 void *closeFunc; 00048 void *readFunc; 00049 void *seekFunc; 00050 void *errorFunc; 00051 void *ioFinishFunc; 00052 } SceFontNewLibParams; 00053 00054 typedef enum FontFamily { 00055 FONT_FAMILY_SANS_SERIF = 1, 00056 FONT_FAMILY_SERIF = 2, 00057 } FontFamily; 00058 00059 typedef enum FontStyle { 00060 FONT_STYLE_REGULAR = 1, 00061 FONT_STYLE_ITALIC = 2, 00062 FONT_STYLE_BOLD = 5, 00063 FONT_STYLE_BOLD_ITALIC = 6, 00064 FONT_STYLE_DB = 103, // Demi-Bold / semi-bold 00065 } FontStyle; 00066 00067 typedef enum FontLanguage { 00068 FONT_LANGUAGE_JAPANESE = 1, 00069 FONT_LANGUAGE_LATIN = 2, 00070 FONT_LANGUAGE_KOREAN = 3, 00071 FONT_LANGUAGE_CHINESE = 4, 00072 }FontLanguage; 00073 00074 typedef enum FontPixelFormat { 00075 FONT_PIXELFORMAT_4 = 0, // 2 pixels packed in 1 byte (natural order) 00076 FONT_PIXELFORMAT_4_REV = 1, // 2 pixels packed in 1 byte (reversed order) 00077 FONT_PIXELFORMAT_8 = 2, // 1 pixel in 1 byte 00078 FONT_PIXELFORMAT_24 = 3, // 1 pixel in 3 bytes (RGB) 00079 FONT_PIXELFORMAT_32 = 4, // 1 pixel in 4 bytes (RGBA) 00080 } FontPixelFormat; 00081 00082 typedef struct SceFontImageRect { 00083 short width; 00084 short height; 00085 } SceFontImageRect; 00086 00087 typedef struct SceFontGlyphImage { 00088 FontPixelFormat pixelFormat; 00089 int xPos64; 00090 int yPos64; 00091 unsigned short bufWidth; 00092 unsigned short bufHeight; 00093 unsigned short bytesPerLine; 00094 unsigned short pad; 00095 unsigned int bufferPtr; 00096 } SceFontGlyphImage; 00097 00098 typedef struct SceFontStyle { 00099 float fontH; 00100 float fontV; 00101 float fontHRes; 00102 float fontVRes; 00103 float fontWeight; 00104 unsigned short fontFamily; 00105 unsigned short fontStyle; 00106 // Check. 00107 unsigned short fontStyleSub; 00108 unsigned short fontLanguage; 00109 unsigned short fontRegion; 00110 unsigned short fontCountry; 00111 char fontName[64]; 00112 char fontFileName[64]; 00113 unsigned int fontAttributes; 00114 unsigned int fontExpire; 00115 } SceFontStyle; 00116 00117 typedef struct SceFontCharInfo { 00118 unsigned int bitmapWidth; 00119 unsigned int bitmapHeight; 00120 unsigned int bitmapLeft; 00121 unsigned int bitmapTop; 00122 // Glyph metrics (in 26.6 signed fixed-point). 00123 unsigned int sfp26Width; 00124 unsigned int sfp26Height; 00125 int sfp26Ascender; 00126 int sfp26Descender; 00127 int sfp26BearingHX; 00128 int sfp26BearingHY; 00129 int sfp26BearingVX; 00130 int sfp26BearingVY; 00131 int sfp26AdvanceH; 00132 int sfp26AdvanceV; 00133 short shadowFlags; 00134 short shadowId; 00135 } SceFontCharInfo; 00136 00137 typedef struct SceFontInfo { 00138 // Glyph metrics (in 26.6 signed fixed-point). 00139 unsigned int maxGlyphWidthI; 00140 unsigned int maxGlyphHeightI; 00141 unsigned int maxGlyphAscenderI; 00142 unsigned int maxGlyphDescenderI; 00143 unsigned int maxGlyphLeftXI; 00144 unsigned int maxGlyphBaseYI; 00145 unsigned int minGlyphCenterXI; 00146 unsigned int maxGlyphTopYI; 00147 unsigned int maxGlyphAdvanceXI; 00148 unsigned int maxGlyphAdvanceYI; 00149 00150 // Glyph metrics (replicated as float). 00151 float maxGlyphWidthF; 00152 float maxGlyphHeightF; 00153 float maxGlyphAscenderF; 00154 float maxGlyphDescenderF; 00155 float maxGlyphLeftXF; 00156 float maxGlyphBaseYF; 00157 float minGlyphCenterXF; 00158 float maxGlyphTopYF; 00159 float maxGlyphAdvanceXF; 00160 float maxGlyphAdvanceYF; 00161 00162 // Bitmap dimensions. 00163 short maxGlyphWidth; 00164 short maxGlyphHeight; 00165 unsigned int charMapLength; // Number of elements in the font's charmap. 00166 unsigned int shadowMapLength; // Number of elements in the font's shadow charmap. 00167 00168 // Font style (used by font comparison functions). 00169 SceFontStyle fontStyle; 00170 00171 uint8_t BPP; // Font's BPP. 00172 uint8_t pad[3]; 00173 } SceFontInfo; 00174 00175 /* prototypes */ 00176 00177 SceFontLibHandle sceFontNewLib(SceFontNewLibParams *params, unsigned int *errorCode); 00178 int sceFontDoneLib(SceFontLibHandle libHandle); 00179 00180 SceFontHandle sceFontOpen(SceFontLibHandle libHandle, 00181 int index, int mode, unsigned int *errorCode); 00182 00183 SceFontHandle sceFontOpenUserMemory(SceFontLibHandle libHandle, 00184 void *pMemoryFont, SceSize pMemoryFontSize, unsigned int *errorCode); 00185 00186 SceFontHandle sceFontOpenUserFile(SceFontLibHandle libHandle, 00187 char *file, int mode, unsigned int *errorCode); 00188 00189 int sceFontClose(SceFontHandle fontHandle); 00190 00191 int sceFontGetNumFontList(SceFontLibHandle libHandle, unsigned int *errorCode); 00192 00193 int sceFontFindOptimumFont(SceFontLibHandle libHandle, 00194 SceFontStyle *fontStyle, unsigned int *errorCode); 00195 00196 int sceFontFindFont(SceFontLibHandle libHandle, 00197 SceFontStyle *fontStyle, unsigned int *errorCode); 00198 00199 int sceFontGetFontInfo(SceFontHandle fontHandle, SceFontInfo *fontInfo); 00200 00201 int sceFontGetFontInfoByIndexNumber(SceFontLibHandle libHandle, 00202 SceFontStyle *fontStyle, int unknown, int fontIndex); 00203 00204 int sceFontSetResolution(SceFontLibHandle libHandle, float hRes, float vRes); 00205 00206 int sceFontGetFontList(SceFontLibHandle libHandle, 00207 SceFontStyle *fontStyle, int numFonts); 00208 00209 int sceFontGetCharInfo(SceFontHandle fontHandle, 00210 unsigned int charCode, SceFontCharInfo *charInfo); 00211 00212 int sceFontGetCharImageRect(SceFontHandle fontHandle, 00213 unsigned int charCode, SceFontImageRect *charRect); 00214 00215 int sceFontGetCharGlyphImage(SceFontHandle fontHandle, 00216 unsigned int charCode, SceFontGlyphImage *glyphImage); 00217 00218 int sceFontGetCharGlyphImage_Clip(SceFontHandle fontHandle, 00219 unsigned int charCode, SceFontGlyphImage *glyphImage, 00220 int clipXPos, int clipYPos, int clipWidth, int clipHeight); 00221 00222 float sceFontPixelToPointH(SceFontLibHandle libHandle, 00223 float fontPixelsH, unsigned int *errorCode); 00224 00225 float sceFontPixelToPointV(SceFontLibHandle libHandle, 00226 float fontPixelsV, unsigned int *errorCode); 00227 00228 float sceFontPointToPixelH(SceFontLibHandle libHandle, 00229 float fontPointsH, unsigned int *errorCode); 00230 00231 float sceFontPointToPixelV(SceFontLibHandle libHandle, 00232 float fontPointsV, unsigned int *errorCode); 00233 00234 int sceFontSetAltCharacterCode(SceFontLibHandle libHandle, unsigned int charCode); 00235 00236 int sceFontFlush(SceFontHandle fontHandle); 00237 00238 #ifdef __cplusplus 00239 } 00240 #endif 00241 00242 #endif /* _PSP2_PGF_H_ */