SimpleFont

View as Markdown

Definition

Defines a particular font configuration.

Note: SimpleFont objects are used for various Drawing methods, and can be used when defining UI element for Add-ons.

Constructors

ConstructorDescription
SimpleFont()Creates a SimpleFont object using a family name of “Arial” and a size of “12”
SimpleFont(string familyName, int size)Creates a SimpleFont object using the specified family name and size

Methods and Properties

PropertyDescription
BoldA bool value determining if the Font is bold style
FamilyA FontFamily representing a family of Fonts
ItalicA bool value determining if the Font is italic style
SizeA double value determining the size of font in WPF units (please see the tip below)
TypefaceA Typeface used to represent the variation of the font used
ApplyTo()Applies a custom SimpleFont object’s properties (family, size, and style) to a Windows Control
ToDirectWriteTextFormat()Converts a SimpleFont object to a SharpDX compatible font which can be used for chart rendering.

The WPF unit used is the default px one, so device independent pixels. With a default system DPI setting of 96, the physical pixel on the screen would be identical in size, but can vary if a custom DPI is employed. Both should not be confused with the points based font sizing known from other familiar Windows applications like Word, the advantage here is that the non points based size measurement will increase / decrease in size if the system DPI is changed - a more detailed discussion is located here.

Examples

1// create custom Courier New, make it big and bold
2NinjaTrader.Gui.Tools.SimpleFont myFont = new NinjaTrader.Gui.Tools.SimpleFont("Courier New", 12) { Size = 50, Bold = true };
3
4Draw.Text(this, "myTag", false, "Hi There!", 0, Low[0], 5, Brushes.Blue, myFont, TextAlignment.Center, Brushes.Black, null, 1);