void testCharGlyphImage(const char *title, FontHandle f, u16 charCode, GlyphImage *glyph, bool show) { if (show) { memset(glyph->buffer, 0, 80 * 20); } int result = sceFontGetCharGlyphImage(f, charCode, glyph); if (result == 0) { checkpoint("%s: OK", title); if (show) { const u8 *p = (const u8 *)glyph->buffer; for (int y = 0; y < 20; ++y) { schedf(" -> "); int linesize = 20; if (glyph->bytesPerLine > 2 && glyph->bytesPerLine <= 80) { linesize = glyph->bytesPerLine; } for (int x = 0; x < linesize; ++x) { schedf("%02x", *p++); } schedf("\n"); } } } else { checkpoint("%s: Failed (%08x)", title, result); } }
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; }
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; }