SDXFrameWork  0.09
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Public Member Functions | List of all members
SDX::Font Class Reference

フォントデータを表すクラス. More...

#include <Font.h>

Inherits SDX::IFont.

Public Member Functions

 Font (const char *フォント名, int 大きさ, int 太さ=1, int 改行高さ=0, FontType フォントタイプ=FontType::Normal)
 
bool Load (const char *フォント名, int 大きさ, int 太さ=1, int 改行高さ=0, FontType フォントタイプ=FontType::Normal)
 メモリ上にフォントを作成する. More...
 
bool Release () const
 フォントをメモリから開放する. More...
 
FontHandle GetHandle () const
 フォントのハンドルを取得. More...
 
Image MakeImage (Color 文字色, bool 反転フラグ, VariadicStream 描画する文字列) const
 フォントから画像を生成
 
int GetSize () const
 大きさを取得. More...
 
int Getthick () const
 太さを取得. More...
 
int GetDrawStringWidth (VariadicStream 幅を計算する文字列) const
 描画時の幅を取得[未実装]. More...
 
bool Draw (const Point &座標, Color 色, VariadicStream 描画する文字列) const override
 文字を描画. More...
 
bool DrawShadow (const Point &座標, Color 表色, Color 影色, VariadicStream 描画する文字列) const
 
bool DrawRotate (const Point &座標, double 拡大率, double 角度, Color 描画色, bool 反転フラグ, VariadicStream 描画する文字列) const override
 文字を回転して描画. More...
 
bool DrawExtend (const Point &座標, double X拡大率, double Y拡大率, Color 描画色, VariadicStream 描画する文字列) const override
 拡大率を指定して文字を描画. More...
 

Detailed Description

フォントデータを表すクラス.

//©SDXFramework http://sourceforge.jp/projects/dxframework/
//🍣フォントを使って文字列を描画する
bool SampleFont()
{
using namespace SDX;
System::Initialise("sample", 600, 400);
//SDLとDXLIBでフォント指定方法が違うので注意が必要
Font fontA( SystemFont::Gothic , 20 , 1 , 10 );
Font fontB( SystemFont::Mincho , 20 , 1 , 10 );
double angle = 0;
while(System::Update())
{
angle += 0.02;
fontA.Draw({ 10 * angle, 10 }, Color::White, "Hello!\nこんにちは\n今日は");
fontB.Draw({ 10 * angle, 200 }, Color::Blue, "Hello!\nこんにちは\n今日は");
fontA.DrawRotate({ 300, 200 }, 1, angle, Color::White, false, "文字の回転\nてすとしますよ~~~");
fontB.DrawRotate({ 300, 200 }, 1, angle / 2, Color::White, false, "文字の回転\nてすとしますよ~~~");
if(Input::key.Return.on) break;//Enterで終了
}
return true;
}

Member Function Documentation

bool SDX::Font::Load ( const char *  フォント名,
int  大きさ,
int  太さ = 1,
int  改行高さ = 0,
FontType  フォントタイプ = FontType::Normal 
)

メモリ上にフォントを作成する.

太さは0~9で指定、大きさと太さは-1にするとデフォルトになる
改行高さは0の場合、改行後の文字が上下くっつく。 SDLとDXLIBではフォント名の指定方法が違うので注意。 SDLでは太さとフォントタイプが無効

bool SDX::Font::Release ( ) const

フォントをメモリから開放する.

FontHandle SDX::Font::GetHandle ( ) const

フォントのハンドルを取得.

int SDX::Font::GetSize ( ) const

大きさを取得.

int SDX::Font::Getthick ( ) const

太さを取得.

int SDX::Font::GetDrawStringWidth ( VariadicStream  幅を計算する文字列) const

描画時の幅を取得[未実装].

bool SDX::Font::Draw ( const Point 座標,
Color  ,
VariadicStream  描画する文字列 
) const
overridevirtual

文字を描画.

Implements SDX::IFont.

bool SDX::Font::DrawRotate ( const Point 座標,
double  拡大率,
double  角度,
Color  描画色,
bool  反転フラグ,
VariadicStream  描画する文字列 
) const
overridevirtual

文字を回転して描画.

呼び出す度に画像イメージを作成するので処理は重い

Implements SDX::IFont.

bool SDX::Font::DrawExtend ( const Point 座標,
double  X拡大率,
double  Y拡大率,
Color  描画色,
VariadicStream  描画する文字列 
) const
overridevirtual

拡大率を指定して文字を描画.

Implements SDX::IFont.