How to use external font families in BIRT Reports?
<p>Hi,</p>
<p> I'm using BIRT version 4.5.0. I want to use some specific font families (more specifically 'Open Sans') in reports. In the mentioned version of BIRT is supported few font families only and also I'm not able to add external font families by API and also by design. Is any APIs or JAR files available to handle external font families? Also kindly expecting the procedure (code) to handle that font families. Thanks in advance..</p>
<p> I'm using BIRT version 4.5.0. I want to use some specific font families (more specifically 'Open Sans') in reports. In the mentioned version of BIRT is supported few font families only and also I'm not able to add external font families by API and also by design. Is any APIs or JAR files available to handle external font families? Also kindly expecting the procedure (code) to handle that font families. Thanks in advance..</p>
0
Comments
-
<p>It's not true that BIRT doesn't support additional font families.</p>
<p> </p>
<p>To include web fonts... When designing, you should download the .OTF, install and use that so that you can select the Font in the drop down. Otherwise, you'll need to manually update the XML Source to point to the web font you want to use.</p>
<p> </p>
<p>Then, for deploying, you can modify FramesetFragment.jsp (found under ...\birtwebcontent\birt\pages\layout) to include the Open Sans CSS:</p>
<pre class="_prettyXprint _lang-nocode">
...
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=utf-8">
<LINK REL="stylesheet" HREF="birt/styles/style.css" TYPE="text/css">
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans" />
<%
if( attributeBean.isRtl() )
{
%>
<LINK REL="stylesheet" HREF="birt/styles/dialogbase_rtl.css" MEDIA="screen" TYPE="text/css"/>
<%
...
</pre>
<p>For commercial BIRT, you can also modify a common .CSS such as webfonts.css to include the web font definition, or add the link to the CSS in a common JSP file. Another method is outlined here in this blog using head.js @ <a data-ipb='nomediaparse' href='https://blogs.opentext.com/extend-birt-with-font-symbols-code/'>https://blogs.opentext.com/extend-birt-with-font-symbols-code/</a></p>
<p> </p>
<p> </p>
<p>The attached design was testing in open source BIRT 4.5.0, deployed to Tomcat 8. Here's a screenshot of the output of the report:</p>
<p>Warning No formatter is installed for the format ipb0 -
<p>BIRT support External font families by using following API</p>
<pre class="_prettyXprint _linenums:0">
ReportDesignHandle designHandle = session.createDesign();
IncludedCssStyleSheet sheet = StructureFactory.createIncludedCssStyleSheet();
sheet.setExternalCssURI("https://fonts.googleapis.com/css?family=Open+Sans");
sheet.setUseExternalCss(true);
designHandle.addCss(sheet);
StyleHandle newStyle = designHandle.getElementFactory().newStyle("group-header");
newStyle.setProperty(StyleHandle.FONT_FAMILY_PROP, "Open Sans");
newStyle.setProperty(StyleHandle.COLOR_PROP, "#676767");
designHandle.getStyles().add(newStyle);
</pre>
<p>It's working fine for me</p>0
Categories
- All Categories
- 122 Developer Announcements
- 53 Articles
- 151 General Questions
- 147 Thrust Services
- 56 OpenText Hackathon
- 35 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 917 Cloud Fax and Notifications
- 84 Digital Asset Management
- 9.4K Documentum
- 31 eDOCS
- 181 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 8 XM Fax
- Follow Categories