Exemple #1
0
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;
}
void testFallback() {
	sceFontSetAltCharacterCode(fontLib, 0);

	uint error;
	FontHandle font = sceFontOpenUserFile(fontLib, "ltn0.pgf", 1, &error);
	if (error != 0) {
		printf("TESTERROR: Unable to open font ltn0.pgf\n");
		return;
	}
	
	checkpointNext("Fallbacks:");
	FontCharInfo charInfo;
	int result;

	sceFontSetAltCharacterCode(fontLib, 0x0000);
	result = sceFontGetCharInfo(font, 0xFFFF, &charInfo);
	checkpoint("  sceFontGetCharInfo 0xFFFF (0x0000): %08x, %d", result, charInfo.bitmapHeight);

	sceFontSetAltCharacterCode(fontLib, 0x005F);
	result = sceFontGetCharInfo(font, 0xFFFF, &charInfo);
	checkpoint("  sceFontGetCharInfo 0xFFFF (0x005F): %08x, %d", result, charInfo.bitmapHeight);

	sceFontSetAltCharacterCode(fontLib, 0xFFFF);
	result = sceFontGetCharInfo(font, 0xFFFF, &charInfo);
	checkpoint("  sceFontGetCharInfo 0xFFFF (0xFFFF): %08x, %d", result, charInfo.bitmapHeight);

	sceFontClose(font);
}
Exemple #3
0
void vita2d_free_pgf(vita2d_pgf *font)
{
	if (font) {
		sceFontClose(font->font_handle);
		sceFontDoneLib(font->lib_handle);
		texture_atlas_free(font->tex_atlas);
		free(font);
	}
}
Exemple #4
0
void vita2d_free_pgf(vita2d_pgf *font)
{
	if (font) {
		vita2d_pgf_font_handle *tmp = font->font_handle_list;
		while (tmp) {
			sceFontClose(tmp->font_handle);
			free(tmp);
			tmp = tmp->next;
		}
		sceFontDoneLib(font->lib_handle);
		texture_atlas_free(font->atlas);
		free(font);
	}
}
extern "C" int main(int argc, char *argv[]) {
	if (!loadFontModule()) {
		return 1;
	}
	if (!loadFontHandles()) {
		return 1;
	}

	testGlyphParams();

	sceFontClose(font);
	sceFontDoneLib(fontLib);

	return 0;
}
bool loadFontHandles() {
	FontNewLibParams libParams;
	memset(&libParams, 0, sizeof(libParams));
	libParams.allocFuncAddr = allocQuiet;
	libParams.freeFuncAddr = freeQuiet;
	libParams.numFonts = 4;

	uint error = -1;
	fontLib = sceFontNewLib(&libParams, &error);

	font = sceFontOpenUserFile(fontLib, "ltn0.pgf", 1, &error);
	if (font <= 0) {
		printf("TEST ERROR: Unable to load ltn0.pgf\n");
		return false;
	}

	fontClosed = sceFontOpenUserFile(fontLib, "ltn0.pgf", 1, &error);
	sceFontClose(fontClosed);

	return true;
}
Exemple #7
0
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;
}