我的结论是,由于我似乎无法访问formattedtext对象的ascender高度,因此无法完成此操作。作为粗略的近似,我正在使用:
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;
}
有更好(更准确)的方式吗?任何帮助表示赞赏。