FontStyle
enum cAlgo.API
DesktopCLICloud
Specifies style information applied to text.
Definition
public enum FontStyle
Namespace: cAlgo.API · Group: Styles
Examples
using cAlgo.API;
namespace cAlgo
{
// This sample shows how to use a chart control font properties to set font size, style, and family
public partial class FontSample : Indicator
{
protected override void Initialize()
{
var stackPanel = new StackPanel
{
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
BackgroundColor = Color.Gold,
Opacity = 0.6
};
stackPanel.AddChild(new TextBlock
{
Text = "Thin Weight Size 10 FontStyle Normal Font Default",
FontSize = 10,
FontWeight = FontWeight.Thin,
FontStyle = FontStyle.Normal,
ForegroundColor = Color.Black,
Margin = 10
});
stackPanel.AddChild(new TextBlock
{
Text = "Thin Weight Size 10 FontStyle Italic Font Default",
FontSize = 10,
FontWeight = FontWeight.Thin,
FontStyle = FontStyle.Italic,
ForegroundColor = Color.Black,
Margin = 10
});
stackPanel.AddChild(new TextBlock
{
Text = "Thin Weight Size 10 FontStyle Oblique Font Default",
FontSize = 10,
FontWeight = FontWeight.Thin,
FontStyle = FontStyle.Oblique,
ForegroundColor = Color.Black,
Margin = 10
});
stackPanel.AddChild(new TextBlock
{
Text = "Black Weight Size 10 FontStyle Normal Font Default",
FontSize = 10,
FontWeight = FontWeight.Black,
FontStyle = FontStyle.Normal,
ForegroundColor = Color.Black,
Margin = 10
});
stackPanel.AddChild(new TextBlock
{
Text = "Bold Weight Size 10 FontStyle Normal Font Default",
FontSize = 10,
FontWeight = FontWeight.Bold,
FontStyle = FontStyle.Normal,
ForegroundColor = Color.Black,
Margin = 10
});
stackPanel.AddChild(new TextBlock
{
Text = "Heavy Weight Size 10 FontStyle Normal Font Default",
FontSize = 10,
FontWeight = FontWeight.Heavy,
FontStyle = FontStyle.Normal,
ForegroundColor = Color.Black,
Margin = 10
});
stackPanel.AddChild(new TextBlock
{
Text = "Bold Weight Size 12 FontStyle Normal Font Default",
FontSize = 12,
FontWeight = FontWeight.Bold,
FontStyle = FontStyle.Normal,
ForegroundColor = Color.Black,
Margin = 10
});
stackPanel.AddChild(new TextBlock
{
Text = "Thin Weight Size 12 FontStyle Normal Font Calibri Light Italic",
FontSize = 12,
FontWeight = FontWeight.Thin,
FontStyle = FontStyle.Normal,
ForegroundColor = Color.Black,
FontFamily = "Calibri Light Italic",
Margin = 10
});
Chart.AddControl(stackPanel);
}
public override void Calculate(int index)
{
}
}
}
import clr
clr.AddReference("cAlgo.API")
from cAlgo.API import *
class Test():
def get_text_block(self, text, fontSize, fontWeight, fontStyle, fontFamily = None):
textBlock = TextBlock()
textBlock.Text = text
textBlock.FontSize = fontSize
textBlock.FontWeight = fontWeight
textBlock.FontStyle = fontStyle
textBlock.ForegroundColor = Color.Black
textBlock.Margin = Thickness(10)
if fontFamily is not None:
textBlock.FontFamily = fontFamily
return textBlock
def initialize(self):
stackPanel = StackPanel()
stackPanel.HorizontalAlignment = HorizontalAlignment.Center
stackPanel.VerticalAlignment = VerticalAlignment.Center
stackPanel.BackgroundColor = Color.Gold
stackPanel.Opacity = 0.6
stackPanel.AddChild(self.get_text_block("Thin Weight Size 10 FontStyle Normal Font Default", 10, FontWeight.Thin, FontStyle.Normal))
stackPanel.AddChild(self.get_text_block("Thin Weight Size 10 FontStyle Italic Font Default", 10, FontWeight.Thin, FontStyle.Italic))
stackPanel.AddChild(self.get_text_block("Thin Weight Size 10 FontStyle Oblique Font Default", 10, FontWeight.Thin, FontStyle.Oblique))
stackPanel.AddChild(self.get_text_block("Black Weight Size 10 FontStyle Normal Font Default", 10, FontWeight.Black, FontStyle.Normal))
stackPanel.AddChild(self.get_text_block("Bold Weight Size 10 FontStyle Normal Font Default", 10, FontWeight.Bold, FontStyle.Normal))
stackPanel.AddChild(self.get_text_block("Heavy Weight Size 10 FontStyle Normal Font Default", 10, FontWeight.Heavy, FontStyle.Normal))
stackPanel.AddChild(self.get_text_block("Bold Weight Size 12 FontStyle Normal Font Default", 12, FontWeight.Bold, FontStyle.Normal))
stackPanel.AddChild(self.get_text_block("Thin Weight Size 12 FontStyle Normal Font Calibri Light Italic", 12, FontWeight.Thin, FontStyle.Normal, "Calibri Light Italic"))
api.Chart.AddControl(stackPanel)
{
"AccessRights": "None",
"TimeZone": "UTC",
"IsOverlay": true
}
Values
| Name | Value | Description |
|---|---|---|
Normal | 0 | Normal text. |
Oblique | 1 | Oblique text. |
Italic | 2 | Italic text. |