Information Classification: External Restricted.
See https://www.chili-publish.com/security

Working with Fonts in Javascript

Add New Fonts to the Document

You can build a customized UI for adding fonts to a CHILI document. The fonts has to exist within the CHILI backoffice resource Fonts folder 

//font details
fID = '768e6dcd-e8b1-42c8-a0bc-0740e320cbf0';
fFamily = "Alero";
fStyle = "Regular";
fName = fFamily + ' ' + fStyle;
//adding fonts
var newFont = editor.ExecuteFunction('document.fonts','Add');
//Displayed name + style in editor
editor.SetProperty('document.fonts[' + newFont.id + ']','family',fFamily);
editor.SetProperty('document.fonts[' + newFont.id + ']','style',fStyle);
editor.SetProperty('document.fonts[' + newFont.id + ']','name',fName);
//Setting the font ID (works for the preview)
editor.SetProperty('document.fonts[' + newFont.id + ']','id',fID);

 

Change Selected Text's Font Size

 editor.SetPoperty('document.selectedText.textFormat','fontSize','20');

Change Selected Text's Font 

 var fntTrade = editor.GetObject('document.fonts[TradeGothic Medium]');
editor.SetProperty('document.selectedText.textFormat','font','cp_object:document.fonts['+ fntTrade.id +']'); 

All information on this page must be treated as External Restricted, or more strict. https://www.chili-publish.com/security