const u8 *u8_get_file(const u8 *archive, const char *filename, u32 *size) { u32 i = 0; struct U8Header *arcHdr = open_u8_archive(archive); if (arcHdr == NULL) return NULL; const struct U8Entry *fst = (const struct U8Entry *)(archive + arcHdr->rootNodeOffset); for (i = 1; i < fst[0].numEntries; ++i) if (fst[i].fileType == 0 && strcasecmp(u8Filename(fst, i), filename) == 0) break; if (i >= fst[0].numEntries) return NULL; *size = fst[i].fileLength; return archive + fst[i].fileOffset; }
bool Theme::loadSystemFont(bool korean) { const char contentMapPath[] ATTRIBUTE_ALIGN(32) = "/shared1/content.map"; u8 *contentMap = NULL; u32 mapsize = 0; Nand::LoadFile(contentMapPath, &contentMap, &mapsize); if(!contentMap) return false; int fileCount = mapsize / sizeof(map_entry_t); map_entry_t *mapEntryList = (map_entry_t *) contentMap; for (int i = 0; i < fileCount; i++) { if (memcmp(mapEntryList[i].hash, korean ? WIIFONT_HASH_KOR : WIIFONT_HASH, 20) != 0) continue; //! Name found, load it and unpack it char font_filename[32] ATTRIBUTE_ALIGN(32); snprintf(font_filename, sizeof(font_filename), "/shared1/%.8s.app", mapEntryList[i].name); u8 *fontArchive = NULL; u32 filesize = 0; Nand::LoadFile(font_filename, &fontArchive, &filesize); if(!fontArchive) continue; const U8Header *u8Archive = (U8Header *) fontArchive; const U8Entry *fst = (const U8Entry *) (((const u8 *) u8Archive) + u8Archive->rootNodeOffset); if(fst[0].numEntries < 1) { free(fontArchive); continue; } if(systemFont) delete [] systemFont; systemFontSize = fst[1].fileLength; systemFont = new (std::nothrow) FT_Byte[systemFontSize]; if(!systemFont) { free(fontArchive); continue; } memcpy(systemFont, fontArchive + fst[1].fileOffset, systemFontSize); free(fontArchive); free(contentMap); gprintf("Loaded Wii System Font: %s\n", u8Filename(fst, 1)); return true; } free(contentMap); return false; }