Converting text to geometry : Geometry « Windows Presentation Foundation « C# / CSharp Tutorial






<Window x:Class="GlyphExamples.GlyphClipping"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Glyph Clipping" Height="300" Width="300">
    <Grid HorizontalAlignment="Center" VerticalAlignment="Center" Width="64">
      <Grid.LayoutTransform>
        <ScaleTransform ScaleX="4" ScaleY="4" />
      </Grid.LayoutTransform>
      <Button x:Name="button1" Content="Click" />
    </Grid>
</Window>

//File:Window.xaml.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Threading;

namespace GlyphExamples
{
    public partial class GlyphClipping : System.Windows.Window
    {
        public GlyphClipping()
        {
            InitializeComponent();
            FormattedText text = new FormattedText("CLIP!",
                Thread.CurrentThread.CurrentUICulture,
                FlowDirection.LeftToRight,
                new Typeface("Gill Sans Ultra Bold"),
                20,
                Brushes.Black);

            Geometry textGeometry = text.BuildGeometry(new Point(0, 0));
            button1.Clip = textGeometry;
        }
    }
}
WPF Converting Text To Geometry








24.105.Geometry
24.105.1.LineGeometryLineGeometry
24.105.2.EllipseGeometryEllipseGeometry
24.105.3.RectangleGeometryRectangleGeometry
24.105.4.Animate GeometryDrawing ExamplesAnimate GeometryDrawing Examples
24.105.5.CombinedGeometry for Path.Data and DrawingBrush for Path.FillCombinedGeometry for Path.Data and DrawingBrush for Path.Fill
24.105.6.Combines two geometries using the XOR combine modeCombines two geometries using the XOR combine mode
24.105.7.Combines two geometries using the union combine modeCombines two geometries using the union combine mode
24.105.8.Combines two geometries using the exclude combine modeCombines two geometries using the exclude combine mode
24.105.9.Geometry Transform for RectangleGeometry Transform for Rectangle
24.105.10.Geometry Transform for PathGeometry Transform for Path
24.105.11.Geometry Used with a DrawingBrushGeometry Used with a DrawingBrush
24.105.12.Geometry Used as a ClipGeometry Used as a Clip
24.105.13.Tiled GeometryTiled Geometry
24.105.14.Ellipse Geometry DemoEllipse Geometry Demo
24.105.15.LineGeometry DemoLineGeometry Demo
24.105.16.Use PolyBezierSegment to Simulated CircleUse PolyBezierSegment to Simulated Circle
24.105.17.Converting text to geometryConverting text to geometry
24.105.18.Use a PathGeometry object to highlight displayed text.Use a PathGeometry object to highlight displayed text.
24.105.19.Shape ExcludeShape Exclude
24.105.20.Shape XorShape Xor
24.105.21.Shape UnionShape Union