2 #include <Multimedia/SDX.h>
3 #include <Multimedia/Screen.h>
4 #include <Multimedia/IFont.h>
12 Normal = DX_FONTTYPE_NORMAL,
13 Edge = DX_FONTTYPE_EDGE,
14 AntiAliase = DX_FONTTYPE_ANTIALIASING,
15 AntiAliaseEdge = DX_FONTTYPE_ANTIALIASING_EDGE,
25 class Font :
public IFont
29 FontHandle handle = NULL_HANDLE;
37 Font(
const char *フォント名,
int 大きさ ,
int 太さ ,
int 改行高さ, FontType フォントタイプ = FontType::Normal)
39 Font::Load( フォント名 , 大きさ , 太さ , 改行高さ , フォントタイプ);
43 bool Load(
const char *フォント名,
int 大きさ ,
int 太さ ,
int 改行高さ, FontType フォントタイプ = FontType::Normal)
49 this->enterHeight = 改行高さ + 大きさ;
52 this->handle = DxLib::CreateFontToHandle(フォント名,大きさ,太さ,(
int)フォントタイプ);
53 return ( handle != -1 );
55 handle = TTF_OpenFont(フォント名,大きさ);
63 if(handle != NULL_HANDLE)
return false;
65 return !DxLib::DeleteFontToHandle(this->handle);
67 TTF_CloseFont(handle);
98 vsprintf_s(bufstr, 1024, 文字列, args);
101 return DxLib::GetDrawStringWidthToHandle(bufstr,strlen(bufstr),this->handle);
108 bool Draw(
int X座標 ,
int Y座標 ,
Color 色 ,
const char *描画文字列 , ...)
const
113 va_start(args, 描画文字列);
114 vsprintf_s(bufstr, 1024, 描画文字列, args);
118 stro = strtok_s(bufstr,
"\n",&pstr);
123 DxLib::DrawStringToHandle(X座標, Y座標, stro, 色, handle);
124 stro = strtok_s(NULL,
"\n",&pstr);
125 Y座標 += this->enterHeight;
136 mbstowcs_s(&ret,wc,100, stro,_TRUNCATE);
138 for (
unsigned int i = 0; i < strlen(stro); ++i)
143 image = TTF_RenderUNICODE_Blended(handle, text, 色);
144 moji = SDL_CreateTextureFromSurface(Screen::GetHandle(), image);
145 temp = { X座標, Y座標, image->w, image->h };
146 SDL_RenderCopy(Screen::GetHandle(), moji, 0, &temp);
148 stro = strtok_s(NULL,
"\n", &pstr);
149 Y座標 += this->enterHeight;
150 SDL_FreeSurface(image);
151 SDL_DestroyTexture(moji);
158 bool ZMask(
int X座標 ,
int Y座標 , ZMaskType Zマスクタイプ ,
const char *str , ...)
const
165 vsprintf_s( bufstr , 1024 ,str, args );
169 strcpy_s(bufstr,1024,str);
171 stro = strtok_s(bufstr,
"\n",&pstr);
175 DxLib::DrawStringToHandleToZBuffer(X座標,Y座標,stro,handle, (
int)Zマスクタイプ);
176 stro = strtok_s(NULL,
"\n",&pstr);
177 Y座標 += this->enterHeight;
187 bool DrawExtend(
int X座標,
int Y座標,
double X拡大率,
double Y拡大率 ,
Color 描画色,
const char *描画文字列, ...)
const
191 va_start(args,描画文字列);
192 vsprintf_s(bufstr, 1024, 描画文字列, args);
196 strcpy_s(bufstr, 1024, 描画文字列);
198 stro = strtok_s(bufstr,
"\n",&pstr);
202 DxLib::DrawExtendStringToHandle(X座標,Y座標,X拡大率 , Y拡大率 , stro , 描画色, handle );
203 stro = strtok_s(NULL,
"\n",&pstr);
204 Y座標 += int( this->enterHeight * Y拡大率 );
215 mbstowcs_s(&ret, wc, 100, stro, _TRUNCATE);
217 for (
unsigned int i = 0; i < strlen(stro); ++i)
222 image = TTF_RenderUNICODE_Blended(handle, text, 描画色);
223 moji = SDL_CreateTextureFromSurface(Screen::GetHandle(), image);
224 temp = { X座標, Y座標, int(image->w * X拡大率), int(image->h * Y拡大率) };
226 SDL_RenderCopy(Screen::GetHandle(), moji, 0, &temp);
228 stro = strtok_s(NULL,
"\n", &pstr);
229 Y座標 += int(this->enterHeight * Y拡大率);
230 SDL_FreeSurface(image);
231 SDL_DestroyTexture(moji);
236 bool ZMaskExtend(
int X座標,
int Y座標,
double X拡大率,
double Y拡大率, ZMaskType Zマスクタイプ,
const char *str, ...)
const
242 vsprintf_s( bufstr , 1024 ,str, args );
246 strcpy_s(bufstr,1024,str);
248 stro = strtok_s(bufstr,
"\n",&pstr);
252 DxLib::DrawExtendStringToHandleToZBuffer(X座標, Y座標, X拡大率, Y拡大率, stro, handle, (
int)Zマスクタイプ);
253 stro = strtok_s(NULL,
"\n",&pstr);
254 Y座標 += this->enterHeight;
FontHandle GetHandle() const
フォントのハンドルを取得.
Definition: Font.h:73
bool DrawExtend(int X座標, int Y座標, double X拡大率, double Y拡大率, Color 描画色, const char *描画文字列,...) const
拡大率を指定して文字を描画.
Definition: Font.h:187
bool Load(const char *フォント名, int 大きさ, int 太さ, int 改行高さ, FontType フォントタイプ=FontType::Normal)
メモリ上にフォントを作成する.
Definition: Font.h:45
int GetSize() const
大きさを取得.
Definition: Font.h:79
色を表すクラス.
Definition: Color.h:7
int Getthick() const
太さを取得.
Definition: Font.h:85
int GetDrawStringWidth(const char *文字列,...) const
描画時の幅を取得.
Definition: Font.h:91
bool Release() const
フォントをメモリから開放する.
Definition: Font.h:61
bool Draw(int X座標, int Y座標, Color 色, const char *描画文字列,...) const
書式付きで文字を描画.
Definition: Font.h:108