[UWP]使用Direct2D进行DirectWrite渲染;削减字形

人气:977 发布:2022-09-22 标签: wpdevelop

问题描述

正如标题所说,我试图通过使用Direct2D的DrawTextLayout函数渲染DirectWrite布局,但问题是我的字形渲染都是不均匀和丑陋的,即使在更大的尺寸,并切入点在较小的尺寸上变得难以理解,我不能为我的生活找出原因。

I使用16左右的DIP,即便如此(这应该是标准的12pt大小),文字是残暴的。我猜这是我正在挑选字体的大小问题 - 在这种情况下,我想知道将点或像素转换为"DIP"的正确方法 - 或者这是我用于渲染器的渲染设置 - 在这种情况下,我想知道我应该更改哪些设置,因为我现在已经将所有设置都设置为默认值。

提前谢谢。

解决方案

我更喜欢UWP的Win2D nuget包了

https://microsoft.github.io/Win2D/html/QuickStart.htm

As the title says, I'm trying to render a DirectWrite layout by using Direct2D's DrawTextLayout function, but the problem is that my glyphs are rendered all uneven and ugly, even at bigger sizes, and cut to the point of becoming unreadable at smaller sizes, and I can't for the life of me figure out why this is.

I'm using 16 or so DIP and even then (this should be a standard 12pt size), the text is atrocious. I'm guessing this is a problem with the size I'm picking for the font - in which case, I'd like to know the correct way to convert points or pixels into those "DIP"s - or it's something about the render settings I'm using for the renderer - in which case I'd love to know what settings I should change, seeing as I have everything set to default right now.

Thank you in advance.

解决方案

I prefer the Win2D nuget package for UWP

https://microsoft.github.io/Win2D/html/QuickStart.htm

146