Adding a Font to the Resource
Unsere Beispiele der Projekte und Berichtsvorlagen helfen Ihnen, die Grundlagen der Arbeit mit unserer Software zu erlernen.This example shows how to add custom font to the resource. First, load and add a font to resources:
Next, add a font from resources to the font collection:
Finally, create a text component:
Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:

...
InitializeComponent();
// Loading and adding a font to resources
var fileContent = System.IO.File.ReadAllBytes("Fonts/Roboto-Black.ttf");
var resource = new StiResource("Roboto-Black", "Roboto-Black", false, StiResourceType.FontTtf, fileContent, false);
report.Dictionary.Resources.Add(resource);
...
Next, add a font from resources to the font collection:
...
// Adding a font from resources to the font collection
StiFontCollection.AddResourceFont(resource.Name, resource.Content, "ttf", resource.Alias);
...
Finally, create a text component:
...
// Creating a text component
var dataText = new StiText();
dataText.ClientRectangle = new RectangleD(1, 1, 3, 2);
dataText.Text = "Sample Text";
dataText.Font = StiFontCollection.CreateFont("Roboto-Black", 12, FontStyle.Regular);
dataText.Border.Side = StiBorderSides.All;
report.Pages[0].Components.Add(dataText);
...Auf dem Screenshot unten Sie können das Ergebnis des Beispiel-Codes ansehen:
