Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Add a Font Path to Birt via API
Dude
Hi there
I am trying to add an own Font Path to my Birt enviroment. I would like to do this at run time.
I am using Birt 3.7.1.
Is this possible ?
Thanks Dude
Find more posts tagged with
Comments
CBR
Do you want to add the font path at startup only or do you need to reset the path after a few report have been generated?
Dude
I would like to do it dynamicly so that i can change it after some reports.
Is there an option to do this.
If not I would go to do it at the startup.
So both possibilities are interessting for me!
Thanks
Dude
CBR
Hi Dude,<br />
<br />
i think that you have 2 different options:<br />
<br />
1) In 3.7.1 you should be able to set a environment variable called birt.font.dirs this variable should contain all directories where the font files are located in. It is possible to give multiple directories by separating them by File.pathSeparator( On UNIX systems, this character is ':';<br />
on Microsoft Windows systems it is ';'. )<br />
I think that this only works if the variable is set during BIRT startup, but i m not sure.<br />
<br />
2) The second option is to use the java FontManager. The FontManager can be used to register font files to be used in java. You can use the following code to register a new directory that contain font files using code below. Please keep in mind that registering a additional directory only works if it is not blocked by the java security manager (some appServer can be configured to run in save mode using very restrict setting for the security manager...you will get a exception if the security manager doesn't allow registering an additional font dir).<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
private void registerJavaFonts( )
{
AccessController.doPrivileged( new PrivilegedAction<Object>( ) {
public Object run( )
{
//register default fonts first
String javaHome = System.getProperty( "java.home" );
String fontsFolder = javaHome + File.separatorChar + "lib"
+ File.separatorChar + "fonts";
FontFactory.registerDirectory( fontsFolder );
// after that register all custom font dirs
String customFontsDir = "c:/myfonts";
FontFactory.registerDirectory(customFontsDir);
return null;
}
} );
}
</pre>
<br />
I was not able to try out...can you please let me know if it worked for you?<br />
<br />
Christian
Dude
Servus cbrell
Your solotion with the Java Fontmanager wokrs just fine Thanks a lot!!
Just fyi
To do it in a static way there is another option too:
In Birt 3.7.1 you can use the EngineConfig to add Font Config. This class contains a method called setFontConfig( URL u )
The Url links to your own fontConfig.xml in which you can edit all of your font properties.
Anyway thanks for your help !
Greetings from germany ;-)
Dude