vita2d_pgf *vita2d_load_system_pgf(int numFonts, const vita2d_system_pgf_config *configs) { if (numFonts < 1) { return NULL; } unsigned int error; vita2d_pgf *font = vita2d_load_pgf_pre(numFonts); if (!font) return NULL; SceFontStyle style = {0}; style.fontH = 10; style.fontV = 10; vita2d_pgf_font_handle *tmp = NULL; for (int i = 0; i < numFonts; i++) { style.fontLanguage = configs[i].code; int index = sceFontFindOptimumFont(font->lib_handle, &style, &error); if (error != 0) goto cleanup; SceFontHandle handle = sceFontOpen(font->lib_handle, index, 0, &error); if (error != 0) goto cleanup; if (font->font_handle_list == NULL) { tmp = font->font_handle_list = malloc(sizeof(vita2d_pgf_font_handle)); } else { tmp = tmp->next = malloc(sizeof(vita2d_pgf_font_handle)); } if (!tmp) { sceFontClose(handle); goto cleanup; } memset(tmp, 0, sizeof(vita2d_pgf_font_handle)); tmp->font_handle = handle; tmp->in_font_group = configs[i].in_font_group; } vita2d_load_pgf_post(font); return font; cleanup: tmp = font->font_handle_list; while (tmp) { sceFontClose(tmp->font_handle); free(tmp); tmp = tmp->next; } sceFontDoneLib(font->lib_handle); free(font); return NULL; }
int load(SceSize args, void *argp){ int stat,modid; if(sceKernelStartModule(modid=sceKernelLoadModule("flash0:/vsh/module/libfont_hv.prx",0,NULL),0,NULL,&stat,NULL)<0)return -__LINE__; int errorCode; InitParam initParams = {NULL,4,NULL,myMalloc,myFree,NULL,NULL,NULL,NULL,NULL,NULL}; void* libID = sceFontNewLib(&initParams, &errorCode);if(errorCode)return -__LINE__; void* fontID = sceFontOpen(libID, FONT(BOLD), FILE, &errorCode);if(errorCode)return -__LINE__; memset((void*)0x44000000,0,4*512*16); //print build date printchar(fontID, __DATE__" "__TIME__);//on vram sceIoWrite(2,__DATE__" "__TIME__,11+1+8);//on cout if(sceFontClose(fontID)) return -__LINE__; if(sceFontDoneLib(libID)) return -__LINE__; sceKernelStopModule(modid,0,NULL,&stat,NULL); sceKernelUnloadModule(modid); sceKernelSelfStopUnloadModule(1,0,NULL); return 0; }
vita2d_pgf *vita2d_load_default_pgf() { unsigned int error; vita2d_pgf *font = malloc(sizeof(*font)); if (!font) return NULL; SceFontNewLibParams params = { font, 1, NULL, pgf_alloc_func, pgf_free_func, NULL, NULL, NULL, NULL, NULL, NULL }; font->lib_handle = sceFontNewLib(¶ms, &error); if (error != 0) { free(font); return NULL; } font->font_handle = sceFontOpen(font->lib_handle, 1, 0, &error); if (error != 0) { sceFontDoneLib(font->lib_handle); free(font); return NULL; } font->tex_atlas = texture_atlas_create(ATLAS_DEFAULT_W, ATLAS_DEFAULT_H, SCE_GXM_TEXTURE_FORMAT_U8_R111); return font; }
int main(int argc, char *argv[]) { FontLibraryHandle libHandle; FontHandle fontHandle; //FontInfo fontInfo; //int result; u32 errorCode; FontNewLibParams params = { NULL, 4, NULL, Font_Alloc, Font_Free, NULL, NULL, NULL, NULL, NULL, NULL }; //pspDebugScreenInit(); printf("Starting fonttest...\n"); libHandle = sceFontNewLib(¶ms, &errorCode); printf("sceFontNewLib: %d, %08X\n", libHandle != 0, errorCode); fontHandle = sceFontOpen(libHandle, 0, 0777, &errorCode); printf("sceFontOpen: %d, %08X\n", fontHandle != 0, errorCode); /* result = sceFontGetFontInfo(fontHandle, &fontInfo); printf("sceFontGetFontInfo: %d\n", result); #define PRINT_GLYPH_METRICS_MAX(TYPE) printf("fontInfo.max" #TYPE ": %d, %f\n", fontInfo.max## TYPE ## I, fontInfo.max## TYPE ## F); #define PRINT_GLYPH_METRICS_MIN(TYPE) printf("fontInfo.min" #TYPE ": %d, %f\n", fontInfo.min## TYPE ## I, fontInfo.min## TYPE ## F); PRINT_GLYPH_METRICS_MAX(GlyphWidth); PRINT_GLYPH_METRICS_MAX(GlyphHeight); PRINT_GLYPH_METRICS_MAX(GlyphAscender); PRINT_GLYPH_METRICS_MAX(GlyphDescender); PRINT_GLYPH_METRICS_MAX(GlyphLeftX); PRINT_GLYPH_METRICS_MAX(GlyphBaseY); PRINT_GLYPH_METRICS_MIN(GlyphCenterX); PRINT_GLYPH_METRICS_MAX(GlyphTopY); PRINT_GLYPH_METRICS_MAX(GlyphAdvanceX); PRINT_GLYPH_METRICS_MAX(GlyphAdvanceY); */ return 0; }