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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With