5 #include <Multimedia/SDX.h>
6 #include <Multimedia/Screen.h>
7 #include <Multimedia/IFont.h>
8 #include <Multimedia/SystemFont.h>
9 #include <Multimedia/Image.h>
10 #include <Multimedia/Window.h>
21 TTF_Font* handle =
nullptr;
29 FontOld(
const char *フォント名,
int 大きさ,
int 太さ = 1,
int 改行高さ = 0)
31 Load( フォント名 , 大きさ , 太さ , 改行高さ);
39 bool Load(
const char *フォント名,
int 大きさ ,
int 太さ = 1 ,
int 改行高さ = 0)
43 this->enterHeight = 改行高さ + 大きさ;
46 handle = TTF_OpenFont(フォント名,大きさ);
47 return (handle !=
nullptr);
53 if(handle !=
nullptr)
return false;
55 TTF_CloseFont(handle);
69 int 高さ = ((int)描画する文字列.
StringS.size()-1) * enterHeight + size;
72 std::vector<SDL_Surface*> surfaces;
76 SDL_Surface* surface = TTF_RenderUTF8_Blended(handle, it.c_str(), 文字色);
77 幅 = std::max(幅, surface->w);
78 surfaces.push_back( surface );
81 SDL_Surface* toRend = SDL_CreateRGBSurface(0, 幅, 高さ, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
82 SDL_Renderer* render = SDL_CreateSoftwareRenderer( toRend );
84 for (
auto it : surfaces)
86 SDL_Texture* texture = SDL_CreateTextureFromSurface( render , it);
88 SDL_Rect temp = { 0, Y座標, it->w, it->h };
89 SDL_RenderCopy( render , texture , 0, &temp);
91 Y座標 += this->enterHeight;
94 SDL_DestroyTexture( texture );
99 SDL_FreeSurface(toRend);
100 SDL_DestroyRenderer(render);
128 if( !handle )
return false;
136 for(
auto it : 描画する文字列.
StringS)
140 image = TTF_RenderUTF8_Blended(handle, it.c_str() , 描画色);
143 temp = { (int)座標.
x, y, image->w, image->h };
146 SDL_FreeSurface(image);
147 SDL_DestroyTexture(moji);
149 y += this->enterHeight;
168 if( !handle )
return false;
180 image = TTF_RenderUTF8_Blended(handle, it.c_str() , 描画色);
183 temp = { (int)座標.
x, y,
int(image->w * X軸拡大率), int(image->h * Y軸拡大率) };
186 SDL_FreeSurface(image);
187 SDL_DestroyTexture(moji);
190 y += int(this->enterHeight * Y軸拡大率);
double y
座標
Definition: Point.h:26
Fontのインターフェース.
Definition: IFont.h:12
Image MakeImage(Color 文字色, bool 反転フラグ, VariadicStream 描画する文字列) const
フォントから画像を生成
Definition: Font_Old.h:66
bool Load(const char *フォント名, int 大きさ, int 太さ=1, int 改行高さ=0)
メモリ上にフォントを作成する.
Definition: Font_Old.h:39
bool DrawRotate(const Point &座標, double 拡大率, double 角度, const Color &描画色, const VariadicStream &描画する文字列, bool 反転フラグ=false) const override
文字を回転して描画.
Definition: Font_Old.h:157
TTF_Font * GetHandle() const
フォントのハンドルを取得.
Definition: Font_Old.h:60
点を表す図形クラス.
Definition: Point.h:22
std::vector< std::string > StringS
一行ずつの文字列.
Definition: VariadicStream.h:53
旧フォントクラス.
Definition: Font_Old.h:18
bool DrawRotate(const Point &座標, double 拡大率, double 角度, bool 反転フラグ=false) const override
角度、拡大率を指定して描画.
Definition: Image.h:229
画像データを表すクラス.
Definition: Image.h:17
色を表すクラス.
Definition: Color.h:11
int Getthick() const
太さを取得.
Definition: Font_Old.h:112
int GetDrawStringWidth(VariadicStream 幅を計算する文字列) const
描画時の幅を取得[DXLIB].
Definition: Font_Old.h:118
bool Release()
イメージをメモリから開放.
Definition: Image.h:109
static SDL_Renderer * GetHandle()
スクリーンハンドルを取得.
Definition: Screen.h:26
bool Draw(const Point &座標, const Color &描画色, const VariadicStream &描画する文字列, bool 反転フラグ=false) const override
文字を描画.
Definition: Font_Old.h:126
可変数引数な文字列を処理するクラス.
Definition: VariadicStream.h:25
double x
座標
Definition: Point.h:25
int GetSize() const
大きさを取得.
Definition: Font_Old.h:106
bool Release() const
フォントをメモリから開放する.
Definition: Font_Old.h:51
bool DrawExtend(const Point &座標, double X軸拡大率, double Y軸拡大率, const Color &描画色, const VariadicStream &描画する文字列, bool 反転フラグ=false) const override
拡大率を指定して文字を描画.
Definition: Font_Old.h:166
FontOld(const char *フォント名, int 大きさ, int 太さ=1, int 改行高さ=0)
デフォルトコンストラクタ.
Definition: Font_Old.h:29