Computer Modern Bright
Computer Modern Bright is an excellent sans serif font. It has one consistent wrinkle, however: the tilde is positioned at accent height, for the original use as a diacritic. This same idiosyncrasy shows up in a number of Computer Modern variants; I don’t like this.
Fixing this using the fontTools library is quite simple, in fact.
Let’s make this sans-IO, and take a generic byte buffer as input and
output, for simplicity’s sake. All we need do is to make
asciitilde’s center be equivalent to plus’s
center.
import io
from fontTools.ttLib import TTFont
def patch_font(font_bytes: bytes) -> bytes:
font = TTFont(io.BytesIO(font_bytes))
glyf = font["glyf"]
tilde = glyf["asciitilde"]
plus = glyf["plus"]
dy = round((plus.yMin + plus.yMax - tilde.yMin - tilde.yMax) / 2)
tilde.coordinates.translate((0, dy))
tilde.recalcBounds(glyf)
out = io.BytesIO()
font.save(out)
return out.getvalue()
Here’s a live example of the before and after. Much more pleasant!
x ~= y
x ~= y