Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 313
SuperJMN Avatar asked Feb 10 '17 15:02

SuperJMN


1 Answers

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.

like image 183
Chris Tophski Avatar answered Sep 22 '22 08:09

Chris Tophski