This example shows how to add font to resource for reports. First, Use
getFile()
method to load font file. After that, use
StiResource()
method to add it to resource:
<script type="text/javascript">
var designer = new Stimulsoft.Designer.StiDesigner(null, "StiDesigner", false);
var report = new Stimulsoft.Report.StiReport();
var fontFileContent = Stimulsoft.System.IO.File.getFile("../reports/Roboto-Black.ttf", true);
var resource = new Stimulsoft.Report.Dictionary.StiResource("Roboto-Black", "Roboto-Black", false, Stimulsoft.Report.Dictionary.StiResourceType.FontTtf, fontFileContent);
report.dictionary.resources.add(resource);
var page = report.pages.getByIndex(0);
//Create text component
var dataText = new Stimulsoft.Report.Components.StiText();
dataText.clientRectangle = new Stimulsoft.System.Drawing.Rectangle(1, 1, 3, 2);
dataText.text = "Sample Text";
dataText.font = new Stimulsoft.System.Drawing.Font("Roboto-Black");
dataText.border.side = Stimulsoft.Base.Drawing.StiBorderSides.All;
page.components.add(dataText);
designer.report = report;
</script>
На скриншоте ниже Вы можете увидеть результат выполнения данного кода: