Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement for Java FX font rendering on Linux #3305

Merged
merged 5 commits into from
Oct 16, 2017

Conversation

halirutan
Copy link
Collaborator

The font-rendering of Java FX on Linux seems to be generally not as good as on other systems. I found the repo Java FX hates Linux helpful which made a comparison for different settings for the prism rendering engine.

That being said, I found simply setting

System.setProperty("prism.text", "t2k");
System.setProperty("prism.lcdtext", "true");

provides the best font rendering without having to make changes in css that might affect other systems.

This pull-request adds a checkbox under Settings -> Appearance -> Look and Feel to turn this on after a restart. I incorporated it into the preference framework. On Linux, it is turned on in the default settings.

settings

When turning it is turned on, the fonts are less blurry and the color bleaching is highly reduced (although we don't use gray scale font smoothing!). Compare these two screenshots:

  1. Tweaks turned off
  2. Tweaks turned on
  • Change in CHANGELOG.md described
  • Tests created for changes
  • Screenshots added (for bigger UI changes)
  • Manually tested changed features in running JabRef
  • Check documentation status (Issue created for outdated help page at help.jabref.org?)
  • If you changed the localization: Did you run gradle localizationUpdate?

@halirutan
Copy link
Collaborator Author

I would have provided localization, but it seems this is done on Windows and when I run localizationUpdate, all property files will be changed because the line separator is different. I can provide descriptions for English and German:

Tweak_font_rendering_for_entry_editor_on_Linux=Tweak_font_rendering_for_entry_editor_on_Linux
Tweak_font_rendering_for_entry_editor_on_Linux=Verbessertes_Schrift-Rendering_für_Linux

@LinusDietz
Copy link
Member

Are you sure that the screenshots are correctly named? I find http://i.imgur.com/BsFhpmk.png way better, however you state that font tweaking is OFF in this version.

Copy link
Member

@LinusDietz LinusDietz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the contribution! The code looks really good, I just have one suggestion for refactoring.

Also, I could't yet test the changes under Linux, as I'm on travel atm.

Concerning the localizationUpdate: It would be great if you managed to incorporate the updates into this Pull Request, as our continuous testing toolchain complains due to missing translations.
If you don't manage, I can also do that for you. In this case you would give me push access to your fork of JabRef.

prefs.put(JabRefPreferences.WIN_LOOK_AND_FEEL, classNamesLAF.getSelectedItem().toString());
if ((customLAF.isSelected() == useDefaultLAF) || !currentLAF.equals(classNamesLAF.getSelectedItem().toString())) {
if ((customLAF.isSelected() == useDefaultLAF)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you extract this into a private method named something like isRestartRequired?

@Siedlerchr
Copy link
Member

Regarding the line endings, check out this post which explains the configs:
https://stackoverflow.com/questions/10418975/how-to-change-line-ending-settings

@halirutan
Copy link
Collaborator Author

First, @Siedlerchr: thanks for the link. I will look into it. For this PR, I will fix the line endings manually, but maybe it is possible to put something like -crlf into .gitattributes for the property files under l10n.

@lynyus I will do the refactoring and include the localization.

Are you sure that the screenshots are correctly named?

Yes, I'm very sure, but I admit that I might be very pedantic about something like this as I'm working in image processing. However, I'm happy to give a demonstration: First, a screenshot from the swing text. which render OK (not as great as in OSX or Windows, but hey, it's Linux):

swing

You see that the antialiasing creates colors around the characters. Now, close your eyes almost completely to create a blurred impression. You'll notice that despite the color-antialiasing, the font appears consistent meaning no character sticks out.

Let's take a small portion from the FX fonts in the bottom

fx1

No matter how hard you will try, the vertical lines of the I, H, and the first vertical of the M feel too heavy compared to the extremely thin and sharp last vertical line of the M. When working, these things give the Entry Editor font a very inconsistent feeling.

Let's look at the same portion with the FX-tweak turned on.

fx2

Not completely awesome, but definitely closer to the swing fonts. I hope that proves my case and I dearly hope that it will work as good on other Linux systems.

…t and bundled them into one single, general dialog "Some appearance settings you changed require to restart JabRef."

This prevents the issue that in the worst case the user is flooded with 3 dialogs saying basically the same: Settings changed, do a restart.

Added localization for the font tweak setting
@LinusDietz
Copy link
Member

Thanks for the explanation. I see the same effects that you explain when I zoom in, it is just that the screenshots without the tweaks look somehow clearer and more harmonic to read. What do you think, @JabRef/developers?

@halirutan
Copy link
Collaborator Author

@lynyus Let me be a visitor for while :) I'm happy if I can help and I'm using JabRef regularly, but I'm not sure how much time I have beside my other stuff. I'm fine with making a PR for the moment.

Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The font with the tweak on definitely looks more clear, but also a bit lighter (which is ok for me).

@koppor
Copy link
Member

koppor commented Oct 16, 2017

I like the screenshots with the tweaks.

Pro tip: One can drop images directly into the text boxes and GitHub uploads it transparently. No need for external hosters as stackoverflow does.


// On Linux, Java FX fonts look blurry per default. This can be improved by using a non-default rendering
// setting. See https://github.com/woky/javafx-hates-linux
if (Globals.prefs.getBoolean(JabRefPreferences.FX_FONT_RENDERING_TWEAK)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we just enable this for Linux by default then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I think it is okay like this. Giving the Users the possibility to opt out is a good thing here, as all screens are different and maybe some users prefer the heavier font over the lighter one (to me the untweaked font looks somehow more appealing)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm ok.

@LinusDietz
Copy link
Member

@halirutan thanks for the contribution! Such expert knowledge is always highly appreciated. If you need a break from research, you are always welcome to have a look at our issues. (;

@LinusDietz LinusDietz merged commit ebf39a4 into JabRef:master Oct 16, 2017
@halirutan
Copy link
Collaborator Author

halirutan commented Oct 16, 2017

@koppor Pro-pro-tip: The screenshot util on Linux can be configured to automatically upload images to imgur and gives you the link back. Only a Ctrl+V is required 😃

Hmm, but on a side note, I was under the impression that GitHub localizes all image links to imgur to its own hoster. At least I saw this happening in the past.

Siedlerchr added a commit that referenced this pull request Oct 19, 2017
* upstream/master:
  Update gradle to 4.2.1 (#3322)
  Avoid recreation of the EntryEditor (#3187)
  Fix #3133 telemetry by locking azure to 1.0.9
  German translation for missing properties (#3312)
  Improvement for Java FX font rendering on Linux (#3305)
  Add also conversion for em dash
  Add \textendash to the html conversion table
  Update latex2tunicode from 0.2.1 -> 0.2.2
  Added note about updating controlsfx
  Fix exception/freezing on EntryChangedEvent in Entry Editor (#3299)
  Update libs (#3300)
  update guava from 23.0 -> 23.2
  update mvvmfx-validation from 1.6.0 -> 1.7.0
  Resolves #3255 file open dialog should have "supported formates" filetype
  Fix #3235: remote metadata is updated instead of delete + insert (#3282)
  Change OO paths to Libre Office in preferences (#3287)
  Fix #2471: remove line breaks from abstracts in ADS fetcher (#3285)
  Resolves #3280 Empty String instead of N/A (#3288)
@halirutan halirutan deleted the fix-FxFontRenderingOnLinux branch October 24, 2017 01:07
@tobiasdiez tobiasdiez mentioned this pull request Sep 17, 2019
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants