Icon Fonts: Mind the Baseline
Earlier this week, I made my first custom icon font using IcoMoon (implemented with Filament Group’s “bulletproof” technique).
I set my grid sizes and exported, but all the icons felt a little higher than I wanted them to be in relation to their surrounding elements. I did some finagling in CSS, but found the results varied (sometimes wildly) between platforms.
After some fruitless Googling, I trudged through the font’s preferences and found the culprit: A rather diminutive baseline height value. In IcoMoon, this is under Preferences, then Font Metrics.
Here’s a quick example at the default height (6.25%):
Here are the same elements and icons, but with a larger baseline height (18.75%):
Lesson learned: If the icon font’s vertical alignment is off, adjust its baseline height before resorting to CSS tweaks.
Tyler Sticka has over 20 years of experience designing interfaces for the web and beyond. He co-owns Cloud Four, where he provides creative direction to their multidisciplinary team. He’s also an artist, writer, speaker and reluctant developer. You can follow Tyler on his personal site or on Mastodon.