Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Can't set a font typeface for the Body of a report(Can't set a font typeface for the Body of a report)
Can't set a font typeface for the Body of a report [message #1690068] Tue, 24 March 2015 23:06 Go to next message
Al Koch is currently offline Al KochFriend
Messages: 62
Registered: August 2011
Member
I have a report (based on a Template that pulls from a Library if that matters) where I need to specify a particular font typeface. Actually, I want to specify a selection list of typefaces but the Designer's Edit facility that allows changes to the default report style only allows selection of a particular typeface and not a list. So, to define a selection list of typefaces I have tried to use a CSS file. In trying to get this to work I have discovered that I can't even specify a single font typeface for the body of a report.

In normal CSS we can define this:
body {
	background: yellow;
	font-family: Impact, Charcoal, sans-serif;
	color: red;
	}


Due to the "cascading" aspect of CSS this, of course, results in all text anywhere on a page (even within other page elements) being rendered in the Impact typeface (assuming it's available on the system, if not then Charcoal or sans-serif is used). In BIRT I have done the following to try and replicate this desired behavior:

1) In the report I have deleted the default "report" style that defines a typeface.
2) I have a CSS file that contains:
report-body {
	background: yellow;
	font-family: Impact, Charcoal, sans-serif;
	color: red;
	}

3) I have used a "Use CSS" on the Styles in Outline and pointed at the CSS file.
4) On the Master Page I have applied the report-body style. (It appears that I cannot apply any style to the Outline page itself.)

Here's what I get:
1) The "background: yellow" is applied to all pages as expected.
2) The "color: red" is only seen in the Header and Footer of the Master Page and it fails to cascade down into a Text element placed on the Outline page.
3) The "font-family: Impact, Charcoal, sans-serif" is completely ignored everywhere.

From this simple test it appears to me that the CSS feature of BIRT is only working in a limited fashion.

Can someone help me see what I am doing wrong here?

Thank you.
Re: Can't set a font typeface for the Body of a report [message #1690334 is a reply to message #1690068] Thu, 26 March 2015 16:12 Go to previous messageGo to next message
Jesse Freeman is currently offline Jesse FreemanFriend
Messages: 184
Registered: January 2015
Senior Member
Could you elaborate on your desired use case with the list of type faces?

Regarding the results you are getting from your CSS change, what I believe is happening is that the portions that are not respecting the change have those properties set at a lower level which is overriding what you have specified for report-body.

Through the BIRT Designer GUI, you can go to the elements that are not taking the changes and inspect the particular setting within the elements Advanced menu in the Property Editor. My guess is each of these elements will already have that property set to a different value.

For more confirmation, you can use your web browsers debugging tools (I prefer Chrome for this) and drill down in the DOM tree to the elements that aren't taking your CSS changes. You should then be able to see which CSS properties are being used for that particular element.

[Updated on: Thu, 26 March 2015 16:13]

Report message to a moderator

Re: Can't set a font typeface for the Body of a report [message #1690362 is a reply to message #1690334] Thu, 26 March 2015 21:07 Go to previous messageGo to next message
Al Koch is currently offline Al KochFriend
Messages: 62
Registered: August 2011
Member
Hi Jesse,

Thanks for the response - it gave ma a couple of things to go look at.

Here are some interesting new pieces of information:

1) Use Case: As you know we can't depend on the OS of the User viewing a report to necessarily have a particular font so it is a good practice to specify a list of "similar" fonts so the browser can hopefully locate one. IMO, this is such an important thing to do it would be useful if BIRT was enhanced so that we could do this without having to go to the extra steps involved with using a CSS file.
2) I wasn't looking at the Advanced tab. When I did I saw that the Master Page's Advance font did show the font-family selection list from the CSS file! But if I then clicked on an element in the Header or Footer (which come from a Library) that showed a font of "Verdana: inherited". So I went back to the Library and applied the CSS file's style to the Library and I still got Verdana. Finally I deleted and re-placed the Text element and back in the reprot we suddenly got the font-family on the text element! So then, in the Library, I set that new Text element to Verdana, 18 pt and returned to the report and we were back to "Verdana". It looks like if I apply a style to an element in a Library, use that element in a report and then apply a style to the report's Master Page, it doesn't override the style I applied back in the Library. Is that observation correct and is that how BIRT should operate? I would think that it's useful to allow an override of a style applied in a Library when you are in the report design.
3) Now that I know what I have to do to get "font cascading" to work on the Master Page I see that it does not work at all for elements on the Layout Page. I simply place a text element on the Layout page (with no changes to its style) and its font is not being set to the Master Page's font-family - it is set to "serif". (Note however, that the CSS file's Background color is being applied to the Layout page which seems inconsistent!) I can manually apply a style to the element to get the desired font-family list, but this whole effort has been to try and define a font-family preference list, apply it once and not have to apply a font style to every element used in the report. Standard HTML works this way for fonts if a font style is applied to the <body> element. BIRT does apply a Background style bur shouldn't it also do the same for fonts?
4) In all of the above I noticed that a Library's Outline does not show Styles but only Themes. Why is that the case?
5) To easily see if various changes are being applied I've been using "dramatic" fonts but it appears that BIRT ignores "Wingding" and "Webding". I have confirmed that these (standard Window font families") are on my system and I can use them in, say, a Word document. But if I try to use font-family: "Webdings", sans-serif; or font-family: "Wingdings", sans-serif; i just get a generic sans-serif display. Why won't BIRT display these particular fonts?

In summary, it looks like my 1st problem was caused by the failure of BIRT to override a Style set in the Library. I can fix that but, per #3 above, I still can't set a font style to the Master Page and have it apply to elements on the Layout Page.

I have attached a very simple CSS file and report that show that the Master Page font style is not applied to the text element on the Layout page.

There must be some way to make this work. Can you help me with this more specific problem?

Thanks for your help!

  • Attachment: TestCSS.zip
    (Size: 1.24KB, Downloaded 120 times)

[Updated on: Thu, 26 March 2015 21:08]

Report message to a moderator

Re: Can't set a font typeface for the Body of a report [message #1690902 is a reply to message #1690362] Tue, 31 March 2015 20:20 Go to previous messageGo to next message
Jesse Freeman is currently offline Jesse FreemanFriend
Messages: 184
Registered: January 2015
Senior Member
1. I would recommend filing an enhancement request to ask for this to be added in a future release.

2. I believe styling from a library is going to take precedence. I will try and verify this to be sure.

3. I believe this is because the font is being set at a lower level (the text element itself) which is being inherited. I think this value being set on the element itself is overriding the higher level CSS setting you are applying to the body. I think background color is giving a different behavior because it is not set on the lower level elements. In the example you attached, background color is not set on the text element and is not inherited. Therefore, I believe this is why your setting is cascading down properly.

4. In the Library Outline, the styles should be nested inside of their parent theme. When you create a new style in a library you select which theme for the style to be appart of which is where the style should show up in the outline.

5. What is the font in the General properties showing up as? When I set the font family to "Wingdings", sans-serif I am seeing the wing-dings show up properly in the web viewer.
Re: Can't set a font typeface for the Body of a report [message #1690911 is a reply to message #1690902] Tue, 31 March 2015 21:17 Go to previous messageGo to next message
Al Koch is currently offline Al KochFriend
Messages: 62
Registered: August 2011
Member
Hi Jesse,

Thanks for the detailed reply. A couple of follow on items:

#3) If that is how the CSS is currently working, what would you recommend I do? All I am trying to accomplish is to set a "global" font preference list that will be automatically applied to all text in all elements. I assume (I haven;t tested) that if I only wanted to specify a single font I could just change the font in the default report style but as I mentioned above, it's important to specify a preference list because we can't necessarily depend on a particular font to be available. So, is there any easy way to get a font list defined for all text?

#5) You said to look at the General tab but I don't have any font controls on the General tab for either the Layout or Master page (perhaps because I deleted the report style?). However the Master page Advanced tab does show the font preference list. However, Wingdings is still not being used! I've attached two screenshots to show that Wingdings is being ignored and it drops down to the next in the list which is Comic Sans.

As always, thanks for your help.
Re: Can't set a font typeface for the Body of a report [message #1691041 is a reply to message #1690911] Wed, 01 April 2015 19:33 Go to previous messageGo to next message
Jesse Freeman is currently offline Jesse FreemanFriend
Messages: 184
Registered: January 2015
Senior Member
3. Looking through the DOM tree in the web viewer, it looks like the elements in the report are inheriting the font properties from the class defined for the container div "__BIRT_ROOT". In my environment this class is "style_0". You may be able to override this by defining your preferences for this class in your CSS as this looks to be where the elements are inheriting their font properties.

5. I was referring to on the elements themselves, such as the table or text element. I just created a style for a table with the font set as "webdings", sans-serif and it is displaying the webdings font properly in my browser when I run the report.
Re: Can't set a font typeface for the Body of a report [message #1691180 is a reply to message #1691041] Thu, 02 April 2015 21:18 Go to previous messageGo to next message
Al Koch is currently offline Al KochFriend
Messages: 62
Registered: August 2011
Member
Hi Jesse,

Thanks for the reply.

#3) I looked in the DOM also and I see what you saw. I changed my CSS to look like:
body .style_0 {
	background: yellow;
	font-family: Impact, Charcoal, sans-serif;
	color: red;
	}

I also tried just ".style_0 {" but in both cases, in the Outline tab under the Styles folder under the name of the CSS file (and after a "Reload CSS File) the CSS file's original .report-body disappears (which it should) but nothing replaces it! It's acting like ".style_0" is "reserved" and it refuses to show it or act on it. Do you have any idea why ".style_0" cannot be used in a CSS file?

#5) OK, this was my fault and I apologize. I am using Firefox but didn't realize that it does not support Webdings/Wingdings! Just my luck that I chose those as a font for testing to be able to easily see if the font was being applied!

So, #5 is resolved but I am still in need of a solution to #3.

Just so there is no confusion, all I want to do in BIRT is accomplish what
body { font-family: Impact, Charcoal, sans-serif; } 

does in standard HTML/CSS - I just want to specify a font preference list to be cascaded down to all text elements. Without this a BIRT user has to manually apply a font list to every text element. This is such a common requirement that there must be a way to do this in software that is as mature as BIRT. Any ideas?

As always, thank you for your help.

[Updated on: Thu, 02 April 2015 21:20]

Report message to a moderator

Re: Can't set a font typeface for the Body of a report [message #1694521 is a reply to message #1691180] Tue, 05 May 2015 22:36 Go to previous messageGo to next message
Al Koch is currently offline Al KochFriend
Messages: 62
Registered: August 2011
Member
bump
Re: Can't set a font typeface for the Body of a report [message #1694648 is a reply to message #1694521] Wed, 06 May 2015 19:31 Go to previous messageGo to next message
Jesse Freeman is currently offline Jesse FreemanFriend
Messages: 184
Registered: January 2015
Senior Member
Sorry for the delay in getting back to you on this one.
I'll take a closer look and let you know what I can find.
Re: Can't set a font typeface for the Body of a report [message #1695423 is a reply to message #1694648] Thu, 14 May 2015 13:22 Go to previous messageGo to next message
Al Koch is currently offline Al KochFriend
Messages: 62
Registered: August 2011
Member
Hi Jesse,

Have you made any progress on this? I'd very much appreciate your help.

Thanks,
Al
Re: Can't set a font typeface for the Body of a report [message #1695435 is a reply to message #1695423] Thu, 14 May 2015 16:04 Go to previous messageGo to next message
Jesse Freeman is currently offline Jesse FreemanFriend
Messages: 184
Registered: January 2015
Senior Member
I'm very sorry about the delay.

Going over this one from the beginning, I looks like we may have been going down a rabbit hole that was unnecessary based on your original requirements.
From your original post you indicated:
Quote:
Actually, I want to specify a selection list of typefaces but the Designer's Edit facility that allows changes to the default report style only allows selection of a particular typeface and not a list.


For a quick sanity check I went back and tested this out. The list box for selection of a font for the default report style does not allow multiselection. However, it does act like a combo box allowing you to also manually enter your font and will accept a font family list.

index.php/fa/21810/0/

I have also attached a simple sample report I have built with this configuration and all elements in the report with text get this font family applied.

Hopefully this will be able to square away your original issue/requirement for this issue.

[Updated on: Thu, 14 May 2015 16:05]

Report message to a moderator

Re: Can't set a font typeface for the Body of a report [message #1695757 is a reply to message #1695435] Tue, 19 May 2015 02:41 Go to previous message
Al Koch is currently offline Al KochFriend
Messages: 62
Registered: August 2011
Member
Hi Jesse,

The solution is a real surprise, but you found it!

I thought back about why I hadn't tried that and I think I know why. If you select an element such as a text item on a page, the font on the Properties tab shows the item's font in the Edit part of the drop down list. If you click in the Edit part in this list you cannot enter anything into the Edit. You can only select from the list. When I saw the same control in the Edit report's font list I must have just subconsciously thought it had the same behavior and never tried to type something here. I'm glad you didn't get fooled - do you have any idea why BIRT would allow edit in one and not the other?

Here is something I've discovered that might help someone else reading this - I am using the following as the font selection list because these fonts are easy to spot so you can see what's going on:

"Wingdings", "Script", "Comic Sans MS", sans-serif

The Designer is inconsistent in how it displays fonts on the Layout and Master pages. If an element has a specific single font defined, the Designer displays the font. But if a selection list is defined if fails to display any of the specified fonts. This behavior misled me for a long time until I discovered I had to do ignore what the Designer displayed and go to the browser to see the results.

Thanks for spending so much time on this and staying with it till it was resolved! I really appreciate your help. Now I'm off to go build a bunch of reports using a font selection list!
Previous Topic:Operation between two row
Next Topic:Enabling emitter for Birt not working
Goto Forum:
  


Current Time: Wed Apr 24 16:51:18 GMT 2024

Powered by FUDForum. Page generated in 0.03497 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top