//登録名・ファイルのパス・フォントの名前を指定 //ex ("HG96", "hoge.ttf", "Hogeman's_Font", 96, 5) void Font::LoadFont(std::string reg_name, std::string file_path, std::string font_name, int fontsize, int thick){ file_path = "Fonts/" + file_path; const char* filename = file_path.c_str(); // ファイルのサイズを得る int FontFileSize = FileRead_size(filename); // フォントファイルを開く int FontFileHandle = FileRead_open(filename); // フォントデータ格納用のメモリ領域を確保 void *Buffer = malloc(FontFileSize); // フォントファイルを丸ごとメモリに読み込む FileRead_read(Buffer, FontFileSize, FontFileHandle); // AddFontMemResourceEx引数用 DWORD font_num = 0; // メモリに読み込んだフォントデータをシステムに追加 if (AddFontMemResourceEx(Buffer, FontFileSize, NULL, &font_num) != 0){} else { // フォント読込エラー処理 MessageBox(NULL, "フォント読込失敗", "", MB_OK); } int tmp_handle = CreateFontToHandle(font_name.c_str(), fontsize, thick, DX_FONTTYPE_ANTIALIASING_4X4); handlemap.emplace(reg_name.c_str(), tmp_handle); }
static DXPTEXTURE3* LoadPngImage(const char *FileName) { u32 filesize; int fp = -1; DXPPNG png; DXPPNG_PARAMS params; void *buf = NULL; DXPTEXTURE3 *texptr = NULL; filesize = FileRead_size(FileName); if(!filesize)goto err; buf = malloc(filesize); if(!buf)goto err; texptr = dxpGraphicsCreateTexture(); if(!texptr)goto err; fp = FileRead_open(FileName,0); if(fp == 0)goto err; FileRead_read(buf,filesize,fp); FileRead_close(fp); params.funcs.pmalloc = malloc; params.funcs.pmemalign = memalign; params.funcs.pfree = free; params.mode = DXPPNG_MODE_GPU; params.src = buf; params.srcLength = filesize; if(dxppng_decode(¶ms,&png) == -1)goto err; texptr->alphabit = png.alpha ? 1 : 0; texptr->colorkey = dxpGraphicsData.colorkey; texptr->width = png.widthN2; texptr->height = png.heightN2; texptr->pitch = png.pitch; texptr->ppalette = (u32 *)png.clut; texptr->psm = png.psm; texptr->reloadflag = 1; texptr->size2_nflag = (png.height == png.heightN2 && png.width == png.widthN2 ? 1 : 0); texptr->swizzledflag = 0; texptr->texdata = png.raw; texptr->texvram = 0; texptr->umax = png.width; texptr->vmax = png.height; return texptr; err: FileRead_close(fp); free(buf); dxpGraphicsReleseTexture(texptr); return NULL; }