Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Add 'monospace' to the <code> font fallback list #1

merged 2 commits into from Aug 2, 2012


None yet
2 participants

evmar commented Apr 20, 2012

<code> blocks were coming out in a serif font on Linux.

Here's a picture of what the github page looks like on my Linux machines.
You can't rely on any particular font to exist on Linux, so it's best to leave in a generic CSS name as a last fallback.

evmar added some commits Apr 20, 2012

@evmar evmar Add 'monospace' to the <code> font fallback list
<code> blocks were coming out in a serif font on Linux.
@evmar evmar Fix "small monospace fonts" workaround to work properly
It's true that to get monospaced fonts to size right, you
need to munge the font fallback list.


But when a font named "monospace" isn't available, Chrome will fall back
on the next option in the list (serif, in this code), which results in a
serif font for <pre> blocks.

Instead, put a nonexistent font *first* so that it always falls
back to monospace.

evmar commented Apr 20, 2012

I added a second commit to fix a related issue about how WebKit sizes monospaced fonts.

I'm the author of some of peripherally related code in WebKit and the linked blog post so if you have any questions I'd be happy to answer them. (The name "WorkAroundWebKitAndMozilla" isn't special so feel free to shorten it if you want, it just needs to be a nonexistent font.)


evmar commented May 24, 2012



mattgraham commented Jul 23, 2012

Sorry @Martine its been crazy with the github android app release. I'll take a look at this and get back with you in the next few days. Thanks for the pull request.

@mattgraham mattgraham pushed a commit that referenced this pull request Aug 2, 2012

Matt Graham Merge pull request #1 from martine/monospace-fix
Add 'monospace' to the <code> font fallback list

@mattgraham mattgraham merged commit a919f68 into mattgraham:master Aug 2, 2012


mattgraham commented Aug 5, 2012

Thanks @Martine your pull request has been updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment