archimatetool / archi

Archi: ArchiMate Modelling Tool
https://www.archimatetool.com
MIT License
914 stars 267 forks source link

Image export to SVG cuts off far most right letter, no matter of box the width #973

Closed ngulden closed 8 months ago

ngulden commented 8 months ago

Version of Archi

5.2.0

Archi Plug-ins

Operating System

Expected Behaviour

The SVG export produces SVG files that show all text in the concepts.

How it looks in ArchiMate:

Bildschirmfoto vom 2023-10-11 09-21-39

Actual Behaviour

The SVG export produces SVG files, where the far most right letter is cut off in the concept boxes, although there is enough space. Increasing the box size, doesn't help either.

How it looks in the exported SVG:

Bildschirmfoto vom 2023-10-11 09-21-49

I tested it with PDF export as well, same behavior.

I also tried Oracle JRE 1.8.0, same result.

I also tried it with Archi 5.0.2 and 5.0, same result.

Steps to Reproduce the Behaviour

  1. Create a view
  2. Add an Application Component and give it the name Application Components.
  3. FileExportView as Image..., select SVG for the format.
  4. Have a look at the SVG image in an image viewer, web browser or Inkscape. You see the far most right letter is cut off.
Phillipus commented 8 months ago

Is is cut off when you export to PNG file?

What's the font? Can you try a different font?

ngulden commented 8 months ago

The PNG export looks good, though. But I need it in SVG for the much clearer appearance.

Bildschirmfoto vom 2023-10-11 10-18-41

I use the default font Sans in font size 9. Changing it to for example Open Sans doesn't have an effect.

Phillipus commented 8 months ago

Can you try several other fonts to see if something works.

It may be do to the Linux distro, I'm not seeing this on Ubuntu or Mint.

What screen resolution are you using?

ngulden commented 8 months ago

Can you recommend some fonts? I have quite a lot installed and don't want to try all of them.

My screen resolution is 3840x2160.

Phillipus commented 8 months ago

Can you try with different scaling (do you use 200% scaling or 150% for example)

ngulden commented 8 months ago

The font "Roboto Regular" in size "10" looks good.

I can't use a different scaling, because then I have a dark display. And I don't want to change that setting, because of just one application.

I guess, I go with the different font and size and change the views accordingly. To me this is a workaround.

Nevertheless, the issue remains.

Thanks for your quick response and showing me a way to continue.

Phillipus commented 8 months ago

I'm not asking you to use a different scaling permanently. As I don't have your setup I'm trying to pinpoint where the problem is. It might be Linux distro, font, screen resolution, scaling, etc. Once I know that I can take a closer look.

Note that there are some issues on different platforms that may be due to the underlying Eclipse frameworks, and I may not be able to fix or workaround them.

ngulden commented 8 months ago

Thanks for your explanation. I can't provide more information with a different screen scaling, because I then get a dark screen. Sorry.

Phillipus commented 8 months ago

I've spent quite a bit of time investigating this today. The problem is more obvious on Linux than Mac or Windows.

In order to export to SVG and PDF we rely on external libraries such as Apache Batik, Apache FOP and some very old graphics code which you can find here - https://github.com/archimatetool/archi/tree/master/com.archimatetool.export.svg

Over the years it has become very difficult to maintain this code in order to keep up with changes in operating systems and screen resolutions, and we are frequently hacking the code to try to workaround issues. Therefore, we have to regard the SVG and PDF export as something that is not always 100% perfect.

See also https://github.com/archimatetool/archi/issues/714

For the next version of Archi I've added three additional options to the export dialogs for SVG and PDF:

  1. Render text as shapes. If checked, all text is drawn as shapes otherwise text is drawn using a font. See https://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/ext/awt/g2d/AbstractGraphics2D.html
  2. Embed fonts. If checked, fonts are embedded in the SVG or PDF file. See https://xmlgraphics.apache.org/batik/javadoc/org/apache/batik/svggen/SVGGeneratorContext.html
  3. Text clipping workaround. If checked all fonts are reduced in height by 1 point so they do not clip.

In existing versions of Archi, the setting for option (1) was true, and for option (2) the setting was false. By allowing to set these options fonts vary slightly in size and it may be that this will help with the text clipping issue. Option (2) needs to be set to true if (1) is false when exporting to PDF.

Option (3) is really a last resort and probably is only needed on Linux.

By exposing these options in the export dialog, some combination of them should result in better font rendering.

That's the best I can do!

ngulden commented 8 months ago

Thank you very much @Phillipus for diving into that and trying to find the root cause. I really appreciate your quick help, because it helped me to continue.

Phillipus commented 8 months ago

5.2 is released now.