2009-11-01 13 views

risposta

8

Utilizzare IDWriteTextLayout::SetDrawingEffect per applicare effetti di disegno su intervalli secondari. Se stai usando DWrite con D2D DrawTextLayout, che suona come sei, allora quell'effetto disegno sarebbe solo un pennello (come ID2D1Brush tramite CreateSolidColorBrush o uno dei pennelli sfumati). Se hai implementato il tuo IDWriteTextRenderer per IDWriteTextLayout::Draw, l'effetto del disegno può essere qualsiasi cosa tu interpreti. Nel callback IDWriteTextRenderer::DrawGlyphRun, si chiama QueryInterface sul parametro drawingEffect oppure, se si è certi che sia il proprio tipo, è sufficiente eseguire static_cast direttamente.

// ... create the colored brushes and determine where to draw ... 
wchar_t const* text = L"Red Green"; 
dwriteFactory->CreateTextLayout(....., OUT &textLayout); 

DWRITE_TEXT_RANGE textRange1 = {0,3}, textRange2 = {4,5}; 

textLayout->SetDrawingEffect(redBrush, textRange1); 
textLayout->SetDrawingEffect(greenBrush, textRange2); 

renderer->DrawTextLayout(point, textLayout, defaultBrush); 
Problemi correlati