2

I want to draw a wavy underline allows FormattedText. I was set formattedtext.Set TextDecorations but when resizing fonts wavylines wrong.

i write:

var geometry = new StreamGeometry();
using (var context = geometry.Open())
{
    context.BeginFigure(new Point(0.0, 1), false, false);
    context.PolyLineTo(new[] {
        new Point(1.5, 0),
        new Point(3, 3),
        new Point(4.5, 1.5),
        new Point(6, 0),
        new Point(7.5, 3),
        new Point(9, 1.5)
    }, true, true);
}

var brushPattern = new GeometryDrawing
{
    Pen = new System.Windows.Media.Pen(System.Windows.Media.Brushes.Black, 1),
    Geometry = geometry
};

var brush = new DrawingBrush(brushPattern)
{
    TileMode = TileMode.Tile,
    Viewport = new Rect(0, 0, 9, 4),
    ViewportUnits = BrushMappingMode.Absolute,
    Viewbox = new Rect(0, 0, 9, 4),
    ViewboxUnits = BrushMappingMode.Absolute,
    Stretch = Stretch.Fill
};
System.Windows.TextDecoration squiggly = new System.Windows.TextDecoration();
squiggly.Pen = new System.Windows.Media.Pen(brush, 1.2);

Can you help me?

Vadim Martynov
  • 8,602
  • 5
  • 31
  • 43
Le Ngoc Loan
  • 176
  • 2
  • 2
  • 12
  • can you describle the different between what you expect and what you get when change font size? – NoName Mar 02 '16 at 11:04
  • I found this [SO question](http://stackoverflow.com/questions/632450/wavy-underlines-in-a-flowdocument) on how to do that effect with FlowDocument elements, but you might be able to reuse the xaml for your purposes – Gordon Allocman Mar 02 '16 at 19:03
  • Hello. but each with a font size difference ViewBox, viewport and polyline, I'd call ViewBox, viewport , just polyline in each font size – Le Ngoc Loan Mar 03 '16 at 01:53

0 Answers0