Bug 145648 - Different kerning when comparing Text and Comments
Summary: Different kerning when comparing Text and Comments
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Writer (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha1+
Hardware: All All
: medium normal
Assignee: Caolán McNamara
URL:
Whiteboard: target:7.5.0 target:7.4.4
Keywords:
Depends on:
Blocks: Writer-Comments Kerning
  Show dependency treegraph
 
Reported: 2021-11-12 18:19 UTC by Rafael Lima
Modified: 2022-11-14 05:30 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments
Image showing the problem (36.60 KB, image/png)
2021-11-12 18:19 UTC, Rafael Lima
Details
ODT file (9.12 KB, application/vnd.oasis.opendocument.text)
2021-11-12 18:27 UTC, Rafael Lima
Details
Screenshot (22.87 KB, application/vnd.oasis.opendocument.text)
2021-11-14 08:46 UTC, Telesto
Details
Sample file (same font size in text and comment) (10.48 KB, application/vnd.oasis.opendocument.text)
2022-11-11 17:41 UTC, Rafael Lima
Details
Comparison of the text rendering (ODG) (25.72 KB, application/vnd.oasis.opendocument.graphics)
2022-11-11 17:43 UTC, Rafael Lima
Details
Screenshot with the patch applied (176.00 KB, image/png)
2022-11-11 21:13 UTC, Rafael Lima
Details
180% zoom sidebar 50% opaque on top of main document text (66.51 KB, image/png)
2022-11-13 17:21 UTC, Caolán McNamara
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rafael Lima 2021-11-12 18:19:37 UTC
Created attachment 176215 [details]
Image showing the problem

In Writer, when you add a comment the text inside the comment box does not have the appropriate kerning settings. It seems that the font kerning in the document body is correct whereas in the comment box the kerning is a bit messy.

To illustrate the issue, I created an ODT file using Liberation Serif 12pt both in the document text and in the comment text. See the attached image where I highlight some examples where kerning is not correct in the comment box.

This issue may seem a minor one at first, however in longer comments the kerning issue stands out and looks unprofessional.

Is it possible to use the same kerning settings in the comment box?

System info:
Version: 7.3.0.0.alpha1+ / LibreOffice Community
Build ID: b31e280b3b502ad16ac0ecf2c644a7d040710897
CPU threads: 16; OS: Linux 5.13; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Calc: CL
Comment 1 Rafael Lima 2021-11-12 18:27:53 UTC
Created attachment 176216 [details]
ODT file

This is the ODT file that I used to take the screenshot. Try different zoom levels to see how the kerning in the comment box is affected.

BTW I used 200% zoom level to take the screenshot I uploaded as example. My screen size is 1080p.
Comment 2 Telesto 2021-11-14 08:46:16 UTC
Created attachment 176242 [details]
Screenshot

I do see difference in kerning, however in different area.

Attached screenshots of main text & comment box both on top of each other with transparency enabled for top image.. If you scroll up/down the transparency (sidebar -> properties -> Image deck with the top image select, can see spot the difference easily 

Screenshots taken at 600%

Version: 7.3.0.0.alpha1+ (x64) / LibreOffice Community
Build ID: 73334560b2dd2d60ac58d2cc2b1a5295490b03e1
CPU threads: 4; OS: Windows 6.3 Build 9600; UI render: Skia/Raster; VCL: win
Locale: nl-NL (nl_NL); UI: en-US
Calc: CL
Comment 3 Telesto 2021-12-01 18:27:07 UTC
Even different size in
LibreOffice 3.5.7.2 
Build ID: 3215f89-f603614-ab984f2-7348103-1225a5b (difference is even bigger)
Comment 4 Rafael Lima 2022-11-11 14:53:36 UTC
@Caolán, given your recent work with text rendering in Writer, could you please give your thoughts on this issue?

Why is text rendering inside the Comment box so different to the rendering in the text document? Is it possible to render the text in the comments the same way they're rendered in the document?
Comment 5 Caolán McNamara 2022-11-11 15:32:17 UTC
What used to happen is covered in the slides of https://events.documentfoundation.org/media/libreoffice-conference-2022/submissions/B87ZBP/resources/LibreOfficeCon-2022-ResolutionI_2TieDK1.odp where writer's text rendering used to do something very different to everything else.

For 7.4 I put in the new approach but was pretty conservative and made the new way of doing things "opt in" and only the "main window" of writer was opted in. I think its been reasonable successful, so I've pushed the boat out a little more since then, and with https://cgit.freedesktop.org/libreoffice/core/commit/?id=495922fd4ac07d4b7c16127b222f1d06a2718399 I'm hoping that its more universal.

I haven't checked this case yet, but it would be interesting to reexamine with a recent daily build and see what differences might persist.
Comment 6 Rafael Lima 2022-11-11 17:41:11 UTC
Created attachment 183545 [details]
Sample file (same font size in text and comment)

(In reply to Caolán McNamara from comment #5)
> I haven't checked this case yet, but it would be interesting to reexamine
> with a recent daily build and see what differences might persist.

So I built the current master today and the issue with the comments still persist. The rendering of text in the comment box and in the document are very different.

Build info:

Version: 7.5.0.0.alpha0+ (X86_64) / LibreOffice Community
Build ID: c819aa06069ec3ea4f2f51d26a77f455740b828f
CPU threads: 16; OS: Linux 5.15; UI render: default; VCL: kf5 (cairo+xcb)
Locale: pt-BR (pt_BR.UTF-8); UI: en-US
Calc: CL threaded

Here is a new sample file. It's very similar to the first one, but now the comment and the document use the same font size (12pt). Notice that the width of the rendered text changes a lot, as well as the spacing between characters.
Comment 7 Rafael Lima 2022-11-11 17:43:58 UTC
Created attachment 183546 [details]
Comparison of the text rendering (ODG)

Here I made a comparison of the rendered document and comment to highlight how different they are.

I did it using the same approach as Telesto. I took a screenshot of both the comment and the text and then placed them on top of each other.
Comment 8 Caolán McNamara 2022-11-11 20:26:01 UTC
looks like there's a bad/different choice of a "reference device" for the editengine in the comment box to do the measurements of text, and its operating at a lower resolution, and so has different numbers, than the one writer is using.
Comment 9 Caolán McNamara 2022-11-11 20:30:52 UTC
https://gerrit.libreoffice.org/c/core/+/142603 on a quick comparison at 600% looks to do the right thing
Comment 10 Rafael Lima 2022-11-11 21:13:25 UTC
Created attachment 183548 [details]
Screenshot with the patch applied

This screenshot compares the current comment box (top) with the patched comment box (bottom).

There's a clear difference in the patched version. It indeed looks like the rendered text.
Comment 11 Telesto 2022-11-11 21:26:20 UTC
(In reply to Rafael Lima from comment #10)
> Created attachment 183548 [details]
> Screenshot with the patch applied
> 
> This screenshot compares the current comment box (top) with the patched
> comment box (bottom).
> 
> There's a clear difference in the patched version. It indeed looks like the
> rendered text.

I'm still noticing kerning issues in the screenshot with patch applied. 

The spacing between Lo in Lorem isn't OK. The spacing between su in ipsum is off too.

I haven't build it myself. So could be a build issue/wrong screenshot etc.
Comment 12 Commit Notification 2022-11-12 11:08:18 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/34a90a7f56b7009bc95cf1b0a0e258fa0af2d52a

Resolves: tdf#145648 use the same reference device for comments as document

It will be available in 7.5.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 13 Caolán McNamara 2022-11-13 17:21:13 UTC
Created attachment 183562 [details]
180% zoom sidebar 50% opaque on top of main document text

wrt same rendering in comment and main document, they appear the same to me when overlaid like in attachment so I think that aspect seems resolved
Comment 14 Caolán McNamara 2022-11-13 17:22:50 UTC
backport to 7-4 in gerrit as https://gerrit.libreoffice.org/c/core/+/142620
Comment 15 Commit Notification 2022-11-14 05:30:51 UTC
Caolán McNamara committed a patch related to this issue.
It has been pushed to "libreoffice-7-4":

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

Resolves: tdf#145648 use the same reference device for comments as document

It will be available in 7.4.4.

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.