Silverlight Character Spacing

What is the easiest way to control message spacing, kerning or tracking in Silverlight?

Arial currently has large headlines that have too many spaces between letters.

thank

+3
source share
2 answers

I don't know if this is the best solution, but it works fine for me:

SomeElement.Children.Add(LetterSpacing("Test", -3));

...

private Canvas LetterSpacing(string String, double Space)
    {
        Canvas kpr = new Canvas();
        char[] lters = String.ToCharArray();
        Label[] lbls = new Label[lters.Length];

        for (int i = 0; i < lters.Length; i++)
        {
            Label tmpLbl = new Label();
            lbls[i] = tmpLbl;
            kpr.Children.Add(lbls[i]);
            lbls[i].Content = lters[i];
            lbls[i].FontSize = 30;
            lbls[i].FontFamily = new FontFamily("Verdana");
        }

        Dispatcher.BeginInvoke(
            () =>
            {
                double leftPos = 0;
                for (int j = 0; j < lbls.Length; j++)
                {
                    Canvas.SetLeft(lbls[j], 0 + leftPos);
                    leftPos += (lbls[j].ActualWidth - (Space * -1));
                }
            });

        return kpr;
    }
+2
source

I do not think it is supported by runtime. You can export the text as a path and use it.

0
source

Source: https://habr.com/ru/post/1780325/


All Articles