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); }
static int atlas_add_glyph_pgf(vita2d_pgf *font, unsigned int character) { SceFontCharInfo char_info; if (sceFontGetCharInfo(font->font_handle, character, &char_info) < 0) return 0; int pos_x; int pos_y; if (!texture_atlas_insert(font->tex_atlas, character, char_info.bitmapWidth, char_info.bitmapHeight, char_info.bitmapLeft, char_info.bitmapTop, char_info.sfp26AdvanceH, char_info.sfp26AdvanceV, 0, &pos_x, &pos_y)) return 0; vita2d_texture *tex = font->tex_atlas->tex; SceFontGlyphImage glyph_image; glyph_image.pixelFormat = SCE_FONT_PIXELFORMAT_8; glyph_image.xPos64 = pos_x << 6; glyph_image.yPos64 = pos_y << 6; glyph_image.bufWidth = vita2d_texture_get_width(tex); glyph_image.bufHeight = vita2d_texture_get_height(tex); glyph_image.bytesPerLine = vita2d_texture_get_stride(tex); glyph_image.pad = 0; glyph_image.bufferPtr = (unsigned int)vita2d_texture_get_datap(tex); return sceFontGetCharGlyphImage(font->font_handle, character, &glyph_image) == 0; }
static int atlas_add_glyph(vita2d_pgf *font, unsigned int character) { SceFontHandle font_handle = font->font_handle_list->font_handle; SceFontCharInfo char_info; bp2d_position position; void *texture_data; vita2d_texture *tex = font->atlas->texture; vita2d_pgf_font_handle *tmp = font->font_handle_list; while (tmp) { if (tmp->in_font_group == NULL || tmp->in_font_group(character)) { font_handle = tmp->font_handle; break; } tmp = tmp->next; } if (sceFontGetCharInfo(font_handle, character, &char_info) < 0) return 0; bp2d_size size = { char_info.bitmapWidth, char_info.bitmapHeight }; texture_atlas_entry_data data = { char_info.bitmapLeft, char_info.bitmapTop, char_info.sfp26AdvanceH, char_info.sfp26AdvanceV, 0 }; if (!texture_atlas_insert(font->atlas, character, &size, &data, &position)) return 0; texture_data = vita2d_texture_get_datap(tex); SceFontGlyphImage glyph_image; glyph_image.pixelFormat = SCE_FONT_PIXELFORMAT_8; glyph_image.xPos64 = position.x << 6; glyph_image.yPos64 = position.y << 6; glyph_image.bufWidth = vita2d_texture_get_width(tex); glyph_image.bufHeight = vita2d_texture_get_height(tex); glyph_image.bytesPerLine = vita2d_texture_get_stride(tex); glyph_image.pad = 0; glyph_image.bufferPtr = (unsigned int)texture_data; return sceFontGetCharGlyphImage(font_handle, character, &glyph_image) == 0; }
void testCharInfo(const char *title, FontHandle f, u16 charCode, FontCharInfo *charInfo) { if (charInfo) { charInfo->bitmapWidth = -1; charInfo->bitmapHeight = -1; } int result = sceFontGetCharInfo(f, charCode, charInfo); if (result == 0) { checkpoint(NULL); schedf("%s: OK ", title); schedfCharInfo(charInfo); } else { checkpoint("%s: Failed (%08x)", title, result); } }
int printchar(void* fontID,char*str){ int i=0,x=0; while(str[i]){ if(str[i]==' '){ x+=4*3; i++; continue; } unsigned short charCode = str[i]; CharInfo charInfo; if(sceFontGetCharInfo(fontID, charCode, &charInfo)) return -__LINE__; Image myImage={PSP_FONT_32BIT}; myImage.psm = PSP_FONT_32BIT; myImage.rect.width = MYIMAGE_WIDTH; myImage.rect.height = MYIMAGE_HEIGHT; myImage.tbw = MYIMAGE_WIDTH * MYIMAGE_BPP; myImage.buffer = (void*)0x44000000+x*4+(MYIMAGE_HEIGHT-charInfo.top)*4*512;//malloc(MYIMAGE_SIZE); myImage.x = 0; myImage.y = 0; // RGBA2ARGB((void*)0x44000000,MYIMAGE_SIZE); //sceFontSetResolution(fontID,1,1); if(sceFontGetCharGlyphImage(fontID, charCode, &myImage)) return -__LINE__; x+=charInfo.width+1; i++; } RGBA2GREY((void*)0x44000000,MYIMAGE_SIZE); return 0; }
void testGlyphParams() { FontCharInfo charInfo; checkpointNext("Fonts:"); testCharInfo(" Normal", font, 'A', &charInfo); testCharInfo(" NULL", 0, 'A', &charInfo); testCharInfo(" Closed", fontClosed, 'A', &charInfo); checkpointNext("Characters:"); testCharInfo(" NUL", font, 0, &charInfo); testCharInfo(" SOH", font, 1, &charInfo); testCharInfo(" BEL", font, 7, &charInfo); testCharInfo(" 0xD7FF", font, 0xD7FF, &charInfo); testCharInfo(" 0xFFFE", font, 0xFFFE, &charInfo); testCharInfo(" 0xFFFF", font, 0xFFFF, &charInfo); checkpointNext("Info:"); testCharInfo(" Missing", font, 'A', NULL); u32 data[18]; memset(data, 0xdd, sizeof(data)); sceFontGetCharInfo(font, 'A', (FontCharInfo *)data); checkpoint(" Data size: %08x %08x %08x %08x", data[14], data[15], data[16], data[17]); }