Adjusting inter-character spacing is possible in XAML by using the Glyphs class, specifically the Indices property. This is a pretty low-level text API, so you have to specify the font URI (rather than the family name), and you need to calculate all the spacings yourself.
The following XAML uses Glyph.Indices to apply inter-character spacing:
<Glyphs UnicodeString="Expanded" Indices=",100;,100;,100;,100;,100;,100;,100"
FontUri="file://c:/windows/fonts/arial.ttf"
Fill="Black" FontRenderingEmSize="24" />
<Glyphs UnicodeString="Normal"
FontUri="file://c:/windows/fonts/arial.ttf"
Fill="Black" FontRenderingEmSize="24" />
<Glyphs UnicodeString="Condensed" Indices=",60;,50;,50;,50;,45;,50;,40;,45"
FontUri="file://c:/windows/fonts/arial.ttf"
Fill="Black" FontRenderingEmSize="24" />
As documented here, the Indices property contains a semicolon-delimited list of chr,off
pairs. chr
is the index of the glyph within the font; if omitted, WPF will use the glyph corresponding to the current character in UnicodeString
. off
is the spacing between this glyph and the next; 0 displays the two on top of each other, any positive value increases the spacing. The "normal" spacing will depend on the font you're using; as you can see in the "Condensed" example, I used a different spacing for different pairs of characters to make the output look better.
Clearly this only applies to static text that you are displaying, and not input being collected from the user (in a TextBox
); I don't know of any way to adjust the inter-character spacing in the "standard" text objects (TextBlock
, TextBox
, Run
, etc.), so perhaps the answer is "No, there is not a way to do this in XAML".