Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use a specific font only when the user is running Linux?

Tags:

jquery

css

Is there a way to detect a Operating system using JQuery or CSS? With CSS I'm referring to something similar to <![if !IE]>

I need to use a specific font only when web page is viewed using Linux and don't want to include this with other os's

like image 455
Elitmiar Avatar asked Apr 18 '10 08:04

Elitmiar


2 Answers

examine navigator.userAgent

You can generally find what you seek with simple rx but to do so will require a basic understanding of sniffing. You can find a good example here.

NOTE: i am not suggesting that you use a sniffing library, just that you familiarize yourself with what you need to look for.

As far as dynamically controlling fonts by OS, I think that, barring some edge case that is not stated in your question, simply defining a font stack is your best bet.

like image 51
Sky Sanders Avatar answered Nov 15 '22 10:11

Sky Sanders


Though not directly answering the question of "detecting O/S", you may be able to achieve the desired effect of selecting a font using the font-family CSS property.

This property lets you chose a list of fonts, where the browser will try to match fonts available on the system. It reads left-to-right and will use the first font available:

body
{
    font-family: "Calibri", "Arial", "Sans Serif"
}

In this case, if the "Calibri" font is not available, the system will use "Arial". If "Arial" cannot be found, it will use any available fonts from in the "Sans Serif" family.

With this you can specify your Linux-specific font first and know that other platforms without the font available will display using a suitable font too.

like image 26
Paul Turner Avatar answered Nov 15 '22 08:11

Paul Turner