new function %font_exists()

+1 vote
asked Feb 25, 2022 in Wanted features by kirchsth (4,960 points)

based on https://forum.plantuml.net/10498/is-there-a-supported-way-to-specify-fall-back-fonts I expected that fall-back-fonts are working. But I checked it and it is not working on e.g. the PlantUML server (details see https://forum.plantuml.net/14842/specify-fall-back-fonts-is-not-working).

Is it possible to add a funcion like %font_exists() that I can implement in C4 a macro which works with png files too (it looks like that the fallback font works only with svg which supports css).

Thank you and best regards
Helmut

 

commented Feb 27, 2022 by kirchsth (4,960 points)
Hi @plantuml,
it could be that @martin found a possible fix for
https://forum.plantuml.net/14842/specify-fall-back-fonts-is-not-working.
Can you please try it.
If it would work this function is not required anymore.
Thank you and best regards
Helmut
commented Feb 28, 2022 by Martin (8,360 points)

@plantuml To recap on my theory.  UFont.java contains the following procedure:

  private static Font buildFont(String fontFamily, int fontStyle, int fontSize) {
    if (fontFamily.contains(",")) {
      for (String name : fontFamily.split(",")) {
        name = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(name).trim();
        if (doesFamilyExists(name)) {
          return new Font(fontFamily, fontStyle, fontSize);
        }
      }
    }
    return new Font(fontFamily, fontStyle, fontSize);
  }

This procedure seems to go to a lot of trouble to check each string of a comma separated list to see if it is an existing font family.  But then always returns the same result whatever.  As it stands everything before the final return statement could be deleted (unless I'm missing a subtlety).

My theory is that SVG can cope with the comma separated list, and maybe even evaluates it at display-time(?).  But that this doesn't happen for PNG.  So I wonder whether the procedure above should, for PNG only, return "name" rather than "fontFamily" for the first existing font family that it finds.

I could be completely wrong, I'm just linking a bit of seemingly redundant code to the fact that fallback fonts don't work for PNG.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:

[Antispam2 Feature: please please wait 1 or 2 minutes (this message will disappear) before pressing the button otherwise it will fail](--------)
To avoid this verification in future, please log in or register.
...