Bug 522619 - Export as image problem with unknown font and auto-scale mode
Summary: Export as image problem with unknown font and auto-scale mode
Status: NEW
Alias: None
Product: Sirius
Classification: Modeling
Component: Diagram (show other bugs)
Version: 5.0.0   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2017-09-22 03:19 EDT by Laurent Redor CLA
Modified: 2017-09-29 05:47 EDT (History)
3 users (show)

See Also:


Attachments
SampleWithSpecificFont.zip (272.44 KB, application/x-zip-compressed)
2017-09-22 03:19 EDT, Laurent Redor CLA
no flags Details
diagramA.jpg (3.66 KB, image/jpeg)
2017-09-22 03:19 EDT, Laurent Redor CLA
no flags Details
diagramA-autoScaling.jpg (1.10 MB, image/jpeg)
2017-09-22 03:20 EDT, Laurent Redor CLA
no flags Details
diagramB.jpg (3.76 KB, image/jpeg)
2017-09-22 03:20 EDT, Laurent Redor CLA
no flags Details
diagramB-autoScaling.jpg (997.93 KB, image/jpeg)
2017-09-22 03:20 EDT, Laurent Redor CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Laurent Redor CLA 2017-09-22 03:19:03 EDT
Created attachment 270304 [details]
SampleWithSpecificFont.zip

Since the auto-scaling of export as image (bug 507056 and bug 521467), there is problem with figure using unknown Font. The label is not visible for this figure when the "auto-scale" is enabled.
	
Steps to reproduce:
* Import project SampleWithSpecificFont (from SampleWithSpecificFont.zip)
* Open diagramA
* Export it as image without the auto-scale (you get something like diagramA.jpg) => OK
* Export it as image with the auto-scale (you get something like diagramA-autoScaling.jpg, better resolution and bigger than previous) => OK
* Open diagramB
* Export it as image without the auto-scale (you get something like diagramB.jpg) => OK
* Export it as image with the auto-scale (you get something like diagramB-autoScaling.jpg, better resolution and bigger than previous) => KO, the label is not visible
Comment 1 Laurent Redor CLA 2017-09-22 03:19:42 EDT
Created attachment 270305 [details]
diagramA.jpg
Comment 2 Laurent Redor CLA 2017-09-22 03:20:06 EDT
Created attachment 270306 [details]
diagramA-autoScaling.jpg
Comment 3 Laurent Redor CLA 2017-09-22 03:20:24 EDT
Created attachment 270307 [details]
diagramB.jpg
Comment 4 Laurent Redor CLA 2017-09-22 03:20:45 EDT
Created attachment 270308 [details]
diagramB-autoScaling.jpg
Comment 5 Laurent Redor CLA 2017-09-22 09:05:06 EDT
Here is a preliminary analysis.
During the export of the DiagramA and DiagramB, I observed the Font characteristic with a breakpoint here

Thread [main] (Suspended)	
	owns: ExportAction  (id=17486)	
	GC.drawText(long, char[], int, int, int, int, int, int, TEXTMETRIC, boolean) line: 2639	
	GC.drawText(long, String, int, int, int, Point) line: 2582	
	GC.drawTextInPixels(String, int, int, int) line: 2434	
	GC.drawTextInPixels(String, int, int, boolean) line: 2384	
	GC.drawText(String, int, int, boolean) line: 2378	
	SWTGraphics.drawText(String, int, int) line: 529	
	SWTGraphics(Graphics).drawText(String, Point) line: 426	
	RenderedMapModeGraphics(ScaledGraphics).drawText(String, int, int) line: 392	
	SiriusWrapLabel.paintText(Graphics, String) line: 1187	
	SiriusWrapLabel.paintFigure(Graphics) line: 1122	
	SiriusWrapLabel(Figure).paint(Graphics) line: 1118	
	SquareEditPart$SquareFigure(Figure).paintChildren(Graphics) line: 1170	
	SquareEditPart$SquareFigure(Figure).paintClientArea(Graphics) line: 1205	
	SquareEditPart$SquareFigure(Figure).paint(Graphics) line: 1120	
	AirStyleDefaultSizeNodeFigure(Figure).paintChildren(Graphics) line: 1170	
	AirStyleDefaultSizeNodeFigure(Figure).paintClientArea(Graphics) line: 1205	
	AirStyleDefaultSizeNodeFigure(Figure).paint(Graphics) line: 1120	
	AirDefaultSizeNodeFigure(Figure).paintChildren(Graphics) line: 1170	
	AirDefaultSizeNodeFigure(Figure).paintClientArea(Graphics) line: 1205	
	AirDefaultSizeNodeFigure(Figure).paint(Graphics) line: 1120	
	DBorderedNodeFigure(Figure).paintChildren(Graphics) line: 1170	
	DBorderedNodeFigure(Figure).paintClientArea(Graphics) line: 1205	
	DBorderedNodeFigure(Figure).paint(Graphics) line: 1120	
	SiriusDiagramImageGenerator(DiagramGenerator).paintFigure(Graphics, IFigure) line: 373	
	SiriusDiagramImageGenerator(DiagramGenerator).renderToGraphics(Graphics, Point, List) line: 226	
	SiriusDiagramImageGenerator(DiagramGenerator).createSWTImageDescriptorForParts(List, Rectangle) line: 721	
	DiagramEditPartService.copyToImage(DiagramGenerator, List, Rectangle, IPath, ImageFileFormat, IProgressMonitor) line: 361	
	DiagramEditPartService(CopyToImageUtil).copyToImage(DiagramEditPart, IPath, ImageFileFormat, IProgressMonitor) line: 305	
	DiagramEditPartService.copyToImage(DiagramEditPart, IPath, ImageFileFormat, IProgressMonitor) line: 247	
	DiagramDialectUIServices.export(DRepresentation, Session, IPath, ExportFormat, IProgressMonitor, boolean) line: 463	
	DialectUIManagerImpl.export(DRepresentation, Session, IPath, ExportFormat, IProgressMonitor, boolean) line: 268	
	ExportAction.createImageFiles(IProgressMonitor) line: 198	
	ExportAction.execute(IProgressMonitor) line: 117	
	ExportAction(WorkspaceModifyOperation).lambda$0(InvocationTargetException[], IProgressMonitor) line: 107	
	
By forcing a factor of 5, ie method org.eclipse.sirius.diagram.ui.tools.api.part.DiagramEditPartService.getExportResolutionFactor(DiagramEditPart, SiriusDiagramImageGenerator) always returns 5:
* the variable points for known Font ("Comic Sans MS") in DiagramA is  [38.0, 54.0, 48.0, 54.0, 54.0, 54.0, 61.0, 54.0, 64.0, 54.0, 70.0, 54.0, 75.0, 54.0]
* the variable points for unknown Font ("UnknownFontName") in DiagramB is  [40.0, 95.0, 86.0, 95.0, 114.0, 95.0, 154.0, 95.0, 167.0, 95.0, 198.0, 95.0, 226.0, 95.0]
* the space bewteen each character is higher for unknown Font and the y location is also higher.

By forcing a factor of 10,
* the variable points for known Font ("Comic Sans MS") in DiagramA is the same as for factor of 5.
* the variable points for unknown Font ("UnknownFontName") in DiagramB is not the same. This is caused by the characteristic of the Font: "TEXTMETRIC lptm".

With factor of 5 or of 10, for font "Comic Sans MS", there are:
* Ascent = 12
* Descent = 3
* AveCharWidth = 5
* Height = 15
* InternalLeading = 4
* MaxCharWidth = 35

With factor of 5, for unknown font "UnknownFontName", there are:
* Ascent = 51
* Descent = 12
* AveCharWidth = 24
* Height = 63
* InternalLeading = 8
* MaxCharWidth = 113

With factor of 5, for unknown font "UnknownFontName", there are:
* Ascent = 101
* Descent = 23
* AveCharWidth = 48
* Height = 124
* InternalLeading = 14
* MaxCharWidth = 226

Is seems that the factor has an impact on the Font characteristic and it should not.
Comment 6 Florian Barbin CLA 2017-09-28 11:50:47 EDT
I cannot reproduce this issue on linux
Comment 7 Steve Monnier CLA 2017-09-29 05:47:57 EDT
I followed Laurent's scenario using Windows and reproduced the issue when exporting diagramB with the auto-scale. There was no label on the image.