Wpf 如何从FormattedText中仅获取大写X高度?

Wpf 如何从FormattedText中仅获取大写X高度?,wpf,formatted-text,Wpf,Formatted Text,我的结论是,这不可能做到,因为我似乎无法访问格式化文本对象的上升高度。作为粗略的近似值,我使用: public static double GetCapitalX(this FormattedText text) { double bottom = text.Height + text.OverhangAfter; // bottom most inked pixel /* this is wrong since the Extent inc

我的结论是,这不可能做到,因为我似乎无法访问格式化文本对象的上升高度。作为粗略的近似值,我使用:

public static double GetCapitalX(this FormattedText text)
    {
         double bottom = text.Height + text.OverhangAfter;      // bottom most inked pixel

        /* this is wrong since the Extent includes the ascender height. But it's the best I can do. */
         double capitalX = text.Extent - (bottom - text.Baseline);
         return capitalX;
    }
有更好更准确的方法吗?感谢您的帮助