LibreOffice Calc jpeg-export: text is misaligned

Hello,

I want to export a table (Selection) to a jpeg file. Two texts with brackets/parentheses are put somewhere else in the picture as compared to the table – see screenshot and jpeg:

What’s wrong, and how can I fix that

Please give your OS, your LO version, and attach a minimum calc doc showing that problem

Apologies, I should have provided this in my initial post:

Version information:

Version: 24.2.7.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 16; OS: Linux 6.6; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
24.2.7-2
Calc: threaded

probab.ods (22.3 KB)

on my Win 10 computer it works like a charm …

Version: 24.2.5.2 (X86_64) / LibreOffice Community
Build ID: bffef4ea93e59bebbeaf7f431bb02b1a39ee8a59
CPU threads: 12; OS: Windows 10.0 Build 19045; UI render: Skia/Raster; VCL: win
Locale: en-US (de_DE); UI: en-US
Calc: CL threaded

You may want to replace the Nimbus Mono PS Font by something more common and try again. But that is just guessing.

Thanks for the idea! It’s not the cause of the issue but led me to some new insights…

It seems that I need to add some more crucial details. When I export,

  • I’m choosing “Selection”
  • I save as JPEG
  • I increase the JPEG dimensions in an effort to get a better quality (resolution)

And it does give me better quality of the jpeg picture, but if I increase the jpeg dimensions, the texts are misaligned.

The better resolution for the picture is important, it will be used in a presentation.

The default dimensions are 6.84 x 1.97 inch.
As soon as I slightly increase, the two texts will be slowly moved into another area of the picture.

Thanks for the hint! Now I can repoduce the behavior. I am still playing around a bit, but I would consider that a LO bug.

Workaround: (i) Do not use merged cells, and (!) (2) do not use bold formatting. See Sheet2, which exports fine …
probab.ods (10.3 KB)

The font might still be causing problems of it is postscript 3 or something ancient with embedded bitmaps.
.
To increase the resolution of the JPG without increasing the size. In the dialogue

  1. Make a note of the width dimension
  2. Increase the resolution to desired, e.g. 300 DPI
  3. Set the width dimension back to its original size. OK

For the sharply defined edges and limited range of colours I think you would get a better quality image by exporting to png and then reducing the number of colours in a graphics program like the Gimp. The file size is likely to be similar.

[Edit}
I have tested the export at 300 dpi and it does as your screenshot shows. It seems to be a bug related to having two different fonts in the same cell. Could you please make a bug report, How to Report Bugs in LibreOffice - The Document Foundation Wiki

Workaround
In the sample below, I unmerged the cells (not affecting the issue) and placed the different font words in different cells. I used Courier Prime as I had that on my system but the actual font doesn’t appear to be the problem.

probab_EA.ods (19.1 KB)
The area exports to png at 300 dpi without problems

I can confirm that contrary to my earlier post merged cells is not a problem. The problem occurs for some strings with mixed fonts. Single font strings in Courier New also showed the problem.

I thought that initially for “Probabilities for HW( im1[5][j] )” but the opening parenthesis and the following space was Liberation Sans. I had to edit the cell to select all characters and apply the same courier type font.

For me, having all fonts as Dejavu Sans still results in the problem.

Mostly it seems to work if I don’t use any brackets/parentheses and / or don’t use mixed fonts and font styles in one merged cell…etc.

In that case I can use

  • bigger dimensions for JPEG/PNG
  • merged cells
  • monospace font Dejavu Sans Mono

I don’t know much about PNG; but if I change to 300 pixels/inch, the “suggested” file size shrinks and the dimensions are getting reduced…that’s somehow weird.

If I increase the PNG dimensions, the same happens: quality is good, but fonts misaligned.

The “heading” goes wrong as soon as I mix bold and normal font. If I only have bold font, I can use the square brackets…well it seems it’s an edge case, I can’t reproduce with too much confidence, sometimes it goes wrong. Same for only bold font as for only normal font.

Wow, very weird and difficult to pin down…I swear that sometimes it works and sometimes doesn’t…the description of test cases that I’ve tried here is getting out of hand.


probab.ods (23.2 KB)

To be certain of removing variations between characters and to get all the words in the cell to the same font is to select the cell and press Ctrl+M (Format > Clear Direct Formatting). This will remove all the other formatting but ensures the font is the same for everything in the cell. You can then apply a single font and, if needed, an attribute like bold to the entire cell.
You can avoid having to bold the parentheses separately by using a heavier font, like Courier Prime, or by bolding the entire cell

Different fonts and different font attributes like bold in the same cell is the cause of the problem, please make a bug report.
Parentheses and brackets are not an issue if they are not a different font or not separately bolded

Please include in your bug report about bolding too

I crossed out the text in my comment above as I thought it was irrelevant to the problem but here it is uncrossed out.
To increase the resolution of the JPG (or PNG) without increasing the size. In the dialogue

  1. Make a note of the width dimension
  2. Increase the resolution to desired, e.g. 300 DPI
  3. Set the width dimension back to its original size. OK

[Edit]
Please report the bug number back here in the form tdf#123456 but without the backticks

I’ll try to submit a bug report report in the coming days.

I submitted a bug report 164439 – Calc export selection to JPG fails when modifying resolution

tdf#164439

Thanks, I didn’t find time yet, but will update the bug report with some details (e.g. it doesn’t only affect jpeg, but also other formats).