Bug 481144 - [Cocoa] Text lowered badly on Widgets in Preference and Properties - Mac 10.10+ (AKA "Lowered Textpectations") (workaround in comment 36)
Summary: [Cocoa] Text lowered badly on Widgets in Preference and Properties - Mac 10.1...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.6   Edit
Hardware: Macintosh Mac OS X
: P3 normal with 3 votes (vote)
Target Milestone: 4.6.3   Edit
Assignee: Phillip Webb CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
: 486734 495097 496770 (view as bug list)
Depends on:
Blocks: 494879
  Show dependency tree
 
Reported: 2015-10-30 15:17 EDT by Andy Thomas-Cramer CLA
Modified: 2017-07-07 12:48 EDT (History)
12 users (show)

See Also:
lshanmug: review+


Attachments
name.baz - issue occurs (100.16 KB, image/png)
2015-10-30 15:17 EDT, Andy Thomas-Cramer CLA
no flags Details
name.foo - issue does not occur (49.94 KB, image/png)
2015-10-30 15:17 EDT, Andy Thomas-Cramer CLA
no flags Details
name.baz project folder (115.69 KB, application/x-zip-compressed)
2015-10-30 15:18 EDT, Andy Thomas-Cramer CLA
no flags Details
name.foo project folder (143.70 KB, application/x-zip-compressed)
2015-10-30 15:18 EDT, Andy Thomas-Cramer CLA
no flags Details
Preference page on first launch (156.65 KB, image/png)
2016-07-11 16:32 EDT, Greg Watson CLA
no flags Details
Preference page on second launch (151.21 KB, image/png)
2016-07-11 16:36 EDT, Greg Watson CLA
no flags Details
Buttons (13.28 KB, image/png)
2016-09-12 23:14 EDT, Phillip Webb CLA
no flags Details
Import screen (550.43 KB, image/png)
2016-09-13 00:32 EDT, Phillip Webb CLA
no flags Details
Import screen without issue (551.26 KB, image/png)
2016-09-13 00:33 EDT, Phillip Webb CLA
no flags Details
Oxygen preference menu w/ clipped fonts on Mac OS (9.71 KB, image/jpeg)
2017-07-06 12:35 EDT, Michael Giroux CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andy Thomas-Cramer CLA 2015-10-30 15:17:19 EDT
Created attachment 257659 [details]
name.baz - issue occurs

Beginning with Mac 10.10, the text is lowered in some controls, sometimes to the point that font descenders are cut off. 

The issue does not occur on Windows or in prior versions of Mac OS X. The issue appeared when we installed our mature RCP applications on Mac 10.10 and Mac 10.11.

At first I presumed we were doing something wrong. But I managed to create a SSCCE using the project templates provided by "Eclipse for RCP and RAP developers."

== EXAMPLE == 

This problem is illustrated by the *.png attachments, and reproducible with the corresponding SSCCE plug-in projects mostly generated by "New Plug-in Project" in "Eclipse for RCP and RAP developers" version 4.5.1. 

* name.foo was generated with the template "RCP 3.x application (minimal)."
* name.baz was generated with the template "RCP 3.x Mail Template."

The same three preference page classes were added to each, and specified in plug-in.xml. No other changes were made to the projects. 

In this example, the issue occurs with name.baz, but not with name.foo. 
* Observe the font descenders in the list of page titles.
* Observe the more subtle lowering of the text in the commit buttons. 

== OBSERVATIONS == 

* The issue does not occur in the Eclipse IDE.
* Our applications are using the Eclipse 3.x compatibility layer. 
* Our applications continue to work correctly on Windows and prior versions of Mac OS X.
* With the SSCCE, the same behavior occurs with both 4.5 and 4.5.1 as targets. 
* The issue occurs with more than just the controls presented in the example.
Comment 1 Andy Thomas-Cramer CLA 2015-10-30 15:17:47 EDT
Created attachment 257660 [details]
name.foo - issue does not occur
Comment 2 Andy Thomas-Cramer CLA 2015-10-30 15:18:26 EDT
Created attachment 257661 [details]
name.baz project folder
Comment 3 Andy Thomas-Cramer CLA 2015-10-30 15:18:46 EDT
Created attachment 257662 [details]
name.foo project folder
Comment 4 Greg Watson CLA 2016-07-11 16:28:53 EDT
Also visible in 4.6 using the DSL and Parallel packages (and I suspect other packages). I see this behavior only after the *second* time Eclipse is started, and it is visible in the main preference page as well as project preferences. The first time Eclipse is launched, the problem is not apparent.

I think this should be made high priority as it makes Eclipse look pretty second rate, IMHO.
Comment 5 Greg Watson CLA 2016-07-11 16:32:03 EDT
Created attachment 263029 [details]
Preference page on first launch
Comment 6 Greg Watson CLA 2016-07-11 16:36:42 EDT
Created attachment 263030 [details]
Preference page on second launch
Comment 7 Patrik Suzzi CLA 2016-07-11 17:34:03 EDT
I can reproduce in Eclipse Neon, on Mac Os X El Captain. 

I think the issue makes Eclipse less ergonomic and less aesthetically appealing.
Comment 8 Patrik Suzzi CLA 2016-07-11 17:37:03 EDT
One further question: is the readability improving if you restart Eclipse ?
Comment 9 Greg Watson CLA 2016-07-12 08:33:35 EDT
(In reply to Patrik Suzzi from comment #8)
> One further question: is the readability improving if you restart Eclipse ?

No. Further restarts do not resolve the problem. Also, if I restart and select a different workspace, the problem persists.
Comment 10 Patrik Suzzi CLA 2016-07-12 09:36:49 EDT
Is this something for SWT ?
Comment 11 Greg Watson CLA 2016-07-13 22:14:36 EDT
I don't know. I've only seen the problem affecting the main tree widget in the preference and properties pages. Other trees within these pages seem to be ok, so I don't know if it's just because these are different somehow, or it's happening higher up than SWT.
Comment 12 Phillip Webb CLA 2016-09-12 23:14:07 EDT
Created attachment 264116 [details]
Buttons

I also see the problem on buttons. The attached screen shot shows the button text slightly lower than it should be.
Comment 13 Phillip Webb CLA 2016-09-13 00:32:31 EDT
Created attachment 264117 [details]
Import screen

Import screen showing issue
Comment 14 Phillip Webb CLA 2016-09-13 00:33:08 EDT
Created attachment 264118 [details]
Import screen without issue
Comment 15 Phillip Webb CLA 2016-09-13 00:34:48 EDT
Interestingly it appears that if you do File -> Switch Workspace then the problem disappears until the next restart.

You can see this by comparing the buttons in the following screenshots: 

https://bugs.eclipse.org/bugs/attachment.cgi?id=264117

https://bugs.eclipse.org/bugs/attachment.cgi?id=264118
Comment 16 Phillip Webb CLA 2016-09-13 18:37:40 EDT
A little more analysis.

The following always fails:

$ ./Eclipse.app/Contents/MacOS/eclipse
Select workspace
View preferences


The following always works:

$ ./Eclipse.app/Contents/MacOS/eclipse -data /Users/pwebb/Documents/workspacetest
View preferences


It appears that when the select workspace dialog is show the problem appears, otherwise it does not.
Comment 17 Phillip Webb CLA 2016-09-13 18:39:45 EDT
Perhaps it's related to the new "recent workspaces" pull down that's now on that dialog (and wasn't in Mars)
Comment 18 Phillip Webb CLA 2016-09-14 01:44:17 EDT
After quite a bit of investigation the root cause seems to be the construction of a new Font from FontData that has a null nsName.

To reproduce with minimal calls:

- Edit org.eclipse.ui.internal.ide.ChooseWorkspaceDialog.java as follows:

	private void createRecentWorkspacesComposite(final Composite composite) {
		FontData[] fontData = composite.getFont().getFontData();
		for (FontData element : fontData) {
			element.setStyle(element.getStyle());
		}
		Font font = new Font(composite.getDisplay(), fontData);
		font.dispose();
		if (true)
			return;

	    --- (previous code)

- Launch the Eclipse Application (but edit the run config to remove an Loation default)
- Make sure the "Switch Workspace" dialog appears
- Click OK
- Open the preferences dialog to see the issue.


For some reason an early call to NSFont.fontWithName(family, size); looking up ".SF NS Text" causes the issue.
Comment 19 Patrik Suzzi CLA 2016-09-14 19:47:51 EDT
*** Bug 496770 has been marked as a duplicate of this bug. ***
Comment 20 Marc-André Laperle CLA 2016-10-13 10:35:27 EDT
*** Bug 495097 has been marked as a duplicate of this bug. ***
Comment 21 Eclipse Genie CLA 2016-10-14 00:46:59 EDT
New Gerrit change created: https://git.eclipse.org/r/83175
Comment 22 Phillip Webb CLA 2016-10-14 01:38:02 EDT
I've submitted a patch for review at https://git.eclipse.org/r/#/c/83175/ that I think will fix this one and https://bugs.eclipse.org/bugs/show_bug.cgi?id=486734.

The problem is pretty interesting and I think it could be considered a bug in Cocoa.

It appears that when you call `NSFont.systemFontOfSize` on El Capitan you get back a reference to the "San Francisco" font. This font is not a regular font, it uses the name ".SF NS Text". Rendering of that font always seems fine, it's spaced correctly and looks right.

If, however, you start to manipulate it to add a 'bold' trait by using `convertFont` then the resulting font has an odd baseline. Although it renders, the text is always too high. I've noticed this on Eclipse Mars when searching for text in the preference dialog, but never thought much of it.

Now the really interesting thing is that calling `NSFont.fontWithName(".SF NS Text")` sometimes returns a good result, and sometimes returns a bad one. As far as I can tell, the result is good up to the point that `convertFont` is called, then it starts returning bad results. In Eclipse Mars, this wasn't a big problem because, luckily, calls were made and Fonts were cached before any bold conversion took place. With the introduction of the new "Select workspace" option on the welcome screen, a bold font is created early and all subsequent fonts are messed up.

The way I've worked around the problem is to update the `Font.init` method to work out if it should get a fresh system font, or lookup the font by name. If the `name` starts with "." and matches the system font name that would be returned at the same size, the system font is used in preference. I've also needed to update the logic that applies or removes the "bold" and "italic" traits.
Comment 23 Marc-André Laperle CLA 2016-10-14 11:17:39 EDT
(In reply to Phillip Webb from comment #22)
> I've submitted a patch for review at https://git.eclipse.org/r/#/c/83175/
> that I think will fix this one and
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=486734.
> 
> The problem is pretty interesting and I think it could be considered a bug
> in Cocoa.

Would it be a good idea to report this to Apple? (see https://developer.apple.com/bug-reporting/) They have fixed a few issues I reported in the past.
Comment 24 Phillip Webb CLA 2016-11-02 15:51:10 EDT
I've submitted the issue to Apple (bug 29072942). I don't expect that they'll get to fixing it soon so it might be nice if my suggested fix could be reviewed for the next Eclipse service release.
Comment 25 Liviu Ionescu CLA 2016-11-03 12:02:39 EDT
It would be great to have this fixed and included in Neon SR2.
Comment 26 Eclipse Genie CLA 2016-11-03 13:36:46 EDT
New Gerrit change created: https://git.eclipse.org/r/84428
Comment 27 Marc-André Laperle CLA 2016-11-08 10:23:37 EST
(In reply to Liviu Ionescu from comment #25)
> It would be great to have this fixed and included in Neon SR2.

Indeed! I have tested the patch and it looks good to me. But I am not a committer on SWT. Can someone help reviewing this? It would be good timing for Neon.2 RC1 on Friday.
Comment 28 Phillip Webb CLA 2016-11-11 11:08:23 EST
Did this make it into Neon SR2? I know it seems like a minor bug but without this fix Eclipse looks so ugly on OSX.
Comment 29 Marc-André Laperle CLA 2016-11-11 11:18:26 EST
(In reply to Phillip Webb from comment #28)
> Did this make it into Neon SR2? I know it seems like a minor bug but without
> this fix Eclipse looks so ugly on OSX.

Not yet. A committer from SWT would need to look at the patch.
Comment 30 Phillip Webb CLA 2016-11-15 17:53:16 EST
As requested I raised this issue with Apple, they wanted a small sample that replicated the issue which I was unfortunately unable to provide. The last comment from them was as follows:

--- snip

Engineering has requested the following information regarding your bug report:

https://github.com/eclipse/eclipse.platform.swt/blob/master/bundles/org.eclipse.swt/Eclipse%20SWT/cocoa/org/eclipse/swt/graphics/Font.java#L329

-[NSFontManager convertFont:toHaveTrait:] on a font returned by -[NSFont systemFontOfSize:] is working properly, we just confirmed. But since you’re using a Java application and aren’t clear about how exactly does the “rendering” part happen, we can’t provide any help with this. Most likely you are getting the correct font from -[NSFontManager convertFont:toHaveTrait:] but using a wrong one for the actual rendering.
Comment 31 Phillip Webb CLA 2016-11-28 15:02:12 EST
Latest update from Apple:

https://github.com/eclipse/eclipse.platform.swt/blob/master/bundles/org.eclipse.swt/Eclipse%20SWT/cocoa/org/eclipse/swt/graphics/Font.java#L329

-[NSFontManager convertFont:toHaveTrait:] on a font returned by -[NSFont systemFontOfSize:] is working properly, we just confirmed. But since you’re using a Java application and aren’t clear about how exactly does the “rendering” part happen, we can’t provide any help with this. Most likely you are getting the correct font from -[NSFontManager convertFont:toHaveTrait:] but using a wrong one for the actual rendering.
Comment 32 Phillip Webb CLA 2016-12-14 17:35:26 EST
According to the release schedule [1] Neon SR2 should be ramping down soon. Is there any way to please get this backported?

[1] http://wiki.eclipse.org/Neon/Simultaneous_Release_Plan#Neon.2
Comment 33 Liviu Ionescu CLA 2016-12-14 17:59:35 EST
if not, perhaps support for HiRes should be reverted until a proper solution will be available.
Comment 34 Dani Megert CLA 2016-12-15 03:45:57 EST
(In reply to Phillip Webb from comment #32)
> According to the release schedule [1] Neon SR2 should be ramping down soon.
> Is there any way to please get this backported?
> 
> [1] http://wiki.eclipse.org/Neon/Simultaneous_Release_Plan#Neon.2

Sorry it is too late for 4.6.2. We first have to put and test the fix in master. We'll make sure it gets into 4.6.3.
Comment 35 Lakshmi P Shanmugam CLA 2016-12-23 07:21:08 EST
Hi Phillip,
Thanks for investigating this and providing a patch. I've added comments to your gerrit change.
Comment 36 Marc-André Laperle CLA 2017-01-06 10:15:22 EST
In case people are coming to this bug looking for a quick solution, here is a quick description of a workaround:

When you start Eclipse and you get the workspace prompt, select your workspace as usual but check "Use this as default and do not ask again". Click OK, then when Eclipse is fully started, quit Eclipse then start again.

The key to the workaround is to not show the workspace prompt.
Comment 37 Michael Giroux CLA 2017-01-06 20:50:58 EST
Thanks for posting your solution.  I tried the workaround described in comment 36 https://bugs.eclipse.org/bugs/show_bug.cgi?id=481144#c36.

For my system, this did not work.
Mac OS X version 10.12.2 (Sierra).

Eclipse:
Version: Neon.2 Release (4.6.2)
Build id: 20161208-0600
java.runtime.version=1.8.0_101-b13
Comment 38 Greg Watson CLA 2017-01-07 21:25:58 EST
(In reply to Michael Giroux from comment #37)
> Thanks for posting your solution.  I tried the workaround described in
> comment 36 https://bugs.eclipse.org/bugs/show_bug.cgi?id=481144#c36.
> 
> For my system, this did not work.
> Mac OS X version 10.12.2 (Sierra).
> 
> Eclipse:
> Version: Neon.2 Release (4.6.2)
> Build id: 20161208-0600
> java.runtime.version=1.8.0_101-b13

I tried this on 10.11.6 (El Capitan) and it works for me. Same Eclipse release.
Comment 39 Lakshmi P Shanmugam CLA 2017-01-17 01:35:37 EST
Hi Phillip,
It would be good to have this for M5 (which is next week) and then in 4.6.3. Do you plan to work on the gerrit comments?
Comment 40 Phillip Webb CLA 2017-01-18 12:23:40 EST
@Lakshmi Yes, I've been meaning to try and find time to make the requested changes. I'll take a look today.
Comment 41 Phillip Webb CLA 2017-01-18 16:14:38 EST
@Lakshmi I've added some comments to Gerrit. Unfortunately I can't get the `NSFont.boldSystemFontOfSize(size)` call alone to fix the issue.
Comment 42 Lakshmi P Shanmugam CLA 2017-01-19 01:24:36 EST
(In reply to Phillip Webb from comment #41)
> @Lakshmi I've added some comments to Gerrit. Unfortunately I can't get the
> `NSFont.boldSystemFontOfSize(size)` call alone to fix the issue.

Phillip, I don't see any comments in the gerrit patch. (https://git.eclipse.org/r/#/c/84428/)
Comment 43 Lakshmi P Shanmugam CLA 2017-01-19 01:36:16 EST
(In reply to Lakshmi Shanmugam from comment #42)
> (In reply to Phillip Webb from comment #41)
> > @Lakshmi I've added some comments to Gerrit. Unfortunately I can't get the
> > `NSFont.boldSystemFontOfSize(size)` call alone to fix the issue.
> 
What is the testcase you are using to verify the fix. I tested with the Snippet in (https://bugs.eclipse.org/bugs/attachment.cgi?id=259436) from Bug 486734. Also, tested with the eclipse IDE.
Comment 44 Eclipse Genie CLA 2017-01-20 02:57:53 EST
New Gerrit change created: https://git.eclipse.org/r/89167
Comment 46 Lakshmi P Shanmugam CLA 2017-01-20 05:08:31 EST
Thanks for the patch Phillip! I've pushed the gerrit patch with a few small changes.
Similar problem exists with text with italics style. I'll open a separate bug to track it.
Comment 47 Lakshmi P Shanmugam CLA 2017-01-20 05:16:18 EST
(In reply to Lakshmi Shanmugam from comment #46)
> Similar problem exists with text with italics style. I'll open a separate
> bug to track it.
Opened Bug 510741 to track this.
Comment 48 Phillip Webb CLA 2017-01-20 13:01:36 EST
> Phillip, I don't see any comments in the gerrit patch

I have a lot of trouble understanding gerrit, for some reason the comments are marked as draft. I'll paste them here:

---

> Looks like this call - NSFont.boldSystemFontOfSize(size) - causes the baseline of the bold font to be set correctly. Having this call and removing the if block that sets the systemFont or boldSystemFont works for me. Can you check?

That doesn't appear to work for me. If I comment out the if block I still see the lowered text.

To test I :
- Changed the run configuration and cleared the workspace location. 
- Ran the Eclipse (from Eclipse)
- Made sure I got the workspace chooser dialog on start. 
- Selected Eclipse -> Preferences when the workspace was running

The preferences tree shows the lowered font.

> Do we need to check for name.startsWith(".") or just use the same code for any system font?

I think we can drop the ".", I was just trying to minimize the impact of the fix my limiting when it applied.
Comment 49 Phillip Webb CLA 2017-01-20 13:02:53 EST
> What is the testcase you are using to verify the fix. I tested with the Snippet in (https://bugs.eclipse.org/bugs/attachment.cgi?id=259436) from Bug 486734. Also, tested with the eclipse IDE.

I just tested with the IDE. I'm not all that familiar with SWT programming so wasn't able to put together an isolated test.
Comment 50 Lakshmi P Shanmugam CLA 2017-01-23 01:59:36 EST
(In reply to Phillip Webb from comment #48)
> > Phillip, I don't see any comments in the gerrit patch
> 
> I have a lot of trouble understanding gerrit, for some reason the comments
> are marked as draft. I'll paste them here:
> 
After saving the comments, click on Reply.. and then click Post. This will post the comments in gerrit.

Verified the fix in build - I20170122-2000. (http://download.eclipse.org/eclipse/downloads/drops4/I20170122-2000/)
Comment 51 Markus Keller CLA 2017-01-23 11:17:01 EST
The change has only been released to master, but this bug was marked as fixed in 4.6.3. Reopening. An eventual backport should likely include the fix for bug 510741.

download.eclipse.org/eclipse/downloads/drops4/I20170122-2000/testresults/html/org.eclipse.swt.tests_ep47I-unit-mac64_macosx.cocoa.x86_64_8.0.html has this new test failure:

java.lang.AssertionError: Wrong font height expected:<10> but was:<13>
at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_graphics_Font.test_getFontData(Test_org_eclipse_swt_graphics_Font.java:317)
at org.eclipse.test.EclipseTestRunner.run(EclipseTestRunner.java:749)
...
Comment 52 Lakshmi P Shanmugam CLA 2017-01-23 13:21:39 EST
(In reply to Markus Keller from comment #51)
> download.eclipse.org/eclipse/downloads/drops4/I20170122-2000/testresults/
> html/org.eclipse.swt.tests_ep47I-unit-mac64_macosx.cocoa.x86_64_8.0.html has
> this new test failure:
> 
Fixed the test failure via http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?id=eb1b7832261ac0b6bdcac875f5b0f830d50e50e0
Comment 53 Lakshmi P Shanmugam CLA 2017-01-25 00:47:56 EST
Pushed the fix to R4_6_maintenance branch --> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/?h=R4_6_maintenance&id=6ebd7c95a5ba339f6c549d8fb3a54caefd9400c5
Comment 54 Lakshmi P Shanmugam CLA 2017-01-27 07:11:12 EST
*** Bug 486734 has been marked as a duplicate of this bug. ***
Comment 55 Michael Giroux CLA 2017-07-06 12:33:11 EDT
Although this bug is marked as Resolved, the problem still exists in Neon.3, and more troubling, the problem is still present in Oxygen.  See attached screenshot from the preferences menu.
Comment 56 Michael Giroux CLA 2017-07-06 12:35:19 EDT
Created attachment 269258 [details]
Oxygen preference menu w/ clipped fonts on Mac OS

Illustrates that fonts are still being clipped in Mac OS with Oxygen.

Mac OS Sierra, version 10.12.5.
Comment 57 Lakshmi P Shanmugam CLA 2017-07-07 07:31:41 EDT
(In reply to Michael Giroux from comment #55)
> Although this bug is marked as Resolved, the problem still exists in Neon.3,
> and more troubling, the problem is still present in Oxygen.  See attached
> screenshot from the preferences menu.

This is unexpected, I don't see this behavior with Oxygen on macOS 10.12.5. Have you changed any font settings? Do you have any other plug-ins installed?
Comment 58 Michael Giroux CLA 2017-07-07 11:02:45 EDT
(In reply to Lakshmi Shanmugam from comment #57)
> Do you have any other plug-ins installed?

None that should be messing with fonts.  However, while digging into the configuration to answer your question, I took a look at the Preferences -> General -> Colors and Fonts.  I clicked "Restore Defaults" and the problem is resolved.  

I did not think to record the previous setting, but defaults seem to be working as expected.
Comment 59 Lakshmi P Shanmugam CLA 2017-07-07 12:48:55 EDT
(In reply to Michael Giroux from comment #58)
> (In reply to Lakshmi Shanmugam from comment #57)
> > Do you have any other plug-ins installed?
> 
> None that should be messing with fonts.  However, while digging into the
> configuration to answer your question, I took a look at the Preferences ->
> General -> Colors and Fonts.  I clicked "Restore Defaults" and the problem
> is resolved.  
> 
> I did not think to record the previous setting, but defaults seem to be
> working as expected.

Thanks for verifying. In-case you are able to reproduce the problem, it would be good if you could find the font settings causing the problem and post it here.