SDL_ttf庫顯示字體

顯示字體

	//初始化字體庫
	TTF_Init();
	//打開字體庫
	TTF_Font* m_titleFont = TTF_OpenFont("msyhbd.ttf", 100);
	/************************************
	設置字體的格式
	/* Set and retrieve the font style */
	#define TTF_STYLE_NORMAL        0x00
	#define TTF_STYLE_BOLD          0x01
	#define TTF_STYLE_ITALIC        0x02
	#define TTF_STYLE_UNDERLINE     0x04
	#define TTF_STYLE_STRIKETHROUGH 0x08
	****************************************/
	TTF_SetFontStyle(m_titleFont, TTF_STYLE_BOLD);  //加粗
	//字體顏色
	/*******************R****G**B**透明度****/
	SDL_Color color = { 255, 0, 0, 255 };
	char *m_Title ="1234";
	SDL_Surface* surface = TTF_RenderUTF8_Blended(m_titleFont, m_Title, color);
	m_titleTexture = SDL_CreateTextureFromSurface(m_sdlRenderer, surface);
	SDL_FreeSurface(surface);
	surface = NULL;
	SDL_RenderClear(m_sdlRenderer);
	SDL_RenderCopy(m_sdlRenderer, m_titleTexture, NULL, NULL);
	SDL_RenderPresent(m_sdlRenderer);
	//退出字體庫
	TTF_Quit();
發佈了15 篇原創文章 · 獲贊 6 · 訪問量 522
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章