I am using Direct2D for some graphics, I have gotten it to draw text with DirectDraw (using the DrawText function on the ID2D1RenderTarget) but for some reason it will not draw with the font I want. When I create a text format for the font I want I do not get any errors. I am compiling with the Multibyte option set.
Font loading code:
std::wstring unicode(name, name + strlen(name));
HRESULT r = g_writeFactory->CreateTextFormat(unicode.c_str(), NULL, DWRITE_FONT_WEIGHT_NORMAL,
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, (float)size, L"en-us", &g_fonts[i]);
g_fonts[i]->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING);
g_fonts[i]->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR);
if (FAILED(r))
{
dgSetLastError(dgERROR_CREATIONFAILED);
return -1;
}
return i;
Text drawing:
std::wstring unicode(text, text + strlen(text));
D2D1_RECT_F r = D2D1::RectF(x, y, x + width, y + height);
int len = unicode.size();
if (g_isRenderToTexture)
g_textureTarget->DrawText(unicode.c_str(), len, g_fonts[fontId], &r, g_solidBrush);
else
g_bufferTarget->DrawText(unicode.c_str(), len, g_fonts[fontId], &r, g_solidBrush);