3

For better visual appearance want to draw a black border around my text.

example pic

Currently i am drawing the same text 5 times.

If i want to draw the text on x = 5, y = 10 i would draw the text one time on the actual position.

Then i would draw the same text in black color with slightly other positions.

  1. x = 4, y = 10
  2. x = 5, y = 9

    ...

I can only imagine that this is bad performance wise. Or is this the correct way?

manlio
  • 18,345
  • 14
  • 76
  • 126
Tommy
  • 596
  • 6
  • 30

2 Answers2

1

I never did it the correct way myself, but it seems here they did it: http://www.codeproject.com/Articles/376597/Outline-Text-With-DirectWrite

Anton Angelov
  • 1,223
  • 7
  • 19
0

I do that too. But I suddenly realise there might be a better way (have not tried it yet): first draw in black with a slightly bigger size, and draw again in white with preferred size. Worth a try? Let me know how that goes.

Mike Versteeg
  • 1,615
  • 14
  • 28
  • Actually, I tried this method, but it turned out that is a problem with this approach - the longet the string is the wierder it loooks. The first letter in the string will have "outline" only on the left side, the last one will have it only on the right side, etc. It doesn't even do the trick for single letters. Imagine, for example, the letter "O" - the bigger one will generate the outer border well, but there will be no inner border, since it would actually require smaller font! You can try this in Photoshop and see how it works. – adlabac Feb 12 '15 at 08:38
  • Thanks. I was afraid it was too simple to be true! – Mike Versteeg Feb 12 '15 at 11:52