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>
8 #include <Framework/Shape.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;
144 for(
auto it : 描画する文字列.StringS)
148 image = TTF_RenderUTF8_Blended(handle, it.c_str() , 色);
151 temp = { (int)座標.x, Y座標, image->w, image->h };
154 SDL_FreeSurface(image);
155 SDL_DestroyTexture(moji);
157 Y座標 += this->enterHeight;
165 Draw({ 座標.x + 1, 座標.y + 1 }, 影色, 描画する文字列);
166 return Draw(座標,表色,描画する文字列);
182 if( !handle )
return false;
189 for (
auto it:描画する文字列.StringS)
193 image = TTF_RenderUTF8_Blended(handle, it.c_str() , 描画色);
196 temp = { (int)座標.x, Y座標,
int(image->w * X拡大率), int(image->h * Y拡大率) };
199 SDL_FreeSurface(image);
200 SDL_DestroyTexture(moji);
203 Y座標 += int(this->enterHeight * Y拡大率);
static RendererHandle GetHandle()
スクリーンハンドルを取得.
Definition: Screen.h:77
Font,BmpFont等のインターフェース.
Definition: IFont.h:9
FontHandle GetHandle() const
フォントのハンドルを取得.
Definition: Font.h:64
bool DrawRotate(const Point &座標, double 拡大率, double 角度, Color 描画色, bool 反転フラグ, VariadicStream 描画する文字列) const override
文字を回転して描画.
Definition: Font.h:171
bool DrawExtend(const Point &座標, double X拡大率, double Y拡大率, Color 描画色, VariadicStream 描画する文字列) const override
拡大率を指定して文字を描画.
Definition: Font.h:180
点を表す図形クラス.
Definition: Shape.h:129
フォントデータを表すクラス.
Definition: Font.h:23
int GetDrawStringWidth(VariadicStream 幅を計算する文字列) const
描画時の幅を取得[未実装].
Definition: Font.h:127
int GetSize() const
大きさを取得.
Definition: Font.h:115
画像データを表すクラス.
Definition: Image.h:38
色を表すクラス.
Definition: Color.h:7
int Getthick() const
太さを取得.
Definition: Font.h:121
bool Draw(const Point &座標, Color 色, VariadicStream 描画する文字列) const override
文字を描画.
Definition: Font.h:135
bool Release() const
フォントをメモリから開放する.
Definition: Font.h:55
bool Release()
イメージをメモリから開放.
Definition: Image.h:113
可変数引数な文字列を処理するクラス.
Definition: VariadicStream.h:8
bool DrawRotate(const Point &座標, double 拡大率, double 角度, bool 反転フラグ=false) const
角度、拡大率を指定して描画.
Definition: Image.h:186
Image MakeImage(Color 文字色, bool 反転フラグ, VariadicStream 描画する文字列) const
フォントから画像を生成
Definition: Font.h:70
FontType
フォントの種類.
Definition: Font.h:13
bool Load(const char *フォント名, int 大きさ, int 太さ=1, int 改行高さ=0, FontType フォントタイプ=FontType::Normal)
メモリ上にフォントを作成する.
Definition: Font.h:43