locked
Outline text control - alignment RRS feed

  • Question

  • I'm using a component called OutlineTextControl (downloaded from here), that is based on MSDN code examples for creating text with an outline by converting the text to a geometry object. The control does just what I want, but I have big problems when trying to align my OutlineTextControl objects. The first action I have taken to solve this is setting the height and width of the OutlineTextControl, which inherits from FrameworkElement, to the height and width of the Geometry object that is the converted text.

    This however does not solve the problem completely. I make presentation displays that present a lot of numbers, and when a number contains a "1" it is still aligned wrong. It is very annoying... Has anyone else run into similar problems?

    Or: Is there any other way to create outlined text? I have tried using text effects, such as outer glow, but they don't do the job well enough. I want black text with a sharp white edge, that makes it readable on any background (for example red).
    Friday, August 1, 2008 8:21 AM

Answers

  • Try to add this to original control:

    protected override Size MeasureOverride(Size a) 
      return _textHighLightGeometry.Bounds.Size; 

    And comment out this:

    public void CreateText() 
      ... 
     
      // Build the geometry object that represents the text hightlight. 
      // if (Highlight == true) 
      // { 
           _textHighLightGeometry = formattedText.BuildHighlightGeometry(new Point(0, 0)); 
      // } 
     


    Developer
    • Edited by Ilya Margolin Saturday, August 2, 2008 9:53 PM strange artifacts
    • Proposed as answer by Ilya Margolin Saturday, August 2, 2008 9:54 PM
    • Marked as answer by Oskar L Monday, August 4, 2008 8:40 AM
    Saturday, August 2, 2008 9:51 PM

All replies

  • Try to add this to original control:

    protected override Size MeasureOverride(Size a) 
      return _textHighLightGeometry.Bounds.Size; 

    And comment out this:

    public void CreateText() 
      ... 
     
      // Build the geometry object that represents the text hightlight. 
      // if (Highlight == true) 
      // { 
           _textHighLightGeometry = formattedText.BuildHighlightGeometry(new Point(0, 0)); 
      // } 
     


    Developer
    • Edited by Ilya Margolin Saturday, August 2, 2008 9:53 PM strange artifacts
    • Proposed as answer by Ilya Margolin Saturday, August 2, 2008 9:54 PM
    • Marked as answer by Oskar L Monday, August 4, 2008 8:40 AM
    Saturday, August 2, 2008 9:51 PM
  • I think that did the trick! Great! Thank you so much!
    Monday, August 4, 2008 6:24 AM