문제

I'm using DirectWrite (through SharpDX) to draw a TextLayout and it works as expected except for a couple things. I'm calling this TextLayout constructor:

http://sharpdx.org/documentation/api/m-sharpdx-directwrite-textlayout--ctor-2

My code is pretty straight forward:

// define 45 deg rotation matrix
var transformMatrix = new SharpDX.DirectWrite.Matrix();
transformMatrix.M11 = 0.7f;
transformMatrix.M12 = 0.7f;
transformMatrix.M21 = -0.7f;
transformMatrix.M22 = 0.7f;
transformMatrix.Dx = 0;
transformMatrix.Dy = 0;

var pixelsPerDip = 5;

var TextLayout = new SharpDX.DirectWrite.TextLayout(DWFactory, "Hello world!",
        TextFormat, 400, 200, pixelsPerDip, transformMatrix, true);

I can change the transform matrix to any values whatsoever but it has no effect on my output. I've also found that pixelsPerDip has no effect except for not drawing the text when I specify zero. I dug into the SharpDX source and these inputs seem to be handled correctly. What am I doing wrong?

The TextLayout constructor I'm using calls CreateGdiCompatibleTextLayout(). Is it possible that something else I'm doing/using is not GDI compatible which then causes my issues?

도움이 되었습니까?

해결책

The transform passed to the IDWriteTextLayout constructor only affects hinting/grid-fitting and subtle metrics of layout (and unless you need GDI compatible pixel aligned metrics, the other constructor to create a natural layout will give more accurate subpixel layout). To draw a text layout with a different orientation, you have to set the transform of whatever you are using to draw onto (SetTransform if you are using the D2D device context/render target or SetCurrentTransform if IDWriteBitmapRenderTarget).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top