Font support
opened this issue · comments
I noticed font support was removed. Are there any plans to re-add some kind of font support?
Are there any plans to re-add some kind of font support?
Yes
Thanks for your feedback.
The same question!
I also suggest some documentation to show how copy the memory into device.
Maybe I can contribute on windows
case WM_PAINT:
{
PAINTSTRUCT ps;
HDC hdc = BeginPaint(hWnd, &ps);
const int width = ps.rcPaint.right - ps.rcPaint.left;
const int height = ps.rcPaint.bottom - ps.rcPaint.top;
plutovg_surface_t* surface = plutovg_surface_create(width, height);
plutovg_t* pluto = plutovg_create(surface);
plutovg_surface_write_to_hdc(surface, 0, 0, hdc);
plutovg_surface_destroy(surface);
plutovg_destroy(pluto);
EndPaint(hWnd, &ps);
}
void plutovg_surface_write_to_hdc(plutovg_surface_t* surface, int x, int y, HDC hdc)
{
BYTE bitmapinfo[FIELD_OFFSET(BITMAPINFO, bmiColors) + (3 * sizeof(DWORD))];
BITMAPINFOHEADER& bih = *(BITMAPINFOHEADER*)bitmapinfo;
bih.biSize = sizeof(BITMAPINFOHEADER);
bih.biWidth = surface->width;
bih.biHeight = surface->height;
bih.biPlanes = 1;
bih.biBitCount = 32;
bih.biCompression = BI_BITFIELDS;
bih.biSizeImage = 0;
bih.biClrUsed = 0;
bih.biClrImportant = 0;
DWORD* pMasks = (DWORD*)(&bitmapinfo[bih.biSize]);
pMasks[0] = 0xff0000; // Red
pMasks[1] = 0x00ff00; // Green
pMasks[2] = 0x0000ff; // Blue
StretchDIBits(hdc,
x,
y + surface->height,
surface->width,
-surface->height,
0,
0,
surface->width,
surface->height,
surface->data,
(BITMAPINFO*)&bih,
DIB_RGB_COLORS,
SRCCOPY);
}
Font and text rendering is now supported!