5

FormattedText文字列をジオメトリベースのオブジェクトに変換するにはどうすればよいですか?

この質問は多くの説明を必要としないと思います、そして私が与えることができる他の多くの詳細があるかどうか私は考えることができません...

FormattedTextを数学的に(幾何学的に)使用できるものに変換する必要があります。

アドバイスをいただければ幸いです。

4

1 に答える 1

7

あなたはおそらく探している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));
于 2009-07-15T23:37:36.087 に答える