6
votes

I'm on Ubuntu 15.10 and use Chrome (47.0.2526.106). As I understand "monospace" is simply an instruction (as in not a specific font) to use the "system" monospaced font. In Chrome Settings the "Fixed-width font" is set to "monospace". Then in my Tweek Tool Fonts Monospace I've set Courier -- but what I see when a page (e.g. a simple error page) comes up is not Courier but something that resembles Ubuntu Mono, but not exactly. What font is Chrome using? Is it sending a font, or is it using something else on my system?

2
Close, but crucially wrong: it's an instruction to use any monospaced system font that is available. Spec-wise there is zero requirement that consecutive loads even use the same font. So: there's no way to tell, don't rely on CSS font family generic fallback keywords to yield anything you can ever rely on. What's the problem you're actually trying to solve that requires knowing the monospace font?Mike 'Pomax' Kamermans
I want to use it, is why I ask. So you're saying it is, in fact, grabbing something from my system and not sending it "embedded"?147pm
No, what I said was "you can't ask about which font is being used because it can differ for every computer". If you want to use the font that you are seeing on your computer, then just screenshoot it and then use a service like whatthefont to find out what it is. Generally the easiest, and for common fonts (which this will be) super reliable.Mike 'Pomax' Kamermans
MyFonts forum says DejaVu Sans Mono, and I agree. (It is installed on my machine, BTW.) Happy ending.147pm

2 Answers

9
votes

Type this url into your browser (chrome://settings/fonts) and see which font is set for "fixed width."

0
votes
var font = 'monospace';
if(navigator.userAgent.match(/Chrome/gi) || navigator.userAgent.match(/Opera/gi)){
    font = 'Courier';
};

pre_element.style.fontFamily = font;
textarea_element.style.fontFamily = font;