// TOOD rename to something else, maybe HRESULT uiprivInitDrawText(void) { // TOOD use DWRITE_FACTORY_TYPE_ISOLATED instead? return DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof (IDWriteFactory), (IUnknown **) (&dwfactory)); }
BOOL DrawTimeFrequencyGrid::Initialize( float aFontSize ) { static const WCHAR msc_fontName[] = L"Verdana"; fontSize = aFontSize; // Added code for factory here--odd place to put it. HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &pFactory); if ( FAILED(hr)) return FALSE; // Create a DirectWrite factory. hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(pDWriteFactory), reinterpret_cast<IUnknown **>(&pDWriteFactory) ); if ( FAILED(hr)) return FALSE; // Create a DirectWrite text format object. hr = pDWriteFactory->CreateTextFormat( msc_fontName, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, fontSize, L"", //locale &pTextFormat ); if ( FAILED(hr)) return FALSE; // Center the text horizontally and vertically. pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); pTextFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); return TRUE; }
// // Program starts here // int main( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow ) { HRESULT hr = D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, &g_pD2DFactory ); hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof( IDWriteFactory ), reinterpret_cast<IUnknown**>( &g_pDWriteFactory ) ); hr = CoInitialize( NULL ); hr = CoCreateInstance( CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, reinterpret_cast<void**>( &g_pWICFactory ) ); g_pHWND = CreateGameWindow(); createDeviceResources(); // // Create a GWEN Direct2D renderer // g_pRenderer = new gwen::Renderer::Direct2D( g_pRT, g_pDWriteFactory, g_pWICFactory ); runSample(); delete g_pRenderer; g_pRenderer = NULL; if ( g_pRT != NULL ) { g_pRT->Release(); g_pRT = NULL; } }
ComPtr<IDWriteTextFormat> CanvasTextFormat::GetRealizedTextFormat() { if (m_format) return m_format; ComPtr<IDWriteFactory2> factory; ThrowIfFailed(DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(&factory), static_cast<IUnknown**>(&factory))); ThrowIfFailed(factory->CreateTextFormat( static_cast<const wchar_t*>(m_fontFamilyName), m_fontCollection.Get(), ToFontWeight(m_fontWeight), ToFontStyle(m_fontStyle), ToFontStretch(m_fontStretch), m_fontSize, static_cast<const wchar_t*>(m_localeName), &m_format)); RealizeFlowDirection(); RealizeIncrementalTabStop(); RealizeLineSpacing(); RealizeParagraphAlignment(); RealizeReadingDirection(); RealizeTextAlignment(); RealizeTrimming(); RealizeWordWrapping(); return m_format; }
DirectWrite::DirectWrite() { DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown**)(&pFactory)); }
int main(int, char**) { IDWriteFactory *factory = 0; DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(&factory)); return 0; }
SharedD2DFactory() { jassertfalse; //xxx Direct2D support isn't ready for use yet! D2D1CreateFactory (D2D1_FACTORY_TYPE_SINGLE_THREADED, d2dFactory.resetAndGetPointerAddress()); DWriteCreateFactory (DWRITE_FACTORY_TYPE_SHARED, __uuidof (IDWriteFactory), (IUnknown**) directWriteFactory.resetAndGetPointerAddress()); if (directWriteFactory != nullptr) directWriteFactory->GetSystemFontCollection (systemFonts.resetAndGetPointerAddress()); }
// An initialization routine to create and implement the DirectWrite library's interfaces bool DebugOverlay::Init(Engine2D * eng) { // Short term rectangle for ease of use in Init function RECT rect = eng->wRect; // Default a simple empty string for the global display text - may be unnecessary displayText = new wchar_t[1] {L""}; // Sets the active window's bounds for referencing later in the DrawText // Can manipulate to move text from upper-right corner by default lRect = D2D1::RectF( static_cast<FLOAT>(rect.left), // dpiScaleX, static_cast<FLOAT>(rect.top), // dpiScaleY, static_cast<FLOAT>(rect.right - rect.left), // dpiScaleX, static_cast<FLOAT>(rect.bottom - rect.top) // dpiScaleY ); // Create the DirectWrite factory and check that it executed okay // Function call is virtually the same as the sample given on the // MSDN site for how to use the DirectWrite library HRESULT hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, // see MSDN for information about this __uuidof(IDWriteFactory), // Also this reinterpret_cast<IUnknown**>(&writeFact) // And this ); if (!SUCCEEDED(hr)) { return false; }; // Create the Text Format for issuing later to the DrawText() function // Function call is virtually the same as the sample given on the // MSDN site for how to use the DirectWrite library hr = writeFact->CreateTextFormat( L"Consolas", // Font type NULL, // ID Write Font Collection - set to null for default system font collection DWRITE_FONT_WEIGHT_REGULAR, // Font weight DWRITE_FONT_STYLE_NORMAL, // Font style DWRITE_FONT_STRETCH_NORMAL, // Font stretch (?) 14.0f, // Font size L"en-us", // Locale name &textFormat // Reference to the text format handle for storing the information ); if (!SUCCEEDED(hr)) { return false; }; // Set the text alignment of the text format object and check to make sure its okay hr = textFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_TRAILING); if (!SUCCEEDED(hr)) { return false; }; // Set the paragraph alignment for the text format object and check to make sure its okay hr = textFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR); if (!SUCCEEDED(hr)) { return false; }; // Use the pre-existing D2D render target to create a solid brush for this class hr = eng->renderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White), &debugBrush); if (!SUCCEEDED(hr)) { return false; }; return true; }
/// <summary> /// Ensure the independent Direct2D resources have been created /// </summary> void EnsureIndependentResourcesCreated() { if (nullptr == g_pD2DFactory) { D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, &g_pD2DFactory); } if (nullptr == g_pDWriteFactory) { DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&g_pDWriteFactory)); } }
CustomFontFileLoader() : m_directWriteFactory(0), m_directWriteFontFileLoader(0) { HRESULT hres = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(&m_directWriteFactory)); if (FAILED(hres)) { qErrnoWarning(hres, "CustomFontFileLoader::CustomFontFileLoader: " "DWriteCreateFactory failed."); } else { m_directWriteFontFileLoader = new DirectWriteFontFileLoader(); m_directWriteFactory->RegisterFontFileLoader(m_directWriteFontFileLoader); } }
static HRESULT initDWriteRenderingParamsHelper() { IDWriteFactoryN* pDWriteFactoryN; HRESULT hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactoryN), reinterpret_cast<IUnknown**>(&pDWriteFactoryN) ); if (SUCCEEDED(hr)) { initDWriteRenderingParams(Direct2DParams, pDWriteFactoryN); initDWriteRenderingParams(DirectWriteParams, pDWriteFactoryN); pDWriteFactoryN->Release(); } return hr; }
HRESULT MainWindow::OnRender() { auto hr = CreateDeviceResources(); hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&m_pWriteFactory)); if (hr != S_OK) return hr; hr = m_pWriteFactory->CreateTextFormat( L"Segoe UI", NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 12.0f * 96.0f / 72.0f, L"zh-CN", &m_pWriteTextFormat); #pragma warning(disable:4244) #pragma warning(disable:4267) if (SUCCEEDED(hr)) { RECT rect; GetClientRect(&rect); m_pHwndRenderTarget->BeginDraw(); m_pHwndRenderTarget->SetTransform(D2D1::Matrix3x2F::Identity()); m_pHwndRenderTarget->Clear(D2D1::ColorF(D2D1::ColorF::White, 1.0f)); m_pHwndRenderTarget->DrawRectangle(D2D1::RectF(20, 10, rect.right - rect.left - 20, 150), m_AreaBorderBrush, 1.0); m_pHwndRenderTarget->DrawRectangle(D2D1::RectF(20, 150, rect.right - rect.left - 20, rect.bottom-rect.top-20), m_AreaBorderBrush, 1.0); for (auto &label : label_) { if (label.text.empty()) continue; m_pHwndRenderTarget->DrawTextW(label.text.c_str(), label.text.size(), m_pWriteTextFormat, D2D1::RectF(label.layout.left, label.layout.top, label.layout.right, label.layout.bottom), m_pBasicTextBrush, D2D1_DRAW_TEXT_OPTIONS_NONE, DWRITE_MEASURING_MODE_NATURAL); } m_pWriteTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); hr = m_pHwndRenderTarget->EndDraw(); } #pragma warning(default:4244) #pragma warning(default:4267) if (hr == D2DERR_RECREATE_TARGET) { hr = S_OK; DiscardDeviceResources(); ::InvalidateRect(m_hWnd, nullptr, FALSE); } return hr; }
void RenderDevice::init() { ComResult hr; hr = D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, D3D11_CREATE_DEVICE_BGRA_SUPPORT | D3D11_CREATE_DEVICE_DEBUG, nullptr, 0, D3D11_SDK_VERSION, &this->pDevice3, nullptr, &this->pDeviceContext3); hr = this->pDevice3.As(&this->pxDevice); hr = D2D1CreateDevice(this->pxDevice.Get(), D2D1::CreationProperties( D2D1_THREADING_MODE_MULTI_THREADED, D2D1_DEBUG_LEVEL_ERROR, D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS), &this->pDevice2); hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), &this->pdwFactory); hr = this->pdwFactory->GetSystemFontCollection(&this->pSystemFontCollection); }
HRESULT ClixRenderer::CreateDIR() { HRESULT hr = S_OK; hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &D2Factory); if (SUCCEEDED(hr)) { hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&pDWriteFactory) ); } if (SUCCEEDED(hr)) { hr = pDWriteFactory->CreateTextFormat( L"Microsoft Sans Serif Regular", // Font family name. NULL, // Font collection (NULL sets it to use the system font collection). DWRITE_FONT_WEIGHT_REGULAR, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 15.0f, L"en-us", &pTextFormat ); } // Center align (horizontally) the text. if (SUCCEEDED(hr)) { hr = pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING); } if (SUCCEEDED(hr)) { hr = pTextFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); } #ifdef CONSOLE if (SUCCEEDED(hr)) std::wcout << "DeviceIndependendResources Succesfully created!" << std::endl; else std::wcout << "DeviceIndependedResources Error: " << std::hex << hr << std::endl; #endif return hr; }
HRESULT CAshaD2D::CreateFactory(void) { HRESULT hr=S_OK; //Initialize com CoInitializeEx(NULL,COINIT_MULTITHREADED); //Create WIC factory hr=CoCreateInstance(CLSID_WICImagingFactory1,NULL,CLSCTX_INPROC_SERVER,IID_PPV_ARGS(&m_pWICImgFactory)); //Create D2D factory if(SUCCEEDED(hr)) hr=D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED,&m_pD2D1Facatory); //Create DWrite factory if(SUCCEEDED(hr)) hr=DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED,__uuidof(IDWriteFactory),reinterpret_cast<IUnknown**>(&m_pDWriteFactory)); return hr; }
PCT_BEG LibPictmancer::LibPictmancer() { HRESULT hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, _WriteFactory.IID(), &_WriteFactory ); auto type = D2D1_FACTORY_TYPE::D2D1_FACTORY_TYPE_MULTI_THREADED; hr = D2D1CreateFactory( type, _Factory.IID(), &_Factory ); }
HRESULT DemoApp::CreateDeviceIndependentResources() { HRESULT hr = S_OK; // Create the Direct2D factory. hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pD2DFactory); if (SUCCEEDED(hr)) { // Create a WIC factory. hr = CoCreateInstance( CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, reinterpret_cast<void **>(&m_pWICFactory) ); } if (SUCCEEDED(hr)) { // Create a DirectWrite factory. hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(m_pDWriteFactory), reinterpret_cast<IUnknown **>(&m_pDWriteFactory) ); } if (SUCCEEDED(hr)) { // Create a DirectWrite text format object. hr = m_pDWriteFactory->CreateTextFormat( sc_fontName, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, static_cast<FLOAT>(sc_fontSize), L"", //locale &m_pTextFormat ); } return hr; }
result_t Render2D::init(HWND window) { // Pass the window handler for future processing. a_window = window; HRESULT hRes = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &ap_d2dFactory); if (FAILED(hRes)) { return RET_FAILURE; } hRes = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&ap_dwFactory)); if (FAILED(hRes)) { return RET_FAILURE; } hRes = ap_dwFactory->CreateTextFormat( L"Gabriola", nullptr, DWRITE_FONT_WEIGHT_REGULAR, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, 72.0f, L"en-us", &ap_dwTextFormat); if (FAILED(hRes)) { return RET_FAILURE; } hRes = ap_dwTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); if (FAILED(hRes)) { return RET_FAILURE; } hRes = ap_dwTextFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); if (FAILED(hRes)) { return RET_FAILURE; } return RET_SUCCESS; }
HRESULT BaseApp::CreateDeviceIndependentResources() { HRESULT hr = S_OK; // Create a Direct2D factory. hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pD2DFactory); // Create a DirectWrite factory. hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&m_pDWriteFactory)); // Create WIC Imaging factory. hr = CoCreateInstance(CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, __uuidof(IWICImagingFactory), (void**)(&m_pWICImagingFactory) ); return hr; }
void FontRendererImpl::Initialize() { trace("[FontRenderer] Initializing DirectWrite.\n"); DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown**)m_dwFactory.GetAddressOf()); // attempt to get a IDWriteFactory2 HRESULT hr = m_dwFactory.As(&m_dwFactory2); if (FAILED(hr)) { trace("[FontRenderer] IDWriteFactory2 unavailable (hr=%08x), colored font rendering will not be used\n", hr); } m_gameInterface = CreateGameInterface(); CreateTextRenderer(); }
HRESULT App::CreateDeviceIndependentResources() { HRESULT hr; // Create a Direct2D factory. #if defined(DEBUG) || defined(_DEBUG) D2D1_FACTORY_OPTIONS options; options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION; hr = D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, options, &D2D_Factory ); #else hr = D2D1CreateFactory( D2D1_FACTORY_TYPE_MULTI_THREADED, &D2D_Factory ); #endif if (SUCCEEDED(hr)) { // Create WIC factory. hr = CoCreateInstance( CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&WIC_Factory) ); } if (SUCCEEDED(hr)) { // Create a DirectWrite factory. hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(DW_Factory), reinterpret_cast<IUnknown **>(&DW_Factory) ); } return hr; }
HRESULT DisplayerImpl::CreateDeviceIndependentResources() { HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), (IUnknown**)&mDWriteFactory); if (FAILED(hr)) return hr; D2D1_FACTORY_OPTIONS options; memset(&options, 0, sizeof(options)); #ifdef _DEBUG options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION; #endif hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_MULTI_THREADED, options, mD2DFactory.GetAddressOf()); if (FAILED(hr)) return hr; mD2DFactory->GetDesktopDpi(&mDpiX, &mDpiY); return hr; }
// Creates resources that are not bound to a particular device. // Their lifetime effectively extends for the duration of the application. HRESULT Direct2D_Miffy::CreateDeviceIndependentResources() { HRESULT hr = S_OK; // Create a Direct2D factory. hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pDirect2dFactory); if(SUCCEEDED(hr)) { hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&m_pDWriteFactory) ); } if(SUCCEEDED(hr)) { hr = m_pDirect2dFactory->CreatePathGeometry(&m_pPathGeometryUnion); } if(SUCCEEDED(hr)) { hr = m_pDirect2dFactory->CreatePathGeometry(&m_pPathGeometryUnion2); } // Create the ellipse geometries, which are device-independent const D2D1_ELLIPSE ellipse1 = D2D1::Ellipse( D2D1::Point2F(240.0f, 140.0f), 40.0f, 100.0f); const D2D1_ELLIPSE ellipse2 = D2D1::Ellipse( D2D1::Point2F(400.0f, 140.0f), 40.f, 100.0f); const D2D1_ELLIPSE ellipse3 = D2D1::Ellipse( D2D1::Point2F(320.0f, 300.0f), 150.f, 120.0f); const D2D1_ELLIPSE ellipse4 = D2D1::Ellipse( D2D1::Point2F(240.0f, 280.0f), 10.f, 10.0f); const D2D1_ELLIPSE ellipse5 = D2D1::Ellipse( D2D1::Point2F(400.0f, 280.0f), 10.f, 10.0f); hr = m_pDirect2dFactory->CreateEllipseGeometry(ellipse1, &m_pEllipseGeometry1); hr = m_pDirect2dFactory->CreateEllipseGeometry(ellipse2, &m_pEllipseGeometry2); hr = m_pDirect2dFactory->CreateEllipseGeometry(ellipse3, &m_pEllipseGeometry3); hr = m_pDirect2dFactory->CreateEllipseGeometry(ellipse4, &m_pEllipseGeometry4); hr = m_pDirect2dFactory->CreateEllipseGeometry(ellipse5, &m_pEllipseGeometry5); return hr; }
// ---------------------------------------------------------------- // Constructor // ---------------------------------------------------------------- CD2DText::CD2DText(void) : m_pD2DRenderer( & CD2DRenderer::GetInstance() ) , m_Text( L"" ) , m_FontFace( L"" ) , m_FontSize(0) , m_ColorR(0) , m_ColorG(0) , m_ColorB(0) , m_Opacity(1.f) , m_Bold(false) , m_Italic(false) , m_DWriteFactory(nullptr) , m_TextFormat(nullptr) , m_Brush(nullptr) , m_PosX(0) , m_PosY(0) { DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(m_DWriteFactory), reinterpret_cast<IUnknown**>(&m_DWriteFactory) ); m_pD2DRenderer->GetHwndRenderTarget()->CreateSolidColorBrush( D2D1::ColorF(m_ColorR,m_ColorG,m_ColorB), &m_Brush ); }
bool CanvasD2D::Initialize() { ++c_Instances; if (c_Instances == 1) { if (!IsWindows7OrGreater()) return false; D2D1_FACTORY_OPTIONS fo = {}; #ifdef _DEBUG fo.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION; #endif HRESULT hr = D2D1CreateFactory( D2D1_FACTORY_TYPE_SINGLE_THREADED, fo, c_D2DFactory.GetAddressOf()); if (FAILED(hr)) return false; hr = CoCreateInstance( CLSID_WICImagingFactory, nullptr, CLSCTX_INPROC_SERVER, IID_IWICImagingFactory, (LPVOID*)c_WICFactory.GetAddressOf()); if (FAILED(hr)) return false; hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(c_DWFactory), (IUnknown**)c_DWFactory.GetAddressOf()); if (FAILED(hr)) return false; hr = c_DWFactory->GetGdiInterop(c_DWGDIInterop.GetAddressOf()); if (FAILED(hr)) return false; hr = c_DWFactory->RegisterFontCollectionLoader(Util::DWriteFontCollectionLoader::GetInstance()); if (FAILED(hr)) return false; } return true; }
void d2d::InitTextDevice(const wstring fontName, FLOAT fontSize) { if (m_pD2DFactory == nullptr) { return; } // Create a DirectWrite factory. HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(m_pDWriteFactory), reinterpret_cast<IUnknown**>(&m_pDWriteFactory)); if (FAILED(hr) || m_pDWriteFactory == nullptr) { return; } // Create a DirectWrite text format object. hr = m_pDWriteFactory->CreateTextFormat( fontName.c_str(), NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, fontSize, L"", //locale &m_pTextFormat); if (FAILED(hr) || m_pTextFormat == nullptr) { return; } // Center the text horizontally and vertically. m_pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); m_pTextFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); hr = m_pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Black), &m_pBlackBrush); pokerlog << "InitTextDevice OK." << endl; }
static QFontEngine *loadEngine(int script, const QFontDef &request, HDC fontHdc, int dpi, bool rawMode, const QtFontDesc *desc, const QStringList &family_list) { LOGFONT lf; memset(&lf, 0, sizeof(LOGFONT)); bool useDevice = (request.styleStrategy & QFont::PreferDevice) && fontHdc; HDC hdc = shared_dc(); QString font_name = desc != 0 ? desc->family->name : request.family; if (useDevice) { hdc = fontHdc; font_name = request.family; } bool stockFont = false; bool preferClearTypeAA = false; HFONT hfont = 0; #if !defined(QT_NO_DIRECTWRITE) bool useDirectWrite = (request.hintingPreference == QFont::PreferNoHinting) || (request.hintingPreference == QFont::PreferVerticalHinting); IDWriteFont *directWriteFont = 0; #else bool useDirectWrite = false; #endif if (rawMode) { // will choose a stock font int f, deffnt = SYSTEM_FONT; QString fam = desc != 0 ? desc->family->name.toLower() : request.family.toLower(); if (fam == QLatin1String("default")) f = deffnt; else if (fam == QLatin1String("system")) f = SYSTEM_FONT; #ifndef Q_WS_WINCE else if (fam == QLatin1String("system_fixed")) f = SYSTEM_FIXED_FONT; else if (fam == QLatin1String("ansi_fixed")) f = ANSI_FIXED_FONT; else if (fam == QLatin1String("ansi_var")) f = ANSI_VAR_FONT; else if (fam == QLatin1String("device_default")) f = DEVICE_DEFAULT_FONT; else if (fam == QLatin1String("oem_fixed")) f = OEM_FIXED_FONT; #endif else if (fam[0] == QLatin1Char('#')) f = fam.right(fam.length()-1).toInt(); else f = deffnt; hfont = (HFONT)GetStockObject(f); if (!hfont) { qErrnoWarning("QFontEngine::loadEngine: GetStockObject failed"); hfont = systemFont(); } stockFont = true; } else { int hint = FF_DONTCARE; switch (request.styleHint) { case QFont::Helvetica: hint = FF_SWISS; break; case QFont::Times: hint = FF_ROMAN; break; case QFont::Courier: hint = FF_MODERN; break; case QFont::OldEnglish: hint = FF_DECORATIVE; break; case QFont::System: hint = FF_MODERN; break; default: break; } lf.lfHeight = -qRound(request.pixelSize); lf.lfWidth = 0; lf.lfEscapement = 0; lf.lfOrientation = 0; if (desc == 0 || desc->style->key.weight == 50) lf.lfWeight = FW_DONTCARE; else lf.lfWeight = (desc->style->key.weight*900)/99; lf.lfItalic = (desc != 0 && desc->style->key.style != QFont::StyleNormal); lf.lfCharSet = DEFAULT_CHARSET; int strat = OUT_DEFAULT_PRECIS; if (request.styleStrategy & QFont::PreferBitmap) { strat = OUT_RASTER_PRECIS; #ifndef Q_WS_WINCE } else if (request.styleStrategy & QFont::PreferDevice) { strat = OUT_DEVICE_PRECIS; } else if (request.styleStrategy & QFont::PreferOutline) { strat = OUT_OUTLINE_PRECIS; } else if (request.styleStrategy & QFont::ForceOutline) { strat = OUT_TT_ONLY_PRECIS; #endif } lf.lfOutPrecision = strat; int qual = DEFAULT_QUALITY; if (request.styleStrategy & QFont::PreferMatch) qual = DRAFT_QUALITY; #ifndef Q_WS_WINCE else if (request.styleStrategy & QFont::PreferQuality) qual = PROOF_QUALITY; #endif if (request.styleStrategy & QFont::PreferAntialias) { if (QSysInfo::WindowsVersion >= QSysInfo::WV_XP) { qual = CLEARTYPE_QUALITY; preferClearTypeAA = true; } else { qual = ANTIALIASED_QUALITY; } } else if (request.styleStrategy & QFont::NoAntialias) { qual = NONANTIALIASED_QUALITY; } lf.lfQuality = qual; lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; lf.lfPitchAndFamily = DEFAULT_PITCH | hint; QString fam = font_name; if(fam.isEmpty()) fam = QLatin1String("MS Sans Serif"); if ((fam == QLatin1String("MS Sans Serif")) && (request.style == QFont::StyleItalic || (-lf.lfHeight > 18 && -lf.lfHeight != 24))) { fam = QLatin1String("Arial"); // MS Sans Serif has bearing problems in italic, and does not scale } if (fam == QLatin1String("Courier") && !(request.styleStrategy & QFont::PreferBitmap)) fam = QLatin1String("Courier New"); memcpy(lf.lfFaceName, fam.utf16(), sizeof(wchar_t) * qMin(fam.length() + 1, 32)); // 32 = Windows hard-coded hfont = CreateFontIndirect(&lf); if (!hfont) qErrnoWarning("QFontEngine::loadEngine: CreateFontIndirect failed"); stockFont = (hfont == 0); bool ttf = false; int avWidth = 0; BOOL res; HGDIOBJ oldObj = SelectObject(hdc, hfont); TEXTMETRIC tm; res = GetTextMetrics(hdc, &tm); avWidth = tm.tmAveCharWidth; ttf = tm.tmPitchAndFamily & TMPF_TRUETYPE; SelectObject(hdc, oldObj); if (!ttf || !useDirectWrite) { useDirectWrite = false; if (hfont && (!ttf || request.stretch != 100)) { DeleteObject(hfont); if (!res) qErrnoWarning("QFontEngine::loadEngine: GetTextMetrics failed"); lf.lfWidth = avWidth * request.stretch/100; hfont = CreateFontIndirect(&lf); if (!hfont) qErrnoWarning("QFontEngine::loadEngine: CreateFontIndirect with stretch failed"); } #ifndef Q_WS_WINCE if (hfont == 0) { hfont = (HFONT)GetStockObject(ANSI_VAR_FONT); stockFont = true; } #else if (hfont == 0) { hfont = (HFONT)GetStockObject(SYSTEM_FONT); stockFont = true; } #endif } #if !defined(QT_NO_DIRECTWRITE) else { // Default to false for DirectWrite (and re-enable once/if everything // turns out okay) useDirectWrite = false; QFontDatabasePrivate *db = privateDb(); if (db->directWriteFactory == 0) { HRESULT hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(&db->directWriteFactory) ); if (FAILED(hr)) { qErrnoWarning("QFontEngine::loadEngine: DWriteCreateFactory failed"); } else { hr = db->directWriteFactory->GetGdiInterop(&db->directWriteGdiInterop); if (FAILED(hr)) qErrnoWarning("QFontEngine::loadEngine: GetGdiInterop failed"); } } if (db->directWriteGdiInterop != 0) { QString nameSubstitute = fontNameSubstitute(QString::fromWCharArray(lf.lfFaceName)); memcpy(lf.lfFaceName, nameSubstitute.utf16(), sizeof(wchar_t) * qMin(nameSubstitute.length() + 1, LF_FACESIZE)); HRESULT hr = db->directWriteGdiInterop->CreateFontFromLOGFONT( &lf, &directWriteFont); if (FAILED(hr)) { #ifndef QT_NO_DEBUG qErrnoWarning("QFontEngine::loadEngine: CreateFontFromLOGFONT failed " "for %ls (0x%lx)", lf.lfFaceName, hr); #endif } else { DeleteObject(hfont); useDirectWrite = true; } } } #endif } QFontEngine *fe = 0; if (!useDirectWrite) { QFontEngineWin *few = new QFontEngineWin(font_name, hfont, stockFont, lf); if (preferClearTypeAA) few->glyphFormat = QFontEngineGlyphCache::Raster_RGBMask; // Also check for OpenType tables when using complex scripts // ### TODO: This only works for scripts that require OpenType. More generally // for scripts that do not require OpenType we should just look at the list of // supported writing systems in the font's OS/2 table. if (scriptRequiresOpenType(script)) { HB_Face hbFace = few->harfbuzzFace(); if (!hbFace || !hbFace->supported_scripts[script]) { FM_DEBUG(" OpenType support missing for script\n"); delete few; return 0; } } initFontInfo(few, request, fontHdc, dpi); fe = few; } #if !defined(QT_NO_DIRECTWRITE) else { QFontDatabasePrivate *db = privateDb(); IDWriteFontFace *directWriteFontFace = NULL; HRESULT hr = directWriteFont->CreateFontFace(&directWriteFontFace); if (SUCCEEDED(hr)) { QFontEngineDirectWrite *fedw = new QFontEngineDirectWrite(db->directWriteFactory, directWriteFontFace, request.pixelSize); initFontInfo(fedw, request, dpi, directWriteFont); fe = fedw; } else { qErrnoWarning(hr, "QFontEngine::loadEngine: CreateFontFace failed"); } } if (directWriteFont != 0) directWriteFont->Release(); #endif if(script == QUnicodeTables::Common && !(request.styleStrategy & QFont::NoFontMerging) && desc != 0 && !(desc->family->writingSystems[QFontDatabase::Symbol] & QtFontFamily::Supported)) { if(!tryFonts) { LANGID lid = GetUserDefaultLangID(); switch( lid&0xff ) { case LANG_CHINESE: // Chinese (Taiwan) if ( lid == 0x0804 ) // Taiwan tryFonts = ch_TW_tryFonts; else tryFonts = ch_CN_tryFonts; break; case LANG_JAPANESE: tryFonts = jp_tryFonts; break; case LANG_KOREAN: tryFonts = kr_tryFonts; break; default: tryFonts = other_tryFonts; break; } } QStringList fm = QFontDatabase().families(); QStringList list = family_list; const char **tf = tryFonts; while(tf && *tf) { if(fm.contains(QLatin1String(*tf))) list << QLatin1String(*tf); ++tf; } QFontEngine *mfe = new QFontEngineMultiWin(fe, list); mfe->fontDef = fe->fontDef; fe = mfe; } return fe; }
// Load the rendering pipeline dependencies. void D3D1211on12::LoadPipeline() { UINT d3d11DeviceFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; D2D1_FACTORY_OPTIONS d2dFactoryOptions = {}; #ifdef _DEBUG // Enable the D2D debug layer. d2dFactoryOptions.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION; // Enable the D3D11 debug layer. d3d11DeviceFlags |= D3D11_CREATE_DEVICE_DEBUG; // Enable the D3D12 debug layer. { ComPtr<ID3D12Debug> debugController; if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController)))) { debugController->EnableDebugLayer(); } } #endif ComPtr<IDXGIFactory4> factory; ThrowIfFailed(CreateDXGIFactory1(IID_PPV_ARGS(&factory))); if (m_useWarpDevice) { ComPtr<IDXGIAdapter> warpAdapter; ThrowIfFailed(factory->EnumWarpAdapter(IID_PPV_ARGS(&warpAdapter))); ThrowIfFailed(D3D12CreateDevice( warpAdapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_d3d12Device) )); } else { ThrowIfFailed(D3D12CreateDevice( nullptr, D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_d3d12Device) )); } // Describe and create the command queue. D3D12_COMMAND_QUEUE_DESC queueDesc = {}; queueDesc.Flags = D3D12_COMMAND_QUEUE_FLAG_NONE; queueDesc.Type = D3D12_COMMAND_LIST_TYPE_DIRECT; ThrowIfFailed(m_d3d12Device->CreateCommandQueue(&queueDesc, IID_PPV_ARGS(&m_commandQueue))); // Describe the swap chain. DXGI_SWAP_CHAIN_DESC swapChainDesc = {}; swapChainDesc.BufferCount = FrameCount; swapChainDesc.BufferDesc.Width = m_width; swapChainDesc.BufferDesc.Height = m_height; swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_FLIP_DISCARD; swapChainDesc.OutputWindow = m_hwnd; swapChainDesc.SampleDesc.Count = 1; swapChainDesc.Windowed = TRUE; ComPtr<IDXGISwapChain> swapChain; ThrowIfFailed(factory->CreateSwapChain( m_commandQueue.Get(), // Swap chain needs the queue so that it can force a flush on it. &swapChainDesc, &swapChain )); ThrowIfFailed(swapChain.As(&m_swapChain)); m_frameIndex = m_swapChain->GetCurrentBackBufferIndex(); // Create an 11 device wrapped around the 12 device and share // 12's command queue. ComPtr<ID3D11Device> d3d11Device; ThrowIfFailed(D3D11On12CreateDevice( m_d3d12Device.Get(), d3d11DeviceFlags, nullptr, 0, reinterpret_cast<IUnknown**>(m_commandQueue.GetAddressOf()), 1, 0, &d3d11Device, &m_d3d11DeviceContext, nullptr )); // Query the 11On12 device from the 11 device. ThrowIfFailed(d3d11Device.As(&m_d3d11On12Device)); // Create D2D/DWrite components. { D2D1_DEVICE_CONTEXT_OPTIONS deviceOptions = D2D1_DEVICE_CONTEXT_OPTIONS_NONE; ThrowIfFailed(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof(ID2D1Factory3), &d2dFactoryOptions, &m_d2dFactory)); ComPtr<IDXGIDevice> dxgiDevice; ThrowIfFailed(m_d3d11On12Device.As(&dxgiDevice)); ThrowIfFailed(m_d2dFactory->CreateDevice(dxgiDevice.Get(), &m_d2dDevice)); ThrowIfFailed(m_d2dDevice->CreateDeviceContext(deviceOptions, &m_d2dDeviceContext)); ThrowIfFailed(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), &m_dWriteFactory)); } // Query the desktop's dpi settings, which will be used to create // D2D's render targets. float dpiX; float dpiY; m_d2dFactory->GetDesktopDpi(&dpiX, &dpiY); D2D1_BITMAP_PROPERTIES1 bitmapProperties = D2D1::BitmapProperties1( D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW, D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED), dpiX, dpiY ); // Create descriptor heaps. { // Describe and create a render target view (RTV) descriptor heap. D3D12_DESCRIPTOR_HEAP_DESC rtvHeapDesc = {}; rtvHeapDesc.NumDescriptors = FrameCount; rtvHeapDesc.Type = D3D12_DESCRIPTOR_HEAP_TYPE_RTV; rtvHeapDesc.Flags = D3D12_DESCRIPTOR_HEAP_FLAG_NONE; ThrowIfFailed(m_d3d12Device->CreateDescriptorHeap(&rtvHeapDesc, IID_PPV_ARGS(&m_rtvHeap))); m_rtvDescriptorSize = m_d3d12Device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_RTV); } // Create frame resources. { CD3DX12_CPU_DESCRIPTOR_HANDLE rtvHandle(m_rtvHeap->GetCPUDescriptorHandleForHeapStart()); // Create a RTV, D2D render target, and a command allocator for each frame. for (UINT n = 0; n < FrameCount; n++) { ThrowIfFailed(m_swapChain->GetBuffer(n, IID_PPV_ARGS(&m_renderTargets[n]))); m_d3d12Device->CreateRenderTargetView(m_renderTargets[n].Get(), nullptr, rtvHandle); // Create a wrapped 11On12 resource of this back buffer. Since we are // rendering all D3D12 content first and then all D2D content, we specify // the In resource state as RENDER_TARGET - because D3D12 will have last // used it in this state - and the Out resource state as PRESENT. When // ReleaseWrappedResources() is called on the 11On12 device, the resource // will be transitioned to the PRESENT state. D3D11_RESOURCE_FLAGS d3d11Flags = { D3D11_BIND_RENDER_TARGET }; ThrowIfFailed(m_d3d11On12Device->CreateWrappedResource( m_renderTargets[n].Get(), &d3d11Flags, D3D12_RESOURCE_STATE_RENDER_TARGET, D3D12_RESOURCE_STATE_PRESENT, IID_PPV_ARGS(&m_wrappedBackBuffers[n]) )); // Create a render target for D2D to draw directly to this back buffer. ComPtr<IDXGISurface> surface; ThrowIfFailed(m_wrappedBackBuffers[n].As(&surface)); ThrowIfFailed(m_d2dDeviceContext->CreateBitmapFromDxgiSurface( surface.Get(), &bitmapProperties, &m_d2dRenderTargets[n] )); rtvHandle.Offset(1, m_rtvDescriptorSize); ThrowIfFailed(m_d3d12Device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(&m_commandAllocators[n]))); } } }
HRESULT DWriteCreateResources(HDC hdc, wchar_t *text, HFONT hfont) { HRESULT hr = S_OK; // If the DirectWrite factory doesn't exist, create the resources, // only create these resources once. if (!g_pDWriteFactory) { HWND hwnd; RECT r; // DirectWrite variables. IDWriteFontFamily* pFontFamily = NULL; IDWriteFont* pFont = NULL; IDWriteLocalizedStrings* pFamilyNames = NULL; // Logical (GDI) font. LOGFONT lf = {}; UINT32 length = 0; UINT32 index = 0; float fontSize = 0; // length of the string UINT32 textLength = 0; wchar_t *name = NULL; // Get a handle to the DC and the window rect. hwnd = WindowFromDC(hdc); GetClientRect(hwnd, &r); // Calculate the string length. textLength = UINT32(wcslen(text)); // Create the DirectWrite factory. hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&g_pDWriteFactory) ); // Create a GDI interop interface. if (SUCCEEDED(hr)) { hr = g_pDWriteFactory->GetGdiInterop(&g_pGdiInterop); } if (SUCCEEDED(hr)) { // Get a logical font from the font handle. GetObject(hfont, sizeof(LOGFONT), &lf); } // Convert to a DirectWrite font. if (SUCCEEDED(hr)) { hr = g_pGdiInterop->CreateFontFromLOGFONT(&lf, &pFont); } // Get the font family. if (SUCCEEDED(hr)) { hr = pFont->GetFontFamily(&pFontFamily); } // Get a list of localized family names. if (SUCCEEDED(hr)) { hr = pFontFamily->GetFamilyNames(&pFamilyNames); } // Select the first locale. This is OK, because we are not displaying the family name. index = 0; // Get the length of the family name. if (SUCCEEDED(hr)) { hr = pFamilyNames->GetStringLength(index, &length); } if (SUCCEEDED(hr)) { // Allocate a new string. name = new (std::nothrow) wchar_t[length+1]; if (name == NULL) { hr = E_OUTOFMEMORY; } } // Get the actual family name. if (SUCCEEDED(hr)) { hr = pFamilyNames->GetString(index, name, length+1); } if (SUCCEEDED(hr)) { // Calculate the font size. fontSize = (float) -MulDiv(lf.lfHeight, 96, GetDeviceCaps(hdc, LOGPIXELSY)); } // Create a text format using the converted font information. if (SUCCEEDED(hr)) { hr = g_pDWriteFactory->CreateTextFormat( name, // Font family name. NULL, pFont->GetWeight(), pFont->GetStyle(), pFont->GetStretch(), fontSize, L"en-us", &g_pTextFormat ); } // Create a text layout. if (SUCCEEDED(hr)) { hr = g_pDWriteFactory->CreateTextLayout( text, textLength, g_pTextFormat, 1024.0f, 480.0f, &g_pTextLayout ); } // Underline and strikethrough are part of a LOGFONT structure, but are not // part of a DWrite font object so we must set them using the text layout. if(lf.lfUnderline) { DWRITE_TEXT_RANGE textRange = {0, textLength}; g_pTextLayout->SetUnderline(true, textRange); } if(lf.lfStrikeOut) { DWRITE_TEXT_RANGE textRange = {0, textLength}; g_pTextLayout->SetStrikethrough(true, textRange); } // Create a bitmap render target for our custom renderer. if (SUCCEEDED(hr)) { hr = g_pGdiInterop->CreateBitmapRenderTarget(hdc, r.right, r.bottom, &g_pBitmapRenderTarget); } // Create default rendering params for our custom renderer. if (SUCCEEDED(hr)) { hr = g_pDWriteFactory->CreateRenderingParams(&g_pRenderingParams); } if (SUCCEEDED(hr)) { // Initialize the custom renderer class. g_pGdiTextRenderer = new (std::nothrow) GdiTextRenderer(g_pBitmapRenderTarget, g_pRenderingParams); } // Clean up local interfaces. SafeRelease(&pFontFamily); SafeRelease(&pFont); SafeRelease(&pFamilyNames); } return hr; }
/// <summary> /// Ensure necessary Direct2d resources are created /// </summary> /// <returns>S_OK if successful, otherwise an error code</returns> HRESULT CBodyBasics::EnsureDirect2DResources() { HRESULT hr = S_OK; if (m_pD2DFactory && !m_pRenderTarget) { RECT rc; GetWindowRect(GetDlgItem(m_hWnd, IDC_VIDEOVIEW), &rc); int width = rc.right - rc.left; int height = rc.bottom - rc.top; D2D1_SIZE_U size = D2D1::SizeU(width, height); D2D1_RENDER_TARGET_PROPERTIES rtProps = D2D1::RenderTargetProperties(); rtProps.pixelFormat = D2D1::PixelFormat(DXGI_FORMAT_B8G8R8A8_UNORM, D2D1_ALPHA_MODE_IGNORE); rtProps.usage = D2D1_RENDER_TARGET_USAGE_GDI_COMPATIBLE; // Create a Hwnd render target, in order to render to the window set in initialize hr = m_pD2DFactory->CreateHwndRenderTarget( rtProps, D2D1::HwndRenderTargetProperties(GetDlgItem(m_hWnd, IDC_VIDEOVIEW), size), &m_pRenderTarget ); if (FAILED(hr)) { SetStatusMessage(L"Couldn't create Direct2D render target!", 10000, true); return hr; } hr = DWriteCreateFactory( DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&m_pDWriteFactory) ); static const WCHAR msc_fontName[] = L"Arial"; static const FLOAT msc_fontSize = 30; hr = m_pDWriteFactory->CreateTextFormat( msc_fontName, NULL, DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, msc_fontSize, L"", //locale &m_pTextFormat ); if (SUCCEEDED(hr)) { hr = m_pTextFormat->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_LEADING); } if (SUCCEEDED(hr)) { hr = m_pTextFormat->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER); } // light green m_pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(0.27f, 0.75f, 0.27f), &m_pBrushJointTracked); m_pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Yellow, 1.0f), &m_pBrushJointInferred); m_pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Green, 1.0f), &m_pBrushBoneTracked); m_pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Gray, 1.0f), &m_pBrushBoneInferred); m_pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Red, 0.5f), &m_pBrushHandClosed); m_pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Green, 0.5f), &m_pBrushHandOpen); m_pRenderTarget->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::Blue, 0.5f), &m_pBrushHandLasso); } return hr; }