Laid the foundation for text rendering into uiAreas on Windows. GTK+ and Cocoa backends need no special setup (we can start using Pango and Core Text respectively without extra initialization). Not sure when I'll actually add the APIs to draw text, but hopefully it's soon because I really really really need to start working on what I was actually going to USE this library for, and text rendering is the last major prerequisite.

This commit is contained in:
Pietro Gagliardi 2015-12-22 00:35:52 -05:00
parent 7d77a8c4e7
commit f04bbe1bdc
5 changed files with 24 additions and 1 deletions

View File

@ -54,7 +54,7 @@ RCFILES += \
# flags for the Windows API
LDFLAGS += \
user32.lib kernel32.lib gdi32.lib comctl32.lib uxtheme.lib msimg32.lib comdlg32.lib d2d1.lib ole32.lib oleaut32.lib oleacc.lib uuid.lib
user32.lib kernel32.lib gdi32.lib comctl32.lib uxtheme.lib msimg32.lib comdlg32.lib d2d1.lib dwrite.lib ole32.lib oleaut32.lib oleacc.lib uuid.lib
# flags for building a shared library
LDFLAGS += \

View File

@ -21,6 +21,21 @@ void uninitDraw(void)
ID2D1Factory_Release(d2dfactory);
}
static IDWriteFactory *dwfactory = NULL;
HRESULT initDrawText(void)
{
// TOOD use DWRITE_FACTORY_TYPE_ISOLATED instead?
return DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,
&IID_IDWriteFactory,
(IUnknown **) (&dwfactory));
}
void uninitDrawText(void)
{
IDWriteFactory_Release(dwfactory);
}
ID2D1HwndRenderTarget *makeHWNDRenderTarget(HWND hwnd)
{
D2D1_RENDER_TARGET_PROPERTIES props;

View File

@ -156,6 +156,10 @@ const char *uiInit(uiInitOptions *o)
if (hr != S_OK)
return loadHRESULT("initializing Direct2D", hr);
hr = initDrawText();
if (hr != S_OK)
return loadHRESULT("initializing DirectWrite", hr);
if (registerAreaClass(hDefaultIcon, hDefaultCursor) == 0)
return loadLastError("registering uiArea window class");
if (registerAreaFilter() == 0)
@ -168,6 +172,7 @@ void uiUninit(void)
{
uninitMenus();
unregisterArea();
uninitDrawText();
uninitDraw();
CoUninitialize();
if (DeleteObject(hollowBrush) == 0)

View File

@ -127,6 +127,8 @@ extern int registerAreaFilter(void);
// draw.c
extern HRESULT initDraw(void);
extern void uninitDraw(void);
extern HRESULT initDrawText(void);
extern void uninitDrawText(void);
extern ID2D1HwndRenderTarget *makeHWNDRenderTarget(HWND hwnd);
extern uiDrawContext *newContext(ID2D1RenderTarget *);
extern void freeContext(uiDrawContext *);

View File

@ -38,6 +38,7 @@
#include <math.h>
#include <d2d1.h>
#include <float.h>
#include <dwrite.h>
#endif
#ifdef _MSC_VER
#pragma warning(pop)