Killing Comic Sans

Sure, you could just uninstall the Microsoft core fonts (they are non-free, after all), but they’re nice to have around (I guess?). Or you could just remove Comic Sans itself, but maybe you’ll one day want to use it for good or ill (who knows?) So instead you might turn to fontconfig.

First you might try a substitution rule like:

<alias>
    <family>Comic Sans MS</family>
    <prefer><family>DejaVu Sans</family></prefer>
</alias>

The prefer families specified should (?) be used before using the matched font family, even if it exists. But in testing, that didn’t work for me. Don’t force it, use a bigger hammer.

So I switched to a match/edit rule like:

<match target="font">
    <test name="family" compare="eq" qual="any">
        <string>Comic Sans MS</string>
    </test>
    <edit name="family" mode="assign">
        <string>DejaVu Sans</string>
    </edit>
</match>

This worked, but was too big of a hammer for my taste. For example, in gedit font selection it no longer says, “Comic Sans MS.” It just says, “DejaVu Sans.” What we’re after is substitution of the face, not the whole entry.

As I’m not in the habit of using Comic Sans by choice, the target of the exercise is the web. Ah, but it’s much easier to replace the font for the web. So we walk away from fontconfig and walk over to Stylish (or userstyle.css if you don’t want an add-on to help).

Now we just need a rule that tells the browser, “replace Comic Sans when you see it.” In comes @font-face. We can use this to define, for the browser, what the meaning of a particular font is:

@font-face {
    font-family: "Comic Sans MS";
    src: local("DejaVu Sans");
}

Great! Well, great-ish. We can’t specify the alias “sans-serif” because it’s an alias. That means if you change which font your alias uses (in this case, away from DejaVu Sans), it will require you to update your style rule.

We have limited options here. You could specify the font-weight, but that will interfere with the site’s own weighting. The best case is to use a distinctive replacement font. Or just give up (my choice in this case). Defeating Comic Sans is enough, no need to gloat.