Bug 162639 - Kashida character is placed slightly misplaced at low zoom levels
Summary: Kashida character is placed slightly misplaced at low zoom levels
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
Inherited From OOo
Hardware: All All
: medium normal
Assignee: Jonathan Clark
URL:
Whiteboard: target:25.2.0
Keywords:
Depends on:
Blocks: Undo-Redo Paragraph Character Kashida-Justification, Tatweel 151748
  Show dependency treegraph
 
Reported: 2024-08-26 11:00 UTC by Hossein
Modified: 2024-08-27 10:16 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments
PDF output showing the problem (21.89 KB, application/pdf)
2024-08-26 11:00 UTC, Hossein
Details
Screenshot of the issue with problems marked as red (36.10 KB, image/png)
2024-08-26 11:04 UTC, Hossein
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hossein 2024-08-26 11:00:12 UTC
Created attachment 196026 [details]
PDF output showing the problem

Description:
While recent fixes by Khaled and Jonathan have fixed many issues related to kashida, there are still some remaining ones. If you modify a document with kashida, and also go to very low zoom levels, you may see that sometimes kashida character is placed slightly misplaced at very low zoom levels.

Quoting from Jonathan in tdf#156211 comment 14:
> During layout, Writer scans each line and portion to detect whether there is enough room to insert kashida glyphs. I strongly suspect this algorithm may produce different results depending on zoom level. Changing the zoom level doesn't trigger another layout, so in the case that there is room for kashida glyphs at one zoom level but not another, you'll see results like that screenshot.

I think the issue can be related to tdf#161837 and will be improved if we can complete that task. 

Steps to Reproduce:
1. Open attachment 188277 [details] from tdf#156211
2. Select text between «», in this case لذا and remove it
3. Press ctrl+z
4. Do these steps while you see the glitch
    a. Zoom out to the lowest possible level
    b. Do step 2 and 3 several times
    c. Zoom in to see if the glitch is there

With a few tries, you can see the glitches.

Actual Results:
Kashida character is placed slightly misplaced, interfering with the previous character. It is beyond regular small overlap. If you export to PDF, you will also see the problem in the PDF output.

The problem is visible in attachment 195837 [details] from tdf#156211.

Expected Results:
Kashida character should be positioned correctly, and not interfere with the previous character. It should only slightly overlap the previous and next characters to only join them smoothly.

Reproducible: Always


User Profile Reset: No


Additional Info:
Reproducible with the latest LO 25.8 dev master:
Version: 25.2.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: c8e272734a8fa26d93b057d1c9def8dc6c401143
CPU threads: 12; OS: Linux 6.2; UI render: default; VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded
Comment 1 Hossein 2024-08-26 11:04:12 UTC
Created attachment 196027 [details]
Screenshot of the issue with problems marked as red

This screenshot better shows the issue with kashida placement.
Comment 2 Jonathan Clark 2024-08-27 06:25:27 UTC
Reproduced, so marking as new.

As mentioned in tdf#156211 comment 14, the root cause for this bug is that the algorithm which is supposed to rule out lines as unsuitable for kashida justification is sensitive to zoom level.

This can be shown consistently:

1. Open attachment 188277 [details] from tdf#156211
2. Select the quoted لذا on line 2 of the document
3. Press Ctrl+C
4. Press Ctrl+V, pasting لذا over itself. Note that the line is unchanged, as expected.
5. Select لذا again.
6. Zoom out to the lowest possible level.
7. Press Ctrl+V, pasting لذا over itself once again. Note that the line now has kashida, which is not the expected behavior.
8. Zoom in again.
9. Select لذا again, and press Ctrl+V. The kashida are removed.

These instructions likely won't manifest the misplaced/overlapping kashida shown in attachment 196027 [details]. On my machine, the text is rendered correctly. However, whether or not the kashida glyphs overlap other characters, layout shouldn't depend on zoom level.
Comment 3 Commit Notification 2024-08-27 10:06:18 UTC
Jonathan Clark committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/b558b96493f3e78445f2071232d59ac1ddbaa78e

tdf#162639 sw: Fix kashida justification affected by zoom level

It will be available in 25.2.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 4 Jonathan Clark 2024-08-27 10:16:49 UTC
This turned out to be a fairly straightforward oversight in the original implementation from 2008. The reference device must be used during layout, not the output device.