Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 347431 - Add alternative way of injecting Font-Directory without having to modify files in the plugin folder
Summary: Add alternative way of injecting Font-Directory without having to modify file...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: BIRT (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.7.2   Edit
Assignee: Yu Chen CLA
QA Contact: Xiaoying Gu CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-27 07:13 EDT by Jens Kleemann CLA
Modified: 2012-10-12 06:47 EDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jens Kleemann CLA 2011-05-27 07:13:01 EDT
Build Identifier: 2.6.2

Currently adding fonts from a custom directory is a nuisance since you have to modify the config-xml in the fonts plugin or put those fonts into the jre/lib/fonts directory. 
A simple SystemProperty which would accept a commaseparated list of custom font directories would be a big plus.

Reproducible: Always
Comment 1 Jens Kleemann CLA 2011-05-27 12:40:52 EDT
I helped myself with a SystemProperty which is used to inject one custom directory in the FontMappingManagerFactory.java

That way i do not need to edit a file inside the plugin directory.

-------------------------------------

	private void registerJavaFonts( )
	{
		AccessController.doPrivileged( new PrivilegedAction<Object>( ) {

			public Object run( )
			{
				String javaHome = System.getProperty( "java.home" );
				String fontsFolder = javaHome + File.separatorChar + "lib"
						+ File.separatorChar + "fonts";
				FontFactory.registerDirectory( fontsFolder );
			
				// Register custom font directory
				String customFontsDir = System.getProperty("birt.customfontsdir");
				if(customFontsDir != null){
					FontFactory.registerDirectory(customFontsDir);
				}
				return null;
			}
		} );
	}

---------------------
Comment 2 Yu Chen CLA 2011-06-01 04:44:21 EDT
Birt loads fonts automatically from the default system font folder. You can find the font paths in <font-paths> section of fontsConfig.xml, and simply copy the font files into the system font folder to avoid any configurations.

However, adding custom font directories from System property is a good alternative way. Now you can use "birt.font.dirs" as the key. It will accept a list separated by File.pathSeparator( On UNIX systems, this character is ':'; on Microsoft Windows systems it is ';'. ) Each path in the list can be a font directory or a single font file.

Fixed.
Comment 3 Xiaoying Gu CLA 2011-06-10 03:15:24 EDT
reopen
Comment 4 Yu Chen CLA 2011-10-07 23:19:38 EDT
Now Engine uses EngineConfig.setFontConfig(URL) to specify a user defined font config file path.
Comment 5 Jason Weathersby CLA 2012-07-02 18:06:12 EDT
Is this system property working?
birt.font.dirs

It does not appear in the code.
Comment 6 Taras Kopets CLA 2012-07-09 07:23:20 EDT
Is it possible to set some configuration option of fontsConfig*.xml files location?

Currently users of BIRT have to repackage jar file to edit fontConfig, which also means removal of jar signature.
Comment 7 Yu Chen CLA 2012-08-22 13:53:18 EDT
The font configuration plugin(org.eclipse.birt.report.engine.fonts_*) is already a folder now. The end user need not repackage the jar file.
Comment 8 Taras Kopets CLA 2012-08-22 14:18:24 EDT
I've just downloaded BIRT runtime and was hoping to see a separate folder for fonts config and was disappointed - there is no such folder.

Currently we have to repackage this jar file:
birt-runtime*\WebViewerExample\WEB-INF\lib\org.eclipse.birt.runtime*.jar
in order to change the fonts configuration.

It would be great if there is an easy way to do this.

I'd say this bug is still open if there is no such easy way to specify fonts.
I'd also consider this bug as severe as out of the box (default configuration) of BIRT does not produce correct cyrillic PDFs (all the letters are missing)!
Comment 9 Xiaoying Gu CLA 2012-08-23 04:07:37 EDT
(In reply to comment #8)
> I've just downloaded BIRT runtime and was hoping to see a separate folder
> for fonts config and was disappointed - there is no such folder.
> 
> Currently we have to repackage this jar file:
> birt-runtime*\WebViewerExample\WEB-INF\lib\org.eclipse.birt.runtime*.jar
> in order to change the fonts configuration.
> 
> It would be great if there is an easy way to do this.
> 
> I'd say this bug is still open if there is no such easy way to specify fonts.
> I'd also consider this bug as severe as out of the box (default
> configuration) of BIRT does not produce correct cyrillic PDFs (all the
> letters are missing)!

Can you use the osgi-runtime which is also provided on the download site?
The font config plugin is shipped as dir in the plugins/ folder.
Comment 10 Taras Kopets CLA 2012-08-23 05:19:08 EDT
Thank you very much! That's exactly what I was looking for!
Comment 11 Yu Chen CLA 2012-08-23 05:27:50 EDT
(In reply to comment #5)
> Is this system property working?
> birt.font.dirs
> 
> It does not appear in the code.

"birt.font.dirs" is removed since we uses EngineConfig.setFontConfig(URL) to specify a user defined font config file path now.
Comment 12 Jason Weathersby CLA 2012-08-23 10:53:13 EDT
Are there plans to add the fonts directory to the POJO runtime?
Comment 13 Misel Mesnjak CLA 2012-10-12 04:14:51 EDT
(In reply to comment #9)
> (In reply to comment #8)
> > I've just downloaded BIRT runtime and was hoping to see a separate folder
> > for fonts config and was disappointed - there is no such folder.
> > 
> > Currently we have to repackage this jar file:
> > birt-runtime*\WebViewerExample\WEB-INF\lib\org.eclipse.birt.runtime*.jar
> > in order to change the fonts configuration.
> > 
> > It would be great if there is an easy way to do this.
> > 
> > I'd say this bug is still open if there is no such easy way to specify fonts.
> > I'd also consider this bug as severe as out of the box (default
> > configuration) of BIRT does not produce correct cyrillic PDFs (all the
> > letters are missing)!
> 
> Can you use the osgi-runtime which is also provided on the download site?
> The font config plugin is shipped as dir in the plugins/ folder.
Hi!

I'm also having issues with PDF export of reports. Fonts used in PDF are wrong. Googling I stumbled onto this page and after reading comments I deployed birt.war from osgi-runtime onto my tomcat installation and then added a new path in fontsConfig_pdf.xml on this path:
/opt/tomcat/webapps/birt/WEB-INF/platform/plugins/org.eclipse.birt.report.engine.fonts_4.2.1.v20120820/
then I restarted the Tomcat and... still no go :(

Can You point me to the right direction please?
BTW, Tomcat is running on Centos 5.5.
Comment 14 Taras Kopets CLA 2012-10-12 05:30:06 EDT
Hi Misel!

I solved the problems with pdf fonts this way:
1. renamed (removed) fontsConfig_pdf.xml
2. edited fontsConfig_linux.xml so it points to some real font, like this:
<?xml version="1.0" encoding="UTF-8"?>
<font>
	<font-aliases>
		<mapping name="serif" font-family="Bitstream Vera Serif" />
		<mapping name="sans-serif" font-family="Bitstream Vera Sans" />
		<mapping name="monospace" font-family="Bitstream Vera Sans Mono" />
		<mapping name="cursive" font-family="Bitstream Vera Sans Mono" />
		<mapping name="fantasy" font-family="Bitstream Vera Sans Mono" />
	</font-aliases>
	<composite-font name="all-fonts" default="Bitstream Vera Sans Mono">
		<font font-family="Bitstream Vera Sans Mono" catalog="Western" />
		<font font-family="ZYSong18030" catalog="Chinese" />
		<font font-family="Baekmuk Batang" catalog="Korean" />
		<font font-family="Kochi Mincho" catalog="Japanese" />
	</composite-font>
</font>
3. make sure the font you listed in fontsConfig_linux.xml is accessible using one of the paths in <font-paths> listing of main fontsConfig.xml, if not, add the dirrectory of this font to the list.
Comment 15 Misel Mesnjak CLA 2012-10-12 06:47:48 EDT
(In reply to comment #14)
> Hi Misel!
> 
> I solved the problems with pdf fonts this way:
> 1. renamed (removed) fontsConfig_pdf.xml
> 2. edited fontsConfig_linux.xml so it points to some real font, like this:
Hi Taras,

I managed to get it to work but the key component was to change the encoding for Arial font family to Cp1250. I found that info here: http://goo.gl/dXT5u
Before I tried with UTF-8 but that didn't work.

Thanks for the help!