Bug 155325 - Cursor position desynchronise for justified lines after a few words (possibly graphite font related)
Summary: Cursor position desynchronise for justified lines after a few words (possibly...
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.4.5.1 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Font-Rendering
  Show dependency treegraph
 
Reported: 2023-05-15 13:39 UTC by Peter Gervai
Modified: 2024-01-05 19:22 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
odt sample (29.59 KB, application/vnd.oasis.opendocument.text)
2023-05-15 13:40 UTC, Peter Gervai
Details
screenshot of the problem (184.86 KB, image/png)
2023-05-15 13:40 UTC, Peter Gervai
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Gervai 2023-05-15 13:39:22 UTC
Description:
The problem may be also font related: it seems that the problem shows for Graphite enabled fonts (Linux Libertine G, L L Display G, from https://numbertext.org/linux/), though I cannot say "only".

On special occasions justification is breaking internal position calculations, which puts the cursor at the wrong position and sometimes breaking the end position of the line as well. 

I attach a document and a screenshot, which shows broken cursor (right position would be before the marked character), broken ending and also a suggestively wrong space marker.

(This is the Debian released version from sid.)


Steps to Reproduce:
1.turn on justification (may be font dependant, I am using now Linux Libertine G)
2.set justification in style
3.find lines with broken ending

Actual Results:
Wrong cursor position, wrong ending position

Expected Results:
Good ones.


Reproducible: Always


User Profile Reset: No

Additional Info:
Linux Libertine G, Linux Biolinum G fonts
Comment 1 Peter Gervai 2023-05-15 13:40:00 UTC
Created attachment 187294 [details]
odt sample
Comment 2 Peter Gervai 2023-05-15 13:40:23 UTC
Created attachment 187295 [details]
screenshot of the problem
Comment 3 ⁨خالد حسني⁩ 2023-05-15 15:50:13 UTC
Linux Libertine G seems to be doing something fishy with tt followed by space:

First check stand alone tt:

$ hb-shape LinLibertine_R_G.ttf "tt"
[t_t+1257]

Then standalone space:

$ hb-shape LinLibertine_R_G.ttf "tt t tt"
[space+512]

Then tt followed by space:

$ hb-shape LinLibertine_R_G.ttf "tt t tt"
[t_t+1769|space@-512,0+0]

Notice how when followed by space the advance width of the t_t glyph gets the advance width of the space glyph add to it, then space gets a negative advance width to compensate for this.

This seems like a font bug. I don’t think there is a good reason to do this. But we also probably have a bug caused by this resulting in calculating the spacing between glyphs differently for cursor position and for actual drawing resulting in this discrepancy.

In general, Linux Libertine G is rather have some issues and is not maintained. We probably are better off not distributing it any more.
Comment 4 ⁨خالد حسني⁩ 2023-05-15 15:54:40 UTC
(In reply to خالد حسني from comment #3)
> First check stand alone tt:
> 
> $ hb-shape LinLibertine_R_G.ttf "tt"
> [t_t+1257]
> 
> Then standalone space:
> 
> $ hb-shape LinLibertine_R_G.ttf "tt t tt"
> [space+512]

This should be:

$ hb-shape LinLibertine_R_G.ttf " "
[space+512]

> Then tt followed by space:
> 
> $ hb-shape LinLibertine_R_G.ttf "tt t tt"
> [t_t+1769|space@-512,0+0]

And this should be:
$ hb-shape LinLibertine_R_G.ttf "tt "
[t_t+1769|space@-512,0+0]

(copied the wrong lines)
Comment 5 ⁨خالد حسني⁩ 2023-07-05 18:20:36 UTC
This is a bug in HarfBuzz graphite2 shaper.
Comment 6 ⁨خالد حسني⁩ 2023-07-06 05:10:17 UTC
I’m working on a HarfBuzz fix.
Comment 7 ⁨خالد حسني⁩ 2023-07-11 04:31:14 UTC
(In reply to ⁨خالد حسني⁩ from comment #6)
> I’m working on a HarfBuzz fix.

HarfBuzz fix didn’t help with this one, it needs to be fixed in th efont.
Comment 8 László Németh 2023-12-28 20:58:36 UTC
@Khaled: many thanks for analyzing the problem and fixing Harfbuzz!

Linux Libertine G contains solutions for several LibreOffice problems (see https://numbertext.org/linux/fontfeatures.pdf), that is why for example it is the font set of two academic journals in Hungary (one of them is "Neveléstudomány" https://nevtud.ppk.elte.hu/content/nevelestudomany.t.6308?m=2818, and font of other scientific books. I will work on to fix these problems in Writer, so we won't need to the special Graphite solutions any more.
Comment 9 Peter Gervai 2024-01-05 19:22:14 UTC
It seems that Libertinus fonts (in LO) support a lot of features now (c2sc, case, dlig, frac, hlig, liga, onum, pnum, salt, smcp, ss01-07, calt) but of course none of the special L L G features.