Draw Text Using Glyphs
.NET Framework 4.5
This topic explains how to use the low-level Glyphs object to display text in Extensible Application Markup Language (XAML).
The following examples show how to define properties for a Glyphs object in Extensible Application Markup Language (XAML). The Glyphs object represents the output of a GlyphRun in XAML. The examples assume that the Arial, Courier New, and Times New Roman fonts are installed in the C:\WINDOWS\Fonts folder on the local computer.
<!-- The example shows how to use a Glyphs object. --> <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <StackPanel Background="PowderBlue"> <Glyphs FontUri = "C:\WINDOWS\Fonts\TIMES.TTF" FontRenderingEmSize = "100" StyleSimulations = "BoldSimulation" UnicodeString = "Hello World!" Fill = "Black" OriginX = "100" OriginY = "200" /> </StackPanel> </Page>
This example shows how to define other properties of Glyphs objects in XAML.
<!-- The example shows how to use different property settings of Glyphs objects. --> <Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Background="PowderBlue" > <Glyphs FontUri = "C:\WINDOWS\Fonts\ARIAL.TTF" FontRenderingEmSize = "36" StyleSimulations = "ItalicSimulation" UnicodeString = "Hello World!" Fill = "SteelBlue" OriginX = "50" OriginY = "75" /> <!-- "Hello World!" with default kerning --> <Glyphs FontUri = "C:\WINDOWS\Fonts\ARIAL.TTF" FontRenderingEmSize = "36" UnicodeString = "Hello World!" Fill = "Maroon" OriginX = "50" OriginY = "150" /> <!-- "Hello World!" with explicit character widths for proportional font --> <Glyphs FontUri = "C:\WINDOWS\Fonts\ARIAL.TTF" FontRenderingEmSize = "36" UnicodeString = "Hello World!" Indices = ",80;,80;,80;,80;,80;,80;,80;,80;,80;,80;,80" Fill = "Maroon" OriginX = "50" OriginY = "225" /> <!-- "Hello World!" with fixed-width font --> <Glyphs FontUri = "C:\WINDOWS\Fonts\COUR.TTF" FontRenderingEmSize = "36" StyleSimulations = "BoldSimulation" UnicodeString = "Hello World!" Fill = "Maroon" OriginX = "50" OriginY = "300" /> <!-- "Open file" without "fi" ligature --> <Glyphs FontUri = "C:\WINDOWS\Fonts\TIMES.TTF" FontRenderingEmSize = "36" StyleSimulations = "BoldSimulation" UnicodeString = "Open file" Fill = "SlateGray" OriginX = "400" OriginY = "75" /> <!-- "Open file" with "fi" ligature --> <Glyphs FontUri = "C:\WINDOWS\Fonts\TIMES.TTF" FontRenderingEmSize = "36" StyleSimulations = "BoldSimulation" UnicodeString = "Open file" Indices = ";;;;;(2:1)191" Fill = "SlateGray" OriginX = "400" OriginY = "150" /> </Canvas>