Source Code Pro & PhpStorm, the plot thickens
Alright, so I thought everything was all set in my last post, however it turns out PhpStorm, Java and font rendering have a bit more issues.
UPDATE: The following fix also works for adding the various font weights that come with Source Code Pro (see bottom for screenshot).
UPDATE #2: Looks like for PHPStorm 8 (I’m running 8.0.1, specifically) and Mac OS X 10.10 Yosemite, you will want to use the ‘TTF’ format, and not the ‘OTF’, if you want the various weights to show up.
If you you have PhpStorm and your fonts look weird like one of the two screenshots below, then I have a fix for you.
It turns out that for things to work out it’s not the type of font (ttf or otf), not exactly. What’s most important for PhpStorm as a Java app is where the fonts are located. From my testing it looks like Java will fallback to ~/Library/Fonts or /Library/Fonts when it comes to PhpStorm but it will have troubles rendering (as you can see in these mangled screenshots). The ttf version of the font in one of the library folders is the less mangled of the two, but things fall apart when it tries to make up an italics and bold version. Unfortunately, Source Code Pro doesn’t come with an italics version.
I say make up an Italics version because with Mac OS X (and maybe Windows?) the operating system has the option of coming up rendering faux bold and italics versions of fonts. This works fine in Sublime Text but for PhpStorm the fonts have to be dropped in another folder.
The real fix
The answer is you must store these fonts in your Java home’s font folder. To find this out open terminal on your mac and type:
/usr/libexec/java_home or echo $JAVA_HOME
One of these two commands, most likely the first one, will return a directory path (Update: If this doesn’t work for you, check out this StackOverflow post as suggested by Emanuil in comments, thanks Emanuil!). Go to this directory path, then proceed to go to ‘lib’, then ‘fonts’ folder. In the case of my machine, the command returned /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/ and then I navigated to the containing lib/fonts directory ending up at /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/fonts
Now that you’re in your java fonts directory, put your Source Code Pro ttf or otf font file.
(Important: As mentioned at the top of the post in Update #2, as of OS X Yosemite and PHPStorm 8, it appears that only the ‘TTF’ format will bring in the various font weights for a family. You still need to include the TTF for each desired weight).
Restart PhpStorm and your fonts should be ready to go with bold, italics and everything. Note, one thing I discovered in my testing is that the otf and ttf versions of Source Code Pro rendered slightly different from each other. The ttf rendered slightly thinner, than the otf (screenshots below). I’m not sure if this applies to other fonts, or just Source Code Pro, but I thought I would mention it.
Hope that gets things going for anyone having trouble with fonts rendering properly in PhpStorm.
If you include the font files of the different Source Code Pro weights you will also get these different options, which some have reported as missing from the fonts menu. Instructions for placing the font files are as mentioned above.