Font metrics for a Windows Universal app?

Question!

I have been trying for some time now to find the APIs in Windows 10 that would provide me all the information about font metrics I would need when developing a Universal App in C#.

The real problem I'm trying to solve is to draw text along a path. I already have code in place to identify the coordinates of a given point given a given distance along the path. What I currently lack is the ability to identify the proper distance between characters.

I'd also like to know the typeface characteristics such as leading, trailing, ascent, descent, etc... I believe that TextFormatter is no longer available or possibly, I don't know how to access it.

Can anyone help me by providing either an example or preferably the correct Microsoft documentation for the class I would need.

Thank you



Answers

The following works. It is hacky as hell, and I'm sure there is a better way. If you need the CanvasFontFace objects often, you had better cache them, as this is not a fast getter. Once you have the CanvasFontFace object, you can use it to find ascent, descent, etc.

public static CanvasFontFace FindFontFace() {
  // Very hacky . . . there has to be a better way . . .
  CanvasFontFace r = null;
  CanvasFontSet set = CanvasFontSet.GetSystemFontSet();
  string fontFaceName = "Regular"; // change to your face . . .
  string familyName = "Segoe UI"; // change to your family . . . 
  IReadOnlyList


This video can help you solving your question :)
By: admin