archimatetool / archi

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

Labels are cut off in exported images #714

Closed mikisvandijk closed 3 years ago

mikisvandijk commented 3 years ago

Version of Archi

Archi 4.8.0

Archi Plug-ins

Specialization and jArchi installed, probably not relevant

Operating System

Win 10

Expected Behaviour

Labels shown in Archi app are fully visible when exported to HTML or PDF Used font is Segoe 11

Actual Behaviour

Labels are cut off, last character is not or only partly visible

Steps to Reproduce the Behaviour

Export any view to PDF or HTML

See attachted screenprint and export

Screenprint Archi

Radiotherapie.pdf

jbsarrodie commented 3 years ago

Specialization and jArchi installed, probably not relevant

Quite the opposite. Please retry without the Specialization plugin (it hooks in the graphic engine and can introduce issues)

Phillipus commented 3 years ago

Does it happen in "export as image" using PNG format?

Any other info would help - your screen resolution (do you use hi-res screen?). Does the problem occur on a different machine? Does the problem occur using a different font? A different font size? Export to PNG? Export to SVG? Are you using label expressions? Etc...

Please try Archi 4.8.1 without the Specialization plug-in. If the issue persists, please attach an example *.archimate file that demonstrates the problem.

mikisvandijk commented 3 years ago

Thanks fo your reactions. I've done some more elaborate testing:

Additional info: I do use simple label expressions, but elements without any label-expression attached are also implicated. I use a 4K monitor; at the moment I have no opportunity to test on a different system.

Attachted screenprint demonstrates the difference before (right) and after (left) the upgrade to 4.8.1

If you still would like a .archimate example I can send my complete model (confidentially) by e-mail or I have to construct something. Let me know.

Archi pdf export comparison
Phillipus commented 3 years ago

Thanks for the extra info.

Edit - no need to try these things as I can reproduce this. See my comment below.

Phillipus commented 3 years ago

Actually, it's interesting that you see such a difference between 4.8.0 and 4.8.1 as there were no changes made that might affect PDF export.

mikisvandijk commented 3 years ago

I'll be back, but probably not today...

Phillipus commented 3 years ago

I can get clipped text labels on Windows 10 if I set my display to 200% scaling (not an ideal scenario as all windows are double size) and using certain fonts and font sizes and a text string of "RT Pre-processing". It seems to happen more on words ending in "g". Also the same on Archi 4.6.0.

See attachment - clipped text.pdf

I don't think this is something that I can fix. The PDF/SVG export code is borrowed from some old Eclipse code from many years ago (com.archimatetool.export.svg.graphiti.GraphicsToGraphics2DAdaptor) based on https://github.com/eclipse/gmf-runtime/blob/master/org.eclipse.gmf.runtime.draw2d.ui.render.awt/src/org/eclipse/gmf/runtime/draw2d/ui/render/awt/internal/graphics/GraphicsToGraphics2DAdaptor.java

and combined with the Draw2D library we are seeing miscalculations of string widths when some fonts are used on hi-res devices. The same font and text might render OK on Mac, so it's also an OS thing.

Phillipus commented 3 years ago

I found something interesting in the original GraphicsToGraphics2DAdaptor.java code:

https://github.com/eclipse/gmf-runtime/commit/2d71b27e2d536c459ae115f92f2b9a5790454078#diff-6472b34090ce6cb354ce805448d72e932824883ce9dcecf658bc2515d4a2cae4

They had a bug related to calculating font height. As an experiment I applied this line:

height = (int) fsize;

and my test case rendered OK on Windows at 200% scaling.

Phillipus commented 3 years ago

@mikisvandijk Could you test a special build of Archi?

I've uploaded it here:

https://www.archimatetool.com/downloads/beta/Archi-Win64-4.8.1-test.zip

It's the portable zip version of Archi for Windows and won't conflict with your current version of Archi. Just unzip it and run Archi.exe

If you could try creating a PDF with this version and report back that would be helpful.

mikisvandijk commented 3 years ago

Thanks! I will try it tomorrow...

Op di 23 mrt. 2021 19:16 schreef Phil Beauvoir @.***>:

@mikisvandijk https://github.com/mikisvandijk Could you test a special build of Archi?

I've uploaded it here - https;// www.archimatetool.com/downloads/beta/Archi-Win64-4.8.1-test.zip

It's the portable zip version of Archi for Windows and won't conflict with your current version of Archi. Just unzip it and run Archi.exe

If you could try creating a PDF with this version and report back that would be helpful.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/archimatetool/archi/issues/714#issuecomment-805123387, or unsubscribe https://github.com/notifications/unsubscribe-auth/AR5FFKRE5E3CLMEPGAI3VCTTFDLHXANCNFSM4ZU2R6DA .

mikisvandijk commented 3 years ago

I've tried and I get interesting results that might help to narrow down the cause:

I hope it is fixable. If not, then at least we've found a work-around: change scaling factor before exporting.

Phillipus commented 3 years ago

@mikisvandijk Where are you setting the scaling of 100%, 150% and 200%? In Windows?

I hope it is fixable. If not, then at least we've found a work-around: change scaling factor before exporting.

The cause is a combination of device scaling, legacy Eclipse code and other factors. There is no real fix, unfortunately. The best we can do is to slightly reduce the size of the font by rounding down the float font size rather than rounding it up to the nearest integer.

The SVG and PDF image export is never going to be perfect. See here - https://bugs.eclipse.org/bugs/show_bug.cgi?id=312723

mikisvandijk commented 3 years ago

Yes, I set the scaling In Windows.

BTW I have a two-monitor setup.

My primary screen is the 4K monitor that I use at 150%, the secondary a Full-HD I use at 100%. I usually run my Archi on the 4K.