That is, let's say there's no css definition for a particular element, so it's using the default. Or, whether there is or not, let's say the user has set their browser to override the page-fonts with their own fonts.
I want to be able to get the font information for the font the user is actually seeing, and ideally, a method that will work with IE6 and 7, Firefox, and it would be nice if it also worked with Safari and Opera, although IE and FF are the primary concerns.
Man, I think I'm starting to hate companies that develop web browsers!
Anyway, I tried getComputedStyle (and the equivalent for IE, currentStyle), and came up with more variation in how each browser handles things than I would like.
The browsers I used, all on WinXP, are: IE 6 Firefox 22.214.171.124 Opera 9.25 Safari 3.0.4
Now, my ultimate goal is to pass this data over to a Java program, in order to set colors, font size/face/etc, to make the Java program seem as seamless to the browser front end as possible.
Anyone know how to resolve the various issues I'm about to describe below:
1) Background color: Safari gives me an rgba(0,0,0,0) value - easy enough to translate, as is IE6's #rrggbb value. Firefox and Opera, on the other hand, say "transparent" rather than giving me an actual color that's being used. Is there any way to get the actual color? My method was:
2) Font size: Lovely. Nobody can agree on what sizing mechanism to use. IE gives me point size, which I prefer, thus says 12pt. Safari and Firefox give a px size. Is there any way to convert from px to pt?
Opera is even worse. Depending on what is or isn't chosen in the Style menu under "View", it'll give px, em, or even, for size, say "sans-serif"
Is there a way to force everything to convert to point-size by any chance?
3) Font face: Safari, Opera, and IE are all good with this, they give me an actual font name. Firefox, however, will say "serif" or "sans-serif". Apparently in their display options, you choose whether you want serif or sans-serif to be the default font, and then choose which font is "serif" and which font is "sans-serif"
I'm trying to get the actual font name that Firefox uses ultimately. Is there a way to get that information (ie: "Times New Roman" or whatever).
Thanks again in advance to anyone who can offer pointers.