Nevron .NET Vision
Framework / Presentation Layer / Graphics / Appearance Styles / Text Style / Text Style

In This Topic
    Text Style
    In This Topic

    Most of the objects visualized with Nevron Graphics have associated texts. The appearance of these texts is controlled by an instance of the NTextStyle class. Following is a list of the major text appearance aspects, controlled by this style:

    • font
    • text type - plain or XML formatted
    • text appearance - fill effect, shadow, border
    • text orientation
    • horizontal and vertical alignment relative to the text origin point
    • offset from the origin point
    • text backplane
    • depth order mode of the text

    The NTextStyle class is implemented as a composition of several more simple styles. These are:

    • NFontStyle - accessed from the FontStyle property. This style as its name suggest controls the font used to display the text.
    • NStringFormatStyle - accessed from the StringFormatStyle property. This style controls the text alingment.
    • NFillStyle - accessed from the FillStyle property. This style controls the text appearance.
    • NShadowStyle - accessed from the ShadowStyle property. This style controls the text shadow. By default the shadow is disabled.
    • NStrokeStyle - accessed from the StrokeStyle property. This style controls the text stoke. By default the stroke is disabled.
    • NBackplaneStyle - accessed from the BackplaneStyle property. This style controls the backplane rendered behind the text which may be useful to increase the text readability. By default the backplane is disabled.

    The following paragraphs show the most common operations with the NTextStyle object.

     Changing the Font

    The FontStyle property is the most important property of the NTextStyle class, because it gives you full control over the font used to display the text. The default font used in Nevron controls is Arial 9pt, but some objects can modify it. For example the header and footer labels in the chart use Arial 12pt. The code below changes the font to "Tahoma", 13pt:

    C#
    Copy Code
    someObject.TextStyle.FontStyle.Name = "Tahoma";
    someObject.TextStyle.FontStyle.EmSize = new NLength(13, NGraphicsUnit.Point);
    
    Visual Basic
    Copy Code
    someObject.TextStyle.FontStyle.Name = "Tahoma"
    someObject.TextStyle.FontStyle.EmSize = New NLength(13, NGraphicsUnit.Point)
    
    Note that it is recommended to use relative measurement units (like point, parent percentage etc.) instead of pixels, because they will scale better when you print the control.
     Changing the Fill Style

    The filling of the text is controlled by the FillStyle property of the NTextStyle class. This property allows you to apply solid color, gradient, image, hatch or advanced gradient fill style to the text object. The following code sets a solid color for the text:

    C#
    Copy Code
    someObject.TextStyle.FillStyle = new NColorFillStyle(Color.Aqua);
    
    Visual Basic
    Copy Code
    someObject.TextStyle.FillStyle = new NColorFillStyle(Color.Aqua)
    
     Changing the Backplane Style

    You can use the backplane style of the text for various purposes for example to draw the user attention to the text or to increase the readability. A typical case is if you have a dark background color and the text color is black. In this case you have to enable the text backplane, because otherwise the text will simply merge with the background and become unreadable. The text backplane is represented by the NBackplaneStyle object accessible from the BackplaneStyle property of the NTextStyle:

    C#
    Copy Code
    someObject.TextStyle.BackplaneStyle.Visible = true;
    someObject.TextStyle.BackplaneStyle.FillStyle = new NColorFillStyle(Color.Red);
    
    Visual Basic
    Copy Code
    someObject.TextStyle.BackplaneStyle.Visible = True
    someObject.TextStyle.BackplaneStyle.FillStyle = new NColorFillStyle(Color.Red)
    
     Offsetting Texts from the Base Point

    When rendering texts the control automatically calculates the coordinates where texts should appear. These coordinates are called base points and are dependent on the scene logic. For example when you have a bar chart it will position the base points for the bar label texts at the top of each bar. The origin point of a text is always specified relative to the base point. This is achieved with the help of the Offset property of the text. It is defined by a NPointL  structure allowing you to move the text relative to its base point. The following example offsets the origin point of a text from its base point with ten points (right and down):

    C#
    Copy Code
    someObject.TextStyle.Offset = new NPointL(new NLength(10, NGraphicsUnit.Pixel), new NLength(10, NGraphicsUnit.Point));
    
    Visual Basic
    Copy Code
    someObject.TextStyle.Offset = New NPointL(New NLength(10, NGraphicsUnit.Pixel), New NLength(10, NGraphicsUnit.Point))
    
     Changing the Text Orientation

    Text orientation is specified with the Orientation property of the NTextStyle class rather than with the orientation property of the associated font. The Orientation property is specified in degrees (counter clockwise) and by default is 0. The example below creates a vertically oriented text:

    C#
    Copy Code
    someObject.TextStyle.Orientation = 90;
    
    Visual Basic
    Copy Code
    someObject.TextStyle.Orientation = 90
    
     Changing Texts Z Order

    When texts are displayed in 3D they also have an associated depth coordinate (Z order). In certain cases you may wish to push texts in front of all other objects. This is very helpful if you want to increase readability and that's why this feature is enabled by default. The following will instruct text control to render with the original depth value.

    C#
    Copy Code
    someObject.TextStyle.TextOverlapsImage = false;
    
    Visual Basic
    Copy Code
    someObject.TextStyle.TextOverlapsImage = False
    
    See Also