/
Working with Fonts in Javascript
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 +']');
, multiple selections available,
Related content
Getting started with your JavaScript integration
Getting started with your JavaScript integration
Read with this
Fonts XML
Fonts XML
More like this
Document Object Model
Document Object Model
Read with this
Document Object Model - Font
Document Object Model - Font
More like this
JavaScript Events
JavaScript Events
Read with this
Colors XML
Colors XML
More like this
All information on this page must be treated as External Restricted, or more strict. https://www.chili-publish.com/security