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;
28 FontOld(
const char *フォント名,
int 大きさ,
int 太さ = 1,
int 改行高さ = 0)
30 Load( フォント名 , 大きさ , 太さ , 改行高さ);
38 bool Load(
const char *フォント名,
int 大きさ ,
int 太さ = 1 ,
int 改行高さ = 0)
42 this->enterHeight = 改行高さ + 大きさ;
45 handle = TTF_OpenFont(フォント名,大きさ);
46 return (handle !=
nullptr);
52 if(handle !=
nullptr)
return false;
54 TTF_CloseFont(handle);
68 int 高さ = ((int)描画する文字列.
StringS.size()-1) * enterHeight + size;
71 std::vector<SDL_Surface*> surfaces;
75 SDL_Surface* surface = TTF_RenderUTF8_Blended(handle, it.c_str(), 文字色);
76 幅 = std::max(幅, surface->w);
77 surfaces.push_back( surface );
80 SDL_Surface* toRend = SDL_CreateRGBSurface(0, 幅, 高さ, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
81 SDL_Renderer* render = SDL_CreateSoftwareRenderer( toRend );
83 for (
auto it : surfaces)
85 SDL_Texture* texture = SDL_CreateTextureFromSurface( render , it);
87 SDL_Rect temp = { 0, Y座標, it->w, it->h };
88 SDL_RenderCopy( render , texture , 0, &temp);
90 Y座標 += this->enterHeight;
93 SDL_DestroyTexture( texture );
98 SDL_FreeSurface(toRend);
99 SDL_DestroyRenderer(render);
127 if( !handle )
return false;
135 for(
auto it : 描画する文字列.
StringS)
139 image = TTF_RenderUTF8_Blended(handle, it.c_str() , 描画色);
142 temp = { (int)座標.
x, y, image->w, image->h };
145 SDL_FreeSurface(image);
146 SDL_DestroyTexture(moji);
148 y += this->enterHeight;
167 if( !handle )
return false;
179 image = TTF_RenderUTF8_Blended(handle, it.c_str() , 描画色);
182 temp = { (int)座標.
x, y,
int(image->w * X軸拡大率), int(image->h * Y軸拡大率) };
185 SDL_FreeSurface(image);
186 SDL_DestroyTexture(moji);
189 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:65
bool Load(const char *フォント名, int 大きさ, int 太さ=1, int 改行高さ=0)
メモリ上にフォントを作成する.
Definition: Font_Old.h:38
bool DrawRotate(const Point &座標, double 拡大率, double 角度, const Color &描画色, const VariadicStream &描画する文字列, bool 反転フラグ=false) const override
文字を回転して描画.
Definition: Font_Old.h:156
TTF_Font * GetHandle() const
フォントのハンドルを取得.
Definition: Font_Old.h:59
点を表す図形クラス.
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:111
int GetDrawStringWidth(VariadicStream 幅を計算する文字列) const
描画時の幅を取得[DXLIB].
Definition: Font_Old.h:117
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:125
可変数引数な文字列を処理するクラス.
Definition: VariadicStream.h:25
double x
座標
Definition: Point.h:25
int GetSize() const
大きさを取得.
Definition: Font_Old.h:105
bool Release() const
フォントをメモリから開放する.
Definition: Font_Old.h:50
bool DrawExtend(const Point &座標, double X軸拡大率, double Y軸拡大率, const Color &描画色, const VariadicStream &描画する文字列, bool 反転フラグ=false) const override
拡大率を指定して文字を描画.
Definition: Font_Old.h:165