Skip to content

Instantly share code, notes, and snippets.

@Islington036
Last active December 8, 2023 20:07
Show Gist options
  • Save Islington036/5b02e44d77cd9a461304fba832ee4538 to your computer and use it in GitHub Desktop.
Save Islington036/5b02e44d77cd9a461304fba832ee4538 to your computer and use it in GitHub Desktop.
#include "DirectWriteCustomFont.h"
void DirectWriteSample()
{
// フォントデータ
FontData data;
// DirectWrite描画クラス
DirectWriteCustomFont* Write;
// DirectWriteCustomFontクラスの生成
Write = new DirectWriteCustomFont(&data);
// 初期化(SwapChainの取得は適宜お願いします)
Write->Init(Renderer::GetSwapChain());
// 日本語ロケールのフォント名を取得
Write->GetFontFamilyName(Write->fontCollection.Get(), L"ja-JP");
// フォントデータを改変
data.fontSize = 60;
data.fontWeight = DWRITE_FONT_WEIGHT_ULTRA_BLACK;
data.Color = D2D1::ColorF(D2D1::ColorF::Red);
data.font = Write->GetFontName(3);
// フォントをセット
Write->SetFont(data);
// 描画(実際はDrawの方で呼び出してください)
Write->DrawString("ここはタイトル画面です", D3DXVECTOR2(90, 90), D2D1_DRAW_TEXT_OPTIONS_NONE);
// メモリ解放
delete Write;
Write = nullptr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment