tonsky / FiraCode

Free monospaced font with programming ligatures
SIL Open Font License 1.1
77.29k stars 3.1k forks source link

[Windows, LoDPI, OTF, some font sizes] Weird dot placement over "i" and "j" #693

Open ForNeVeR opened 5 years ago

ForNeVeR commented 5 years ago

On Windows in Java-based apps for bold font variant I get weird placement for dots over "i" and "j".

It is easier to spot in Java-based applications due to specific font sizing, bug it looks like actually every program is susceptible to this.

  1. Install OTF Fira Code fonts on Windows
  2. Make sure you have a LoDPI display (e.g. Windows font scale = 100%)
  3. Execute the following Java program:
import javax.swing.*;
import java.awt.*;

public class Main {
    private static void createAndShowGUI() {
        JLabel label = new JLabel("AggressiveInlining ijij ijij");
        label.setFont(new Font("Fira Code", Font.BOLD, 14));

        JFrame frame = new JFrame("Fira Code Demonstration Program");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        frame.getContentPane().add(label);

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

    public static void main(String[] args) {
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }
}

Check how dots over "i" and "j" are weirdly placed (looks like they've been moved to the right):

image

Other font sizes (e.g. 13 or 15) usually work okay, but e.g. for 16 it looks like dots are moved to the left:

image

I'm not sure if it's Fira Code issue or not, but looks like dots placement works strange not only for Java programs. E.g. compare these two screenshots from Visual Studio (which works better in that aspect but still not ideal):

image

image

Looks like the dot is misplaced to the left for size = 12.

I wasn't able to reproduce the issue with TTF fonts or on a retina display. So, for now the best advice for users who have the issue is to switch to TTF variant of Fira Code.

tonsky commented 5 years ago

Yes TTFs seem to work better on windows

ForNeVeR commented 5 years ago

That's very strange and weird. Do we have any explanation? I've tried to compare ttf and otf glyphs using fontforge, but wasn't able to see any noticeable differences, I'm not a font expert though. These files are produced from the same sources, right? So the only difference is inside of a Windows font renderer, and we have completely no control over it?

tonsky commented 5 years ago

My guess is Windows applies different hinting to different formats. Or maybe only TTFs has hinting info?

ForNeVeR commented 5 years ago

The issue looks almost non-actionable from FiraCode side (I'll try to report the issue to Microsoft though), but should we change the Fira Code Chocolatey installer to install TTF instead of OTF? What are pros/cons of such decision? Is this issue tracker the right place to discuss Fira Code Chocolatey installer? Should I file a separate issue?

tonsky commented 5 years ago

I have no idea who maintain it, but it should install TTF by default, yes.

ForNeVeR commented 5 years ago

Alright, I will reach them. Thanks a lot!

Quppa commented 5 years ago

At least some Windows software definitely seems to prefer TTF over OTF - I noticed in the (quite dated) native Font dialog box that only the TTF version will get ClearType rendering (OTF on the left, TTF on the right): 2019-09-19 ClearType

Likewise in Notepad++ there was no ClearType rendering with the OTF version (unless 'Enable smooth font' is toggled on - the TTF version doesn't seem to need this). Notepad2, which lacks such an option, doesn't render Fira Code with ClearType if the OTF version is installed.