views:

703

answers:

2

Hello,

I am using standard GWT (2.0.1) to make an internet app and i have this wierd issue with huge fonts (edit: well, larger than normal) with the default style in IE 7 & 8, while FF, Chrome and Safari are displaying fonts correctly. At first i thought it must be on error on my side (i use UiBinder with some custom css) but then I noticed that on the GWT showcases site the various widget fonts are also too big. Any ideas?

A: 

A quick comparison between Opera 10.10, IE 6 and FF 3.6 (all on WinXP SP3) - Opera and IE show slightly larger fonts. I'm not sure if that's GWT's fault - every browser has some core CSS rules defining the default look, if no additional CSS styles are applied (like that annoying blue border on all images in FF), so just make sure you set explicitly your font size, etc to nullify these differences.

That is, unless you are seeing fonts way larger than they should be - then it might be a bug.

Update: under Linux (Gentoo amd64) it's the same - Opera reneders slightly larger fonts than Firefox, but nothing that looks odd.

Igor Klimer
Well, fonts are larger by quite a bit (similar to a 120% zoom) - enough to break the layout on a few occasions. I thought that the default GWT style defined fonts for all the widgets but i could be wrong, i ll have to check on that. I just hope i don't have to explicitly define fonts for every widget that is being used.
nvrs
+1  A: 

This is due to IE default font size rendering and has nothing to do with GWT but rather with CSS styling.

You can ensure that fonts are consistent over multiple browser with a CSS like that (for instance):

*
{
    font-family: Arial, sans-serif;
    font-size: 12pt;    
}

body, table td, a, div, .p, pre 
{
    font-family: Arial, sans-serif;
    font-size: 12pt;
}

EDIT:

To ensure all widgets "get" this new style you need to put your CSS file in the *.gwt.xml file in the following way (the order of lines is important):

<inherits name='com.google.gwt.user.theme.standard.Standard' />
<stylesheet src="MyNewAndImprovedStyle.css" />

don't put it in the HTML page!

This will ensure that your style override the widget styles.

PS: You might override some widget styles by hand (I have a GwtOverride.css for that purpose) ... see snippet:

.gwt-TextBox,.gwt-PasswordTextBox,.gwt-DateBox
{
    border: 1px solid #BDBDBD;
    padding: 2px;
    background-color: #FFFCDA;
}


.gwt-ListBox 
{
    font-family: Arial, sans-serif;
    font-size: 12px;    
    background-color: #FFFCDA;
}


/* make dialog slick and nice */
.gwt-DialogBox .dialogContent 
{
    margin: 5px;
}

.gwt-DialogBox .Caption 
{
    background: #99B4CC;
    border-top: 2px solid #99B4CC;
    border-bottom: 1px solid gray;

    font-size: 110%;
    font-weight: bold;
    white-space: nowrap;
}
Drejc
I see your point but there's still a catch. GWT default style already defines fonts on widgets (not for plain HTML content i.e. content in HTMLPanels). Furthermore, when producing a similar style to the one you recommended i now get consistent fonts only on some widgets e.g. labels and not in content inside HTMLPanels (the styles are not applied there). This is obvously an IE CSS thing and it seems the time has come to learn to deal with it...
nvrs
I am pretty sure there is some css conflict with the default GWT css that affects only IE. I guess this isn't as simple as i originally thought and i also can't find enough information on the topic.
nvrs
@nvrs Forgot to mention some details ;) (see edit)
Drejc
Thanks, in general i ve sorted most of my problems out. I voted for your answer but i made a mistake and retracted the vote in the effort to accept it - sorry for that :( If you'd like, edit it so i can revote...
nvrs
I finally found out what was causing my css trouble with IE. I was using GWT 2.0 layout system and uiBinder but miss that:http://code.google.com/webtoolkit/doc/latest/DevGuideUiPanels.html#StandardsIt turns out that on quirks mode using UiBinder and any of the new panels messes up css big time on IE but not for the rest of the browsers. By messing up i mean that styles are not always applied/overriden, e.g. when creating a new gwt-button style in my stylesheet it did not apply to Button widgets in IE, but gwt-Listbox did!
nvrs