public void RenderTextOffscreen(string text) { // Clear the off-screen render target. deviceResources.D3DDeviceContext.ClearRenderTargetView(renderTargetView, new RawColor4(0f, 0f, 0f, 0f)); // Begin drawing with D2D. d2dRenderTarget.BeginDraw(); // Create a text layout to match the screen. SharpDX.DirectWrite.TextLayout textLayout = new SharpDX.DirectWrite.TextLayout(deviceResources.DWriteFactory, text, textFormat, textureWidth, textureHeight); // Get the text metrics from the text layout. SharpDX.DirectWrite.TextMetrics metrics = textLayout.Metrics; // In this example, we position the text in the center of the off-screen render target. Matrix3x2 screenTranslation = Matrix3x2.CreateTranslation( textureWidth * 0.5f, textureHeight * 0.5f + metrics.Height * 0.5f ); whiteBrush.Transform = screenTranslation.ToRawMatrix3x2(); // Render the text using DirectWrite. d2dRenderTarget.DrawTextLayout(new RawVector2(), textLayout, whiteBrush); // End drawing with D2D. d2dRenderTarget.EndDraw(); }