8

How do I change the character spacing in a WPF application within a textblock. Also known as kerning or tracking for characters.

anton2g
  • 923
  • 6
  • 12
  • 29
  • "Also known as kerning" Kerning is enabled by default and should not be confused with letter spacing (tracking), as kerning is specifically the adjustment between certain _pairs_ of letters like A and V (bringing them closer together using distance adjustments inside the font). Letter spacing on the other hand is a _global_ adjustment to all character clusters, which is what it sounds like you want. The CharacterSpacing property exists for Windows 8, but I'm unsure if it is available in your version of WPF. – Dwayne Robinson Oct 09 '14 at 23:21

2 Answers2

9

An answer on social.msdn suggests the use of Glyphs.

Other than that FontStretch allows for some adjustment.

H.B.
  • 166,899
  • 29
  • 327
  • 400
  • 2
    FontStretch is a font selection property that works **if** that font family supports thinner and wider variants, but not all do. Arial Narrow is one such well-known one. – Dwayne Robinson Oct 09 '14 at 23:19
  • Arial Narrow appears to ignore the setting when I try it? – user230910 Feb 15 '17 at 11:37
  • @user230910: As Dwayne Robinson already pointed out: Not all fonts support this. – H.B. Feb 15 '17 at 15:41
  • I understand, but from your comment I understood that Arial Narrow supported it. No problem, just wanted to help future readers :) – user230910 Feb 16 '17 at 09:37
-2

Maybe you can add a Behavior for that TextBox that would go over every character and add a space after it.

Alternatively, If you're using DataBinding, use a Converter with the same logic.

And if you want to go for an overkill, you can make a custom control, that will inherit from TextBox and implement that spacing logic That would also allow you to add a Dependency Property, something like "NumOfSpaces" and you could control how many spaces it would put

Notter
  • 588
  • 4
  • 16
  • 1
    Character spacing, or kerning/tracking as anton2g correctly mentions, is not about adding one or more spaces between the characters in the text, but rather about much more fine grained adjustment. To quote Wikipedia: In typography, kerning (less commonly mortising) is the process of adjusting the spacing between characters in a proportional font, usually to achieve a visually pleasing result. Kerning adjusts the space between individual letter forms, while tracking (letter-spacing) adjusts spacing uniformly over a range of characters. http://en.wikipedia.org/wiki/Kerning – d7samurai Aug 15 '13 at 00:08