Adding a Font to the Resource
Наши примеры проектов и шаблоны отчётов помогут Вам разобраться в основах работы с нашими продуктами.A custom font can be embedded into the report as a resource, so it travels with the template.
Registering the resource. Load or register the external resource before rendering so the finished report remains portable across environments.
The font file is read with
Registering the resource. Load or register the external resource before rendering so the finished report remains portable across environments.
@Component({
selector: "adding-font-to-the-resource",
imports: [Designer],
template: `<sti-designer [(report)]="report" [options]="designerOptions"></sti-designer>`
})
export class AddingFontToTheResource {
report: Stimulsoft.Report.StiReport;
designerOptions: Stimulsoft.Designer.StiDesignerOptions;
constructor() {
this.report = new Stimulsoft.Report.StiReport();
this.report.loadFile("Reports/CusomFontSimpleList.mrt");
var fileContent = Stimulsoft.System.IO.File.getFile("Fonts/LongCang-Regular.ttf", true);
var resource = new Stimulsoft.Report.Dictionary.StiResource("LongCang", "LongCang", false, Stimulsoft.Report.Dictionary.StiResourceType.FontTtf, fileContent);
this.report.dictionary.resources.add(resource);
this.designerOptions = new Stimulsoft.Designer.StiDesignerOptions();
this.designerOptions.appearance.fullScreenMode = true;
}
}The font file is read with
File.getFile, wrapped in a StiResource of type FontTtf and added to dictionary.resources. The font is then available inside the designer and in every export.