Mega Code Archive

 
Categories / VB.Net Tutorial / WPF
 

Converting text to geometry

<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.vb Imports System Imports System.Collections.Generic Imports System.Text Imports System.Windows Imports System.Windows.Controls Imports System.Windows.Data Imports System.Windows.Documents Imports System.Windows.Input Imports System.Windows.Media Imports System.Windows.Media.Imaging Imports System.Windows.Shapes Imports System.Threading Namespace GlyphExamples   Public Partial Class GlyphClipping     Inherits System.Windows.Window     Public Sub New()       InitializeComponent()       Dim text As New FormattedText("CLIP!", Thread.CurrentThread.CurrentUICulture, FlowDirection.LeftToRight, New Typeface("Gill Sans Ultra Bold"), 20, Brushes.Black)       Dim textGeometry As Geometry = text.BuildGeometry(New Point(0, 0))       button1.Clip = textGeometry     End Sub   End Class End Namespace