2009-07-15 28 views

回答

6

您可能正在尋找FormattedText.BuildGeometry MethodFormattedText.BuildHighlightGeometry Method;這兩個MSDN鏈接都以通常的例子爲特色。

基本使用模式是像這樣:

// Create sample formatted text. 
FormattedText formattedText = new FormattedText("Sample", 
    CultureInfo.GetCultureInfo("en-us"), FlowDirection.LeftToRight, 
    new Typeface("Verdana"), 16, System.Windows.Media.Brushes.Black); 

// Build geometry object that represents the text. 
Geometry normalGeometry = formattedText.BuildGeometry(
    new System.Windows.Point(0, 0)); 

// Build geometry object that represents the highlight bounding box of the text. 
Geometry highLightGeometry = formattedText.BuildHighlightGeometry(
    new System.Windows.Point(0, 0));