简体   繁体   English

无论如何,我可以在Directwrite TextLayout中将宽度和布局宽度设置为相同吗?

[英]Is there anyway I could set width and layout width to be the same in Directwrite TextLayout?

Whenever I render a text using text layout object, it's apparent that actual width of text is not same as the width of layout depending on enable option in text wrapping. 每当我使用文本布局对象渲染文本时,很明显文本的实际宽度与布局的宽度不同,这取决于文本环绕中的启用选项。

I would like to know if there is anyway I could do to set width and layout width to be the same? 我想知道是否可以将宽度和布局宽度设置为相同?

So When I pass in width and height in a creation of text layout object, I want it to render the text in the exact dimension I provided. 因此,当我在创建文本布局对象时传入宽度和高度时,我希望它以我提供的确切尺寸呈现文本。

Initial layout dimensions are used to control word wrapping or trimming, if enabled. 如果启用,则初始布局尺寸用于控制自动换行或修剪。 So it depends on what you want to achieve, normally you set desired layout box, and text does not have to fit or fully fill to any degree. 因此,这取决于您要实现的目标,通常您可以设置所需的布局框,并且文本不必在任何程度上适合或完全填充。 When rendering you might be interested in effective rectangle that your text fits in fully, you need to call GetMetrics for that, and use returned DWRITE_TEXT_METRICS struct fields. 渲染时,您可能对文本完全适合的有效矩形感兴趣,您需要为此调用GetMetrics ,并使用返回的DWRITE_TEXT_METRICS结构字段。 Metrics data will contain actual rectangle sizes for your text, regardless of what you specified on layout creation. 指标数据将包含文本的实际矩形大小,无论您在布局创建时指定了什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM