Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing DWriteMeasuringMode for DrawTextLayout

I am currently drawing text in DirectWrite using DrawText.

On my switch to DrawTextLayout i noticed that the rendering of aliased letters isn't done nicely.

Is there a way to change the measurement mode like we can do in DrawText to DWRITE_MEASURING_MODE_GDI_CLASSIC

Top text is drawn with DrawText (and DWRITE_MEASURING_MODE_GDI_CLASSIC), bottom with DrawTextLayout.

http://img5.fotos-hochladen.net/uploads/wwwwwwwww3b9zou6icp.jpg

http://img5.fotos-hochladen.net/uploads/xxxxxxxag8pdm5h2e.jpg

As you can see the character spacing isn't nice in the bottom text.

If i set the measuring mode of DrawText to DWRITE_MEASURING_MODE_NATURAL i have the exact same result like drawing with TextLayout. So the problem is the measuring mode which i don't know how to change.

like image 488
Sawyer Avatar asked Dec 15 '25 08:12

Sawyer


1 Answers

Got it working.

I totally didn't see that function:

DWriteFactory.CreateGdiCompatibleTextLayout

However when using Delphi they messed up the params as stated here:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd368192%28v=vs.85%29.aspx

For whatever reason they refure to fix that as it was reported in 2013:

http://qc.embarcadero.com/wc/qcmain.aspx?d=112581

like image 95
Sawyer Avatar answered Dec 16 '25 23:12

Sawyer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!