I was recently developing my own GUI library. The window is created using Win32 API and then Direct2D RenderTarget was created inside. All the drawing (buttons, labels, etc.) happens inside the RenderTarget. Everything is fine except for the quality of the text. When I look at visual studio buttons for example, the text looks so clear compared to DirectWrite method DrawTextW().
Here is an image example:
I use DirectWrite to directly draw text. `
ID2D1SolidColorBrush* brush;
RenderTarget->CreateSolidColorBrush(D2D1::ColorF(red, green, blue, alpha), &brush);
IDWriteTextFormat* format;
HRESULT h = WriteFactory->CreateTextFormat(std::wstring(font.begin(), font.end()).c_str(), NULL, fontWeight,
fontStyle, DWRITE_FONT_STRETCH_NORMAL, fontSize, L"", &format);
// Center the text horizontally and vertically.
format->SetTextAlignment(textAllignment);
format->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
// Draw text
RenderTarget->DrawTextW(std::wstring(text.begin(), text.end()).c_str(), std::wstring(text.begin(), text.end()).size(), format, D2D1::RectF(xPos, yPos, xPos+width, yPos+height), brush);
brush->Release();
format->Release();
`
I was just wondering, is this something that I should just accept and move on or do I have to tweak something with DWriteFactory?