Skip to content

Latest commit

 

History

History
61 lines (46 loc) · 2.72 KB

File metadata and controls

61 lines (46 loc) · 2.72 KB

Custom font

DISCLAIMER: this extension point is very experimental and is subject to change.
In particular, the way of changing the defaults will be done via configuration in the future.

Javascript example

♻️ BPMN Visualization Usage

Override the BPMN element fonts using various ways. mxGraph knowledge is required to handle style changes. See the development documentation for more details.

⚠️To avoid having to many content in the README, we simplify it. You can find all the content of the example in index.js.

ℹ Generally, the style keys and values constants are related to the mxConstants object that comes from mxGraph. For reference, see the mxConstants API.
We are using FontStyle and StyleIdentifiers here that store the constants string values. They are defined in style-identifier.js. But you can also use the string value directly, for instance style['fontStyle']=....

Content:

  • override default font:
    • update the StyleDefault default values
  StyleDefault.DEFAULT_FONT_SIZE = '12';
  StyleDefault.DEFAULT_FONT_FAMILY = 'Courier New,serif';
  • update the StyleConfigurator method
StyleConfigurator.configureCommonDefaultStyle = function (style) {
    originalConfigureCommonDefaultStyle(style);
    style[StyleIdentifiers.STYLE_FONTSTYLE] = FontStyle.FONT_ITALIC;
}
  • different fonts for event, gateway and task: extend the lib class entry point
class BpmnVisualizationCustomFonts extends BpmnVisualization {

    constructor(containerId) {
        super({ container: containerId });
        this.configureStyle();
    }

    configureStyle() {
        const styleSheet = this.graph.getStylesheet(); // mxStylesheet

        const userTaskStyle = styleSheet.styles[ShapeBpmnElementKind.TASK_USER];
        userTaskStyle[StyleIdentifiers.STYLE_FONTFAMILY] = 'Courier New,serif';
        userTaskStyle[StyleIdentifiers.STYLE_FONTSIZE] = '14';
        userTaskStyle[StyleIdentifiers.STYLE_FONTSTYLE] = FontStyle.FONT_BOLD + FontStyle.FONT_ITALIC;
    }
}

const bpmnVisualizationCustomFonts = new BpmnVisualizationCustomFonts('bpmn-container-custom-fonts');

Note: for example about font colors, see the custom-colors example.