How to calculate the height of a FontFamily with Win2D (Line Spacing)?

删除回忆录丶 提交于 2019-12-06 19:44:56

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/42162481/how-to-calculate-the-height-of-a-fontfamily-with-win2d-line-spacing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!