Search This Site

Custom Search

Thursday, November 11, 2010

Re: [bloggerDev] Problem with Gadget Skins - FONT_FACE identified

yea and in some cases, the FONT_FACE doesn't hold a proper font value. (It might in some cases hold the font family).. So in addition to checking the last character, i also scan for spaces  within the string(not a correct method as the font name itself can include spaces) and commas

if (font.charAt(font.length - 1) == ";") font = font.substr(0, font.length - 1);
if(font.indexOf(" ")!=-1||font.indexOf(",")!=-1) myLink.style.font = font; else myLink.style.fontFamily=font;
..

On Wed, Nov 10, 2010 at 10:53 AM, Aratina Cage <aratina.cag3@gmail.com> wrote:
I was just alerted to a problem where my gadget was not displaying the
font correctly, and I traced the problem down to a small but crucial
error in how the skin style for FONT_FACE is created on blogs that
have their main font modified through the Template Designer. What
happens is that a semicolon somehow gets attached to the end of the
FONT_FACE string. Normally the semicolon is not there, and unmodified
blogs have a FONT_FACE skin style that looks like this (\x27 is a
single quotation mark):

"normal normal 13px \x27Trebuchet MS\x27, Trebuchet, sans-serif"

But blogs that have their font-family or font-size changed through the
Template Designer get a FONT_FACE skin style with a semicolon tacked
to the end, like this:

"normal normal 13px \x27Trebuchet MS\x27, Trebuchet, sans-serif;"

The semicolon at the end renders the FONT_FACE style string unusable
when it is used to set the font style of an HTML element in
JavaScript. For example (you can test this in an HTML/JavaScript
gadget on your blog):

<div id="elementX">Test 123 Test</div>
<script>
var elementX = document.getElementById("elementX");

elementX.style.font = "normal normal 13px 'Trebuchet MS', Trebuchet,
sans-serif;"; // works in IE, does not work in Chrome, FF, Safari, or
Opera

elementX.style.font = "normal normal 13px 'Trebuchet MS', Trebuchet,
sans-serif"; // works in all major browsers
</script>


The workaround is, of course, to test the last character in the
FONT_FACE style string for a semicolon and delete it if found.

--
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To post to this group, send email to bloggerdev@googlegroups.com.
To unsubscribe from this group, send email to bloggerdev+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bloggerdev?hl=en.


--
You received this message because you are subscribed to the Google Groups "Blogger Developer Group" group.
To post to this group, send email to bloggerdev@googlegroups.com.
To unsubscribe from this group, send email to bloggerdev+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/bloggerdev?hl=en.

No comments:

Post a Comment