Bug Hunting Session
Bug 104013 - glyphs positioned at left margin of menu entries are clipped when OpenGL rendered with HarfBuzz common layout
Summary: glyphs positioned at left margin of menu entries are clipped when OpenGL rend...
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: graphics stack (show other bugs)
Version:
(earliest affected)
5.3.0.0.alpha1+
Hardware: All Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard: target:5.4.0 target:5.3.0.1
Keywords:
Depends on:
Blocks: VCL-OpenGL HarfBuzz-regressions
  Show dependency treegraph
 
Reported: 2016-11-18 17:04 UTC by V Stuart Foote
Modified: 2017-10-30 13:05 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
screen clip of layouts --- OpenGL rendering w HarfBuzz top left (2.41 MB, image/png)
2016-11-18 17:06 UTC, V Stuart Foote
Details
Screenshot, no clipping (5.01 KB, image/png)
2016-11-20 16:56 UTC, Khaled Hosny
Details
Screenshot before/after patch (42.98 KB, image/png)
2016-11-30 21:22 UTC, Luke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description V Stuart Foote 2016-11-18 17:04:19 UTC
Description:
With the new HarfBuzz common text layout on Windows, glyphs rendered with OpenGL and positioned on the left margin of menu entries are being clipped. The default GDI rendering, and the old GDI or DirectWrite rendering does not affect the glyphs.

In the attached screen clip new layout on left old layout on right. OpenGL rendering on top, GDI rendering on bottom.

In the top-left clip (of Tools -> Options at 300%) glyphs with round left edge "O" "C" are being clipped/poorly smoothed. The same glyphs away from the edge are nicely aliased.

Steps to Reproduce:
On Windows 10 Pro 64-bit en-US
Open LibreOffice
enable new HarfBuzz layout engine (default)
enable OpenGL rendering (default)
Open Tools -> Option dialog
inspect glyphs on the left edge of the menu



Actual Results:  
Glyphs with wide shadowing/smoothing "O" & "C" are clipped when positioned against left margin of menu.

Expected Results:
Glyphs for "O" and "C" should match the rendering of the same elsewhere in the menu entries. 


Reproducible: Always

User Profile Reset: Yes

Additional Info:
On Windows 10 Pro 64-bit (1607) en-US with nVidia GTX 750ti 372.70 driver

Version: 5.3.0.0.alpha1+
Build ID: 43b5ca69aa545cf93eded55258d92d651917815f
CPU Threads: 8; OS Version: Windows 6.2; UI Render: GL; Layout Engine: new; 
TinderBox: Win-x86@62-merge-TDF, Branch:MASTER, Time: 2016-11-18_05:27:05
Locale: en-US (en_US); Calc: CL


User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:50.0) Gecko/20100101 Firefox/50.0
Comment 1 V Stuart Foote 2016-11-18 17:06:40 UTC
Created attachment 128849 [details]
screen clip of layouts --- OpenGL rendering w HarfBuzz top left
Comment 2 V Stuart Foote 2016-11-18 17:12:34 UTC
@Khaled, this one sure seems HarfBuzz layout related. 

Differences between OpenGL rendering on old layout and new layout, and manifests depending on the placement of the glyph for layout.
Comment 3 V Stuart Foote 2016-11-18 17:18:40 UTC
Not just when positioned on left edge of a menu entry, but the strings "Ctrl+..." for the short-cuts being appended to the menu entries loose the left edge of pixels also with OpenGL rendering and the new layout engine.
Comment 4 Aron Budea 2016-11-19 02:34:28 UTC
Confirmed in Windows 7 with daily build from 2016-11-17_00:29:08.
Comment 5 Khaled Hosny 2016-11-20 16:56:52 UTC
Created attachment 128890 [details]
Screenshot, no clipping

I can’t reproduce this, with or without DirectWrite (manually enabling it). I don’t have OpenGL enabled, though.
Comment 6 V Stuart Foote 2016-11-20 17:08:38 UTC
(In reply to Khaled Hosny from comment #5)
> Created attachment 128890 [details]
> Screenshot, no clipping
> 
> I can’t reproduce this, with or without DirectWrite (manually enabling it).
> I don’t have OpenGL enabled, though.

I'd expect that, because as in the clip in comment 1, it is just with our OpenGL with new HarfBuzz layout that we see left alligned glyphs being clipped. 

And for me on same system running CentOS 7.2 with GTK2 on a VMWare guest--no issues then for leading glyphs with OpenGL rendering enabled.  So this is Windows only with new HarfBuzz layout and only with our OpenGL rendering.
Comment 7 Khaled Hosny 2016-11-27 19:31:31 UTC
*** Bug 104196 has been marked as a duplicate of this bug. ***
Comment 8 Khaled Hosny 2016-11-27 19:38:18 UTC
Something like this should fix the issue:

diff --git a/vcl/win/gdi/winlayout.cxx b/vcl/win/gdi/winlayout.cxx
index 19ab9ae..e3366d4 100644
--- a/vcl/win/gdi/winlayout.cxx
+++ b/vcl/win/gdi/winlayout.cxx
@@ -3427,6 +3427,11 @@ bool D2DWriteTextOutRenderer::GetDWriteInkBox(SalLayout const &rLayout, Rectangl
         rOut.Union(b);
     }
 
+    // The clipping rectangle is sometimes overzealous, add an extra pixel to
+    // remedy this.
+    if (!rOut.IsEmpty)
+        rOut.expand(1);
+
     return true;
 }

But since I can’t reproduce, I feel uneasy about applying such a fix a blindly. If someone who is able to reproduce can build with this patch and verify it fixes the issue, I’ll happily push it.
Comment 9 Luke 2016-11-28 08:32:33 UTC
Khaled Hosny,
I can't test your patch to see if it fixes this or Bug 104196. 

Any idea what's causing this?

[build CXX] vcl/win/window/salmenu.cxx
C:/lode/dev/core/vcl/win/gdi/winlayout.cxx(3431): error C2276: '!': illegal operation on bound member function expression
C:/lode/dev/core/solenv/gbuild/LinkTarget.mk:189: recipe for target 'C:/lode/dev/core/workdir/CxxObject/vcl/win/gdi/winlayout.o' failed
make[1]: *** [C:/lode/dev/core/workdir/CxxObject/vcl/win/gdi/winlayout.o] Error 2
make[1]: *** Waiting for unfinished jobs....
Makefile:266: recipe for target 'build' failed
make: *** [build] Error 2
Comment 10 Khaled Hosny 2016-11-28 09:09:14 UTC
(In reply to Luke from comment #9)
> Khaled Hosny,
> I can't test your patch to see if it fixes this or Bug 104196. 
> 
> Any idea what's causing this?
> 
> [build CXX] vcl/win/window/salmenu.cxx
> C:/lode/dev/core/vcl/win/gdi/winlayout.cxx(3431): error C2276: '!': illegal
> operation on bound member function expression
> C:/lode/dev/core/solenv/gbuild/LinkTarget.mk:189: recipe for target
> 'C:/lode/dev/core/workdir/CxxObject/vcl/win/gdi/winlayout.o' failed
> make[1]: *** [C:/lode/dev/core/workdir/CxxObject/vcl/win/gdi/winlayout.o]
> Error 2
> make[1]: *** Waiting for unfinished jobs....
> Makefile:266: recipe for target 'build' failed
> make: *** [build] Error 2

My bad, should be IsEmpty() not IsEmpty, it is a method not a variable.
Comment 11 Luke 2016-11-30 10:34:50 UTC
Khaled,
Your patch fixes the Calc '5' and '7' glyph in Bug 104196. I not sure about the "O" "C" in Tools->Option.
Comment 12 Commit Notification 2016-11-30 14:16:20 UTC
Khaled Hosny committed a patch related to this issue.
It has been pushed to "master":

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

tdf#104013: Band aid for overzealous clipping

It will be available in 5.4.0.

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 13 Khaled Hosny 2016-11-30 20:12:23 UTC
Please test and close if the commit above fixes both issues.
Comment 14 Khaled Hosny 2016-11-30 20:12:46 UTC
(In reply to Luke from comment #11)
> Khaled,
> Your patch fixes the Calc '5' and '7' glyph in Bug 104196. I not sure about
> the "O" "C" in Tools->Option.

Thanks for testing this.
Comment 15 Luke 2016-11-30 21:22:21 UTC
Created attachment 129168 [details]
Screenshot before/after patch

Does it fix the Option->Tools bug? Seems the same on my system.
Comment 16 Commit Notification 2016-12-01 00:51:06 UTC
Khaled Hosny committed a patch related to this issue.
It has been pushed to "libreoffice-5-3":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=c7e7a634cf5941fffd97102fe4252aee7445e36b&h=libreoffice-5-3

tdf#104013: Band aid for overzealous clipping

It will be available in 5.3.0.1.

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 17 Khaled Hosny 2016-12-01 07:35:23 UTC
(In reply to Luke from comment #15)
> Created attachment 129168 [details]
> Screenshot before/after patch
> 
> Does it fix the Option->Tools bug? Seems the same on my system.

So they weren’t duplicates after all. I guess we should de-duplicate them then, close the other as fixed and leave this one open.
Comment 18 V Stuart Foote 2016-12-20 15:21:48 UTC
The left edge clipping on menus is gone now, between 2016-12-16 and 2016-12-17 builds.

https://cgit.freedesktop.org/libreoffice/core/log/?qt=range&q=0c565095983b0cc8b96a78012c611b7a03962204..1427817a944f3cf1020b2f06a2ca934847b56ba8