Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

assigning a CSS fontFamily ending with a number

so it seems that if I assign a font family ending with a number it doesn't stick

a = document.createElement("div")
a.style.fontFamily = "Arial"

and a is then

<div style="font-family: Arial; "></div>

BUT

a = document.createElement("div")
a.style.fontFamily = "Goudy Bookletter 1911"

and a is then

<div></div>

I'm pretty sure its the ending number that is the problem. Since

a = document.createElement("div")
a.style.fontFamily = "Goudy Bookletter blablabla"

and a is then

<div style="font-family: 'Goudy Bookletter blablabla'; "></div>

Is this a bug? I'm doing this in chrome 16

like image 818
fynyky Avatar asked Jan 21 '12 08:01

fynyky


1 Answers

Something about the spaces and numbers causes a problem when setting font-family. Enclosing the font-family name in single quotes allowed it to work in Chrome 16 for me.

http://jsfiddle.net/ZMxS4/1/

a.style.fontFamily = "'Goudy Bookletter 12'";

Without the quotes I saw the following odd behavior

a.style.fontFamily = "Goudy Bookletter12"; //works
a.style.fontFamily = "Goudy 12Bookletter"; //works
a.style.fontFamily = "Goudy 12 Bookletter"; //does not work
like image 171
mrtsherman Avatar answered Sep 25 '22 07:09

mrtsherman