Bug 72488 - Ligatures spanning spaces break when showing nonprinting characters
Summary: Ligatures spanning spaces break when showing nonprinting characters
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
4.1.3.2 release
Hardware: All Linux (All)
: medium normal
Assignee: ⁨خالد حسني⁩
URL:
Whiteboard: target:4.3.0 target:4.1.5 target:4.2.0.1
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-08 18:11 UTC by Munzir Taha
Modified: 2014-01-14 14:09 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
A doc with the text that caused the bug. (7.59 KB, application/vnd.oasis.opendocument.text)
2013-12-08 18:11 UTC, Munzir Taha
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Munzir Taha 2013-12-08 18:11:57 UTC
Created attachment 90472 [details]
A doc with the text that caused the bug.

I have written
بسم الله الرحمن الرحيم
which is an Arabic text and set the font to Aldhabi which is a MS font that comes with Windows. Everything is OK until I pressed Ctrl+F10 to show non-printing characters and the text is completely messed up.

Attached is a sample document for testing. Press Ctrl-F10 and check what happens!
Comment 1 Munzir Taha 2013-12-08 18:26:58 UTC
I now found if I change the font to Scheherazade e.g, strange dashes appear between words.
Comment 2 Faisal Menawer 2013-12-08 19:17:28 UTC
hi munzir

can you put screenshot for the problem?

thx
Comment 3 Faisal Menawer 2013-12-08 19:23:01 UTC
(In reply to comment #1)
> I now found if I change the font to Scheherazade e.g, strange dashes appear
> between words.

this bug already reported see Bug 64559
Comment 4 ⁨خالد حسني⁩ 2013-12-08 19:49:13 UTC
The problem is that Writer code assume that the text string with and without the visible space (the dot) are otherwise identical and tries to draw the text string with spaces replaced with the dot, but using the glyph positions of the original string (and the idea here, I think, is that even if there is small difference in the width of the space and the dot, the text does not reflow with non-printing characters shown).

This generally works, but it breaks badly with this font because here:

بسم الله الرحمن الرحيم

is a single glyph (a ligature of the whole sentence), while:

بسم·الله·الرحمن·الرحيم

is 25 glyphs, and they all are drawn overprinting each other since they are treated as if they were a single glyph.

The relevant code is in sw/source/core/txtnode/fntcache.cxx, around line 1457 
pKernArray is obtained (note the rInf.GetText(), this is the original text string), then at line 1572 spaces are replaced with bullets, then at line 1798 the text is drawn using the modified text string and the *original* kern array.

I’m not sure how to fix this, but I guess we will need to check the original text string *eats* the spaces when rendered and avoid drawing anything for those spaces.
Comment 5 ⁨خالد حسني⁩ 2013-12-08 20:50:45 UTC
Here is a hack that fixes the issue for me https://gerrit.libreoffice.org/6995.
Comment 6 Commit Notification 2013-12-09 09:02:09 UTC
Khaled Hosny committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=02ce734450559c9353ca7f42b2519239220dd265

fdo#72488: Broken text when showing visible space



The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 7 Munzir Taha 2013-12-09 10:23:41 UTC
Excellent job Khalid, thanks a lot.
Comment 8 Commit Notification 2013-12-09 16:51:02 UTC
Khaled Hosny committed a patch related to this issue.
It has been pushed to "libreoffice-4-1":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=b79b4b88c5eb6b0fe4092b5eb98f3088f316f7b2&h=libreoffice-4-1

fdo#72488: Broken text when showing visible space


It will be available in LibreOffice 4.1.5.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.
Comment 9 Commit Notification 2013-12-09 16:51:36 UTC
Khaled Hosny committed a patch related to this issue.
It has been pushed to "libreoffice-4-2":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=8351eb25302a28c70ef5b2aaa1189db949dcf443&h=libreoffice-4-2

fdo#72488: Broken text when showing visible space


It will be available in LibreOffice 4.2.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds
Affected users are encouraged to test the fix and report feedback.