I would like to use a specified font file with DirectX 11
After searching, i am stuck to create a custom Font Collection.
Code to load the specified font file:
Platform::String^ pathTEST;
Microsoft::WRL::ComPtr<IDWriteFontFile> fontFileTEST;
Microsoft::WRL::ComPtr<IDWriteFontFileLoader> fontFileLoaderTEST;
Windows::Storage::StorageFolder^ folder = Windows::Storage::ApplicationData::Current->LocalFolder;
pathTEST = folder->Path + L"\\Bubblegum.ttf";//#BubbleGum
HRESULT hr = S_OK;
if (SUCCEEDED(hr))
hr = dwriteFactory->CreateFontFileReference(pathTEST->Data(), NULL, &fontFileTEST);
if (SUCCEEDED(hr))
hr = fontFileTEST->GetLoader(&fontFileLoaderTEST);
if (SUCCEEDED(hr))
hr = dwriteFactory->RegisterFontFileLoader(fontFileLoaderTEST.Get());
Code that should use the font, but i am missing the Font collection:
MyIDWriteFactory2->CreateTextFormat(
L"BubbleGum", MyWriteFontCollection (nullptr for the moment),
DWRITE_FONT_WEIGHT_LIGHT, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
16.0f, L"en-us", &MyIDWriteTextFormat);
I don't have any problem to use a system Font like Arial.
Thanks for your help.