2 #include <Multimedia/SDX.h>
3 #include <Multimedia/Screen.h>
4 #include <Multimedia/IFont.h>
5 #include <Multimedia/SystemFont.h>
6 #include <Multimedia/Image.h>
7 #include <Multimedia/Window.h>
26 FontHandle handle = NULL_HANDLE;
33 Font(
const char *フォント名,
int 大きさ ,
int 太さ = 1 ,
int 改行高さ = 0 ,
FontType フォントタイプ = FontType::Normal)
35 Font::Load( フォント名 , 大きさ , 太さ , 改行高さ , フォントタイプ);
43 bool Load(
const char *フォント名,
int 大きさ ,
int 太さ = 1 ,
int 改行高さ = 0,
FontType フォントタイプ = FontType::Normal)
47 this->enterHeight = 改行高さ + 大きさ;
50 handle = TTF_OpenFont(フォント名,大きさ);
51 return (handle !=
nullptr);
57 if(handle !=
nullptr)
return false;
59 TTF_CloseFont(handle);
74 int 高さ = ((int)描画する文字列.StringS.size()-1) * enterHeight + size;
77 std::vector<SDL_Surface*> surfaces;
79 for (
auto it : 描画する文字列.StringS)
81 SDL_Surface* surface = TTF_RenderUTF8_Blended(handle, it.c_str(), 文字色);
82 幅 = std::max(幅, surface->w);
83 surfaces.push_back( surface );
86 SDL_Surface* toRend = SDL_CreateRGBSurface(0, 幅, 高さ, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
87 SDL_Renderer* render = SDL_CreateSoftwareRenderer( toRend );
89 for (
auto it : surfaces)
91 SDL_Texture* texture = SDL_CreateTextureFromSurface( render , it);
93 SDL_Rect temp = { 0, Y座標, it->w, it->h };
94 SDL_RenderCopy( render , texture , 0, &temp);
96 Y座標 += this->enterHeight;
99 SDL_DestroyTexture( texture );
108 SDL_FreeSurface(toRend);
109 SDL_DestroyRenderer(render);
137 if( !handle )
return false;
143 for(
auto it : 描画する文字列.StringS)
147 image = TTF_RenderUTF8_Blended(handle, it.c_str() , 色);
150 temp = { X座標, Y座標, image->w, image->h };
153 SDL_FreeSurface(image);
154 SDL_DestroyTexture(moji);
156 Y座標 += this->enterHeight;
181 文字イメージ.
ZMaskRotate(X座標, Y座標, 拡大率, 角度, Zマスクタイプ, 反転フラグ);
189 if( !handle )
return false;
194 for (
auto it:描画する文字列.StringS)
198 image = TTF_RenderUTF8_Blended(handle, it.c_str() , 描画色);
201 temp = { X座標, Y座標, int(image->w * X拡大率), int(image->h * Y拡大率) };
204 SDL_FreeSurface(image);
205 SDL_DestroyTexture(moji);
208 Y座標 += int(this->enterHeight * Y拡大率);
ZMaskType
Zマスクの種類.
Definition: Image.h:8
Font,BmpFont等のインターフェース.
Definition: IFont.h:9
bool ZMaskRotate(int X座標, int Y座標, double 拡大率, double 角度, ZMaskType Zマスクタイプ, bool 反転フラグ=false) const
角度、拡大率を指定してマスク[DXLIB].
Definition: Image.h:205
bool DrawRotate(int X座標, int Y座標, double 拡大率, double 角度, Color 描画色, bool 反転フラグ, VariadicStream 描画する文字列) const
文字を回転して描画.
Definition: Font.h:169
FontHandle GetHandle() const
フォントのハンドルを取得.
Definition: Font.h:64
フォントデータを表すクラス.
Definition: Font.h:23
int GetDrawStringWidth(VariadicStream 幅を計算する文字列) const
描画時の幅を取得[DXLIB].
Definition: Font.h:127
int GetSize() const
大きさを取得.
Definition: Font.h:115
bool ZMask(int X座標, int Y座標, ZMaskType Zマスクタイプ, VariadicStream 描画する文字列) const
文字をマスク[DXLIB].
Definition: Font.h:162
画像データを表すクラス.
Definition: Image.h:37
色を表すクラス.
Definition: Color.h:7
int Getthick() const
太さを取得.
Definition: Font.h:121
bool Release() const
フォントをメモリから開放する.
Definition: Font.h:55
bool DrawExtend(int X座標, int Y座標, double X拡大率, double Y拡大率, Color 描画色, VariadicStream 描画する文字列) const
拡大率を指定して文字を描画.
Definition: Font.h:187
bool Release()
イメージをメモリから開放.
Definition: Image.h:112
可変数引数な文字列を処理するクラス.
Definition: VariadicStream.h:8
Image MakeImage(Color 文字色, bool 反転フラグ, VariadicStream 描画する文字列) const
フォントから画像を生成
Definition: Font.h:70
bool ZMaskRotate(int X座標, int Y座標, double 拡大率, double 角度, ZMaskType Zマスクタイプ, bool 反転フラグ, VariadicStream 描画する文字列) const
文字を回転してマスク[DXLIB].
Definition: Font.h:178
FontType
フォントの種類.
Definition: Font.h:12
bool Draw(int X座標, int Y座標, Color 色, VariadicStream 描画する文字列) const
文字を描画.
Definition: Font.h:135
bool Load(const char *フォント名, int 大きさ, int 太さ=1, int 改行高さ=0, FontType フォントタイプ=FontType::Normal)
メモリ上にフォントを作成する.
Definition: Font.h:43
bool ZMaskExtend(int X座標, int Y座標, double X拡大率, double Y拡大率, ZMaskType Zマスクタイプ, VariadicStream 描画する文字列) const
拡大率を指定して文字をマスク[DXLIB].
Definition: Font.h:214
static ScreenHandle GetHandle()
スクリーンハンドルを取得.
Definition: Screen.h:49
bool DrawRotate(int X座標, int Y座標, double 拡大率, double 角度, bool 反転フラグ=false) const
角度、拡大率を指定して描画.
Definition: Image.h:195