source-foundry/Hack

Fonts gone crazy after installing v2_018 on Jetbrains [Java renderer]

rahilwazir opened this issue · 78 comments

Fonts gone crazy after installing the v2.018 but its working fine with v2.010, I did restart Jetbrain IDE. Increasing/Decreasing font have still same effect.

crazy-fonts

Thanks for reporting it. Can you give us your platform, the editor, and indicate whether you are using the ttf or otf builds?

Sure, here you go

Not sure should I open a new issue for this or not but using v2.010 shows same wierd fonts on multiline comments, when writing /** (double asterik)

Example:

code-comments-crazy-fonts

We will take a look into the initial issue that you reported. This was a direct upgrade from the v2.010 to the v2.018 release?

Yes It was

thanks!

fruel commented

Did a direct update from v2.010 to v2.018 today too.
Visual Studio, Sublime Text 3 and all other editors are fine but all JetBrains IDEs are messed up (Android Studio 1.5, PHPStorm 10, IntelliJ 15).

System:
Windows 10 Pro x64
Installed TTF version.

Never had any rendering issues prior to v2.018.

are messed up

Can you be more specific? Are you seeing character changes like in the OP image?

fruel commented

Sorry forgot - pretty much the same as OP reported it.

Example: Laravel composer.json file
image

Edit:

It should look like this:
image

And this is the settings dialog:
image
image

Seems to be some strange Windows + JB renderer-specific issue. Here is where I am in PyCharm 4.5 (old version) and the current PyCharm 5.0.2 release:

PyCharm 4.5

pycharm4

PyCharm 5.0.2

pycharm5

My understanding is that PyCharm uses the same Java based text renderer. I modified the text size to 12 and have line spacing at 1.0. This does not seem to influence the display on OS X.

Are either of you willing to submit an issue report on the JetBrains tracker to investigate this? I don't develop on a Windows platform and it will be difficult for me to work through the issue with them. I'd be happy to follow the thread, pitch in information from the standpoint of our fonts (including OpenType table settings if that is where this winds up existing) and implement any changes that they recommend if they are able to identify what is going on with the renderer in the Windows editors.

Will take a look at a diff of our OpenType table data between the 2.010 and 2.018 versions this week as well. Perhaps this will lead to some useful information.

If you are willing to take the time, would it be possible to check each of the release versions between 2.010 and 2.018 to determine where we introduced the problem? This might point us in the direction of an answer if it lies in the OpenType table settings.

fruel commented

It seems to be a general issue with the Java font renderer - not specific to JetBrains IDEs.

I wrote a quick test application using the generic Java Swing GUI system. It prints the text "Hello World" twice - on the left using Hack and on the right using the default monospaced font.

image

Sourcecode: https://gist.github.com/fruel/1e4471b5474708f9c3e1

Maybe someone else can confirm that other Java-based application are affected too.

Edit:
My Java version

java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b18, mixed mode)
fruel commented

Tested the old versions with the test application from the comment above. The issue starts with v2.017.
v2.015 and v2.016 (from here #126) are fine.

@fruel Thank you! I will take a look at our OpenType table changes between those versions.

Are you aware of other text editors that use this renderer?

Are the editors here being released with a bundled JDK? That seems to be the case on OS X.

fruel commented

I tested a few other applications with v2.0.17:

jEdit
http://sourceforge.net/projects/jedit/
Is affected by the bug and has definitely no bundled JRE.

eclipse
Version: Mars.1
Not affected
Don't think it has a bundeled JRE.

NetBeans 8.1
Affected
Not sure if JRE is bundled.

I think NetBeans and jEdit use the same GUI system whereas eclipse uses something different. (NetBeans and jEdit have similar look & feel and the font-selection dialogs are identical)

Wikipedia confirms this:

Eclipse implements the graphical control elements of the Java toolkit called SWT, whereas most Java applications use the Java standard Abstract Window Toolkit (AWT) or Swing. 

@fruel Thank you very much for all of this information. This is extremely helpful. I will post some information about the differences in our OpenType tables between the identified versions this week.

fruel commented

New discovery:

I have multiple Java versions installed and only older ones are affected. When installing NetBeans it seems the installer changed the default Java runtime as Hack v2.018 is now working everywhere except in NetBeans.

I tested this manually with the my test application from above:
v2.018 works fine in my test application with JRE 1.8u66 x64 and JDK 1.8u66 x64 but not with JDK 1.8u51 x64 or JDK 1.7u55 x86

What Java version do you have on OSX?

java version "1.8.0_05"
Java(TM) SE Runtime Environment (build 1.8.0_05-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.5-b02, mixed mode)
fruel commented

OK...this thing is getting really weird....

If I start my test application from the command line using 1.8u51 it does not work but IntelliJ claims to be running with 1.8u51 and it is working now:

image

image

Edit: Of course I restarted all applications every time the Hack version changed

Edit2: Ok...IntelliJ uses a bundled JRE - but why did Hack start to work after installing NetBeans...really weird

PyCharm v5.0.2 on OS X:

jre-version

Different than the installed version on my PATH.

Please reopen if this remains an issue for you.

I'm not sure why did you close this issue, but this issue still exist with latest Webstorm v11.0.2 and JDK v8u65

@rahilwazir More than happy to continue to help here though I am not on Windows and cannot reproduce the issue on OS X versions of JetBrains editors.

@fruel would you be willing to release that code that you used to render fonts with Java? This would be an extremely helpful tool for us and might help us locate the problematic JRE versions. Perhaps with this information, one of the two of you could submit an issue report on the JetBrains issue tracker so that we can explore this in more detail.

fruel commented

You can find the source code for my demo application linked im my comment from Nov. 29. It's a basic java window.

It still does not work for me in Android Studio but it works in PHPStorm - I'm not sure why or what version of java are affected as it behaved really weird.

@fruel thanks! sorry, I missed the link.

@fruel & @rahilwazir: Here is where I am on OS X with Java(TM) SE Runtime Environment (build 1.8.0_05-b13) vs. Source Code Pro:

java1

and with Java(TM) SE Runtime Environment (build 1.8.0_66-b17):

java2

@rahilwazir can you link the JRE that your version of WebStorm is using on Windows?

Scratch that, you have it above. Will you link your system java version and try the test with the Java rendered text window using this Main.java file:

import javax.swing.*;
import java.awt.*;

public class Main {

    private static void createAndShowGUI() {
        JFrame frame = new JFrame("Hack Test");
        frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        frame.setLayout(new FlowLayout());

        JLabel label = new JLabel("Hello World");
        Font test = new Font("Hack", Font.PLAIN, 18);
        label.setFont(test);
        frame.getContentPane().add(label);

        JLabel label2 = new JLabel("Hello World");
        Font test2 = new Font(Font.MONOSPACED, Font.PLAIN, 18);
        label2.setFont(test2);
        frame.getContentPane().add(label2);

        frame.pack();
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(Main::createAndShowGUI);
    }
}

If you need it, compile on OS X is:

$ javac Main.java

then launch is:

$ java -cp ./ Main

I'm guessing that you simply switch to Windows paths for the compiled binary root directory with the -cp switch on Windows, correct @fruel?

@fruel possible to modify this script to read in a text specimen file and render on a scrollable display window with Java? I'd like to turn this into a tool for typeface developers. Interested?

fruel commented

"I'm guessing that you simply switch to Windows paths for the compiled binary root directory with the -cp switch on Windows" - Yes, same commands - only with Windows paths.

Demo application:
I can't promise anything as I've many other things to do right now but what would you need?
Loading a textfile and a TTF file and a window to display the text in the given font?

Thank you. Yes that description fits. I would need some help with the file I/O and Swing UI. Not a Java developer and would like to have something simple that will test rendering with Java since these JetBrains editors have caused us a significant number of problems and are so widely used. This was a great idea that you had and I think it will help with tests out of the editor with other Java versions. Do you happen to know if the Font class supports a setting to apply and not apply True Type instructions (hinting) in the rendered fonts?

and my scrollable comment simply meant that we will need to be able to support reasonably large blocks of specimen text so the UI window should support text overflow with a scrollbar.

fruel commented

Ok - I might be able write it on Saturday or Sunday.

About the hinting: Not sure. Have to check the docs.

Absolutely no rush at all. I will take a look through the documentation too.

@rahilwazir Rahil, will you be able to provide the information above about the success with the Java versions on your system? This should help us to better understand this problem.

@fruel let’s move the conversation about the tool to #161. We will continue to discuss @rahilwazir's original issue here. Let me know if you’d like me to create a repository for this. I am happy to host it in our Source Foundry organization if you’d like.

Sorry for the change in status, I had posted the result of Linux machine mistakenly

Anyway here is the result (Compiled with javac 1.8.0_65):

hack_java_font

@rahilwazir it looks like it is time to go to JetBrains for more information. That is the same version as the reported version in WebStorm and it renders fine. Mind submitting your issue in their issue tracker and update us with the outcome? Perhaps they modified the Java font rendering code in some way?

I have posted the issue, just so you know:
https://youtrack.jetbrains.com/issue/IDEA-149554

I'll update here if I get any reply from them

Hi @rahilwazir !

I've had this issue too and it was because I've installed a newer version of the Hack font without removing the existing one.

Also, you need to restart your IDE.

Hope this helps.

fruel commented

While working on the test tool for #161 i discovered that the fonts on my PC are messed up. It looks to me that there were multiple versions of Hack installed as some applications were using C:\Windows\Fonts\Hack_Regular.ttf and some C:\Windows\Fonts\Hack_Regular**_0**.ttf

I removed Hack from the Windows fonts folder (had to do it multiple times as the file reappeared) - but some Java applications are still able to use it.

TL:DR:
Windows is messed up. Might explain the confusing results in my previous comments. Will try it on another computer.

@rahilwazir Thanks Rahil! I will keep an eye on it as well.

@yoyosan Thanks for this information Marius. Really appreciate it.

Windows is messed up. Might explain the confusing results in my previous comments. Will try it on another computer.

Interesting. I wonder why it would lead to a render with incorrect glyphs rather than simply selecting one or the other set of font files? Perhaps this belongs on a Windows issue tracker?

@fruel Thanks for creating the Java font testing tool by the way. It looks great!

@yoyosan Thanks that actually worked, but this is so weird, not most of the users remove fonts when they upgrade.

@chrissimpkins Can you please make a note of this update process on readme for future readers. I'll close this once you do.

I'd be glad to. What approach did you use to delete them prior to the install?

Just navigate to c:\windows\fonts, search for the Hack font and delete, then install the newer version.

@chrissimpkins Go to Control Panel\Appearance and Personalization\Fonts(Windows 7), search for Hack, right click and Delete.

@rahilwazir @yoyosan both of these approaches fix the issue?

And is there a reboot involved? I saw that the editor needs to be closed and reopened in the comments above.

I'm not sure about the yoyosan solution (as I'm not currently on my Windows machine).
Yes the editor needs to be restarted.

@chrissimpkins Yeah both approaches works, @yoyosan solution is other way around

I will add this to the README and let you know when it is available. Thanks again. Odd problem.

README updated with workaround for this issue. Users are still having the problem and the issue report remains open on the JetBrains tracker. Will continue to leave the issue open here for reference.

@chrissimpkins The issue is closed now

Alright, I will close this issue. Thanks for raising it @rahilwazir

@fruel I know this issue is closed, but just for the sake of documentation: The issue that you suddenly had a C:\Windows\Fonts\Hack_Regular.ttf and some C:\Windows\Fonts\Hack_Regular**0**.ttf file is caused by the _Fonts applet.

As soon as you open C:\Windows\Fonts (or use _Fonts_ from Control Panel) and then drag&drop a TTF file that is already there and/or locked, Windows will decide to copy the file as OrignalFileName**_0**.ttf. This doesn't make any sense, but that's what the coder of the Microsoft.Fonts applet did.

@texhex Thank you for this information Michael. Appreciate the feedback. Odd that the duplicates that include different file paths lead to such problems...

@texhex Nice to know, thanks for the inside

iflp commented

Does anyone have this this issue after upgrading to webstorm 2016?

@ragingnerd Well you are correct, I forgot to comment here.

@chrissimpkins Can you look into this? PHPStorm 2016 causes this behavior again, even deleting old fonts before installing the new one.

OS: Windows 10 x64,
IDE: PHPStorm 2016.1

@ragingnerd @rahilwazir

Can you both confirm that you do not have duplicate fonts as a result of the Fonts applet issue that @texhex reported in #152 (comment)?

iflp commented

@chrissimpkins

I think that might be the root cause. Font properties for the individual types show up as:

  • Hack-BoldItalic_0.ttf
  • Hack-Italic_1.ttf
  • Hack-Bold_2.ttf
  • Hack-Regular_3.ttf

but all my system fonts have a suffix of _3 (Eg. arial_3.ttf)

I've tried uninstalling the font, doing a clean reboot and reinstalling the fonts by clicking on them individually, then invalidating cache and restarting the ide.

OS: Windows 8.1 x64
IDE: WebStorm 2016.1

@ragingnerd any idea how those numbers are being applied? Is that install order or is Windows supplementing the file path with variant meta info through the number? This numbering system in the file paths (on clean installs) seems to be a new Windows issue. I wonder if we are dealing with a change in Windows rather than the JetBrains editors.

iflp commented

@chrissimpkins no idea at this stage. I've tried reinstalling 2.019 and 2.018 .TTF fonts, the number of times / order I install the fonts in have no bearing on the numbers. I've also tried installing the Hack OTF fonts - no suffixes.

@ragingnerd thank you for checking! do you see this problem with the otf builds?

iflp commented

@chrissimpkins no problem! 2.019 .OTF Bold is fine, the other 3 have _0 appended to them - IDE renders everything in bold.

@texhex I think we may need your expertise here. Any thoughts about these issues with the Windows installs?

@chrissimpkins OK, I will do my very best. Let's see if this is enough :)

@ragingnerd First, we should remove anything "Hack" related in order to have a clean state. Please first go to the Fonts applet (Right-click on Start menu -> Control Panel -> Appearance -> Fonts). Search for Hack and hit delete. Windows should then delete the fonts. If it says something about File XXX in use, can't delete don't worry. Next, restart the machine. Trust me, Windows requires this because of all the caching it does. Once the machine is back, fire up Regedit.exe and move to

HKEY_LOCAL_MACHINE -> SOFTWARE -> Microsoft -> Windows NT -> CurrentVersion -> Fonts

Inside this, locate the entries ("Name") starting with Hack (TrueType) etc. and delete them. Also, check if the column "Data" lists anywhere any Hack_XX.ttf entries. If so, delete them.

Finally, below "Fonts" inside regedit.exe (left side) is another entry called FontSubstitutes. Check if there are any entries listed with "Hack". If so, delete them.

Restart the machine.

Move back to the Fonts applet and check if there is still something "Hack" related listed.
If so delete it and recheck the registry again. There shouldn't be anything, but you never now.

Finally, we do a check if really a files are gone. Open CMD.EXE and execute dir "C:\Windows\Fonts\Hack*.*". There should be no result. If there are files listed, delete them.

Restart the machine one final time. Recheck WebStorm. It shouldn't list Hack anymore and using any other font should be OK. If it still lists Hack, please let me know. In this case we might have the rare case of a damaged Font Cache 3.0 which requires stopping the "Windows FontCache" service and deleting the "FontCache3.0_.dat" file in _C:\Windows\ServiceProfiles\LocalService\AppData\Local*.

Then try to install Hack again by drag&drop the TTF file to the fonts applet. And you know it already: Restart the machine after that before trying to use the font.

That's all I can think of right now. HTH!

P.S.: If you think the font handling of Windows is b0rken by design: I couldn't agree more :).

@texhex Wow, that is a convoluted mess on Windows. It sounds like Windows doesn’t intend to have fonts updated very often. Thanks so much for all of this information. @rahilwazir @ragingnerd please let us know if the above works for you.

@chrissimpkins Yes, it's a total mess. The main problem is that Windows has several "data stores" (Files, Registry, Cache) and no sanity check in place if this all makes sense. I would assume that single coder, that has the full backup from the Windows lead, could get all this sorted out in less than two weeks or so. But hey, it only took them two Windows version to bring the start menu back :-).

@chrissimpkins Well that actually works 😄

Thanks @texhex once again, so weird shit going on

iflp commented

@texhex @chrissimpkins All sorted, thanks for your help!

Btw for anyone having the same problem, when I do a dir "C:\Windows\Fonts\Hack*.*", there are hack files but they are hidden on the font applet. I had to del dir "C:\Windows\Fonts\Hack*.*" on an elevated cmd to get rid of it.

@ragingnerd Good to hear. Finally you can enjoy the most awesome font ever :-).

Blunt self promotion: I have create a setup.exe for Hack (and some other fonts) that should make installation on a new machine rather easy. It takes also care about those Hack_0/1/2.ttf files and about the Font Cache service(s). You might want to give it a try for the next machine: OS Font Pack.

Note: This setup is not approved by @chrissimpkins, but I hope some day it will.

I hope some day it will

I will try to get the docs updated this week. Sorry for the delay and thanks again!

@chrissimpkins No rush needed Chris, I just wanted to make sure that the setup is not "official". The message wasn't intend to push you to anything. Really.