bramp / js-sequence-diagrams

Draws simple SVG sequence diagrams from textual representation of the diagram
https://bramp.github.io/js-sequence-diagrams/
BSD 2-Clause "Simplified" License
7.81k stars 1.08k forks source link

waitForFont adds ~5 second delay #175

Open beaugunderson opened 7 years ago

beaugunderson commented 7 years ago

Noticed my diagrams were rendering very slowly. It appears that waitForFont takes time to load even if it's not doing any loading. I've just disabled it in my local version of the code but it might make sense to make it a configuration option if people don't want to incur the delay?

beaugunderson commented 7 years ago

I should note I'm using the snap-specific version of 2.0.1 with the default theme and the default font (Andale mono).

udondan commented 6 years ago

After upgrading js-sequence-diagrams this also happens for me, for drawings with the simple theme. The hand drawn theme is fine. I added this to the waitForFont method to render immediately:

      if(fontFamily != "danielbd") {
        callback();
        return;
      }

Complete method:

    waitForFont: function(callback) {
      var fontFamily = this.font_['font-family'];

      if (typeof WebFont == 'undefined') {
        throw new Error('WebFont is required (https://github.com/typekit/webfontloader).');
      }

      if(fontFamily != "danielbd") {
        callback();
        return;
      }

      if (LOADED_FONTS[fontFamily]) {
        // If already loaded, just return instantly.
        callback();
        return;
      }
vin-ni commented 6 years ago

Thank you!