如何使用Win2D(行距)计算FontFamily的高度? [英] How to calculate the height of a FontFamily with Win2D (Line Spacing)?

查看:94
本文介绍了如何使用Win2D(行距)计算FontFamily的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在Windows Universal Application中使用Win2D计算给定字体的高度(及其属性,例如大小,粗细,样式...).

我以前使用过CanvasTextLayout,但是它需要文本才能工作,就像下面这样:

var ctl = new CanvasTextLayout(session, "Some text", new CanvasTextFormat(), constraintWidth, constraintHeight);

在我的情况下,我将没有文本,因为我要查找的是给定字体的所有字形的高度(包括其样式,大小,粗细... )合适.

编辑:我也尝试过使用CanvasFontFace类,但是似乎没有任何公共构造函数.

解决方案

但是您已经走对了.你看. G. fg作为文本. f分配上部区域,g分配下部区域,因此您可以获取画布当前字体中文本的总高度.

I would like to know how to calculate the height of a given a font (with its properties, like size, weight, style...) in a Window Universal Application using Win2D.

I previously used a CanvasTextLayout, but it requires a text to work, like in this line:

var ctl = new CanvasTextLayout(session, "Some text", new CanvasTextFormat(), constraintWidth, constraintHeight);

In my case, I will NOT have a text because what I'm looking for is the height in which all the glyphs of a given font (with its style, size, weight...) are fit.

EDIT: I have also tried with the CanvasFontFace class, but it seems it doesn't have any public constructor.

解决方案

But you are already on the right way. Use e. g. fg as text. The f allocates the upper area, the g the lower one, so you get the total height of a text in the current font of the canvas.

这篇关于如何使用Win2D(行距)计算FontFamily的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆