Re: Trying to programmatically add fonts

2008-10-06 Thread Frederic W

Hi,
fopFactory.setUserConfig(new File(userConfigPath));
works for me !!!

To generate a FOP font metrics file (.xml) and create a UserConfigFile, I
have done what's explained here:
http://www.sagehill.net/docbookxsl/AddFont.html
http://xmlgraphics.apache.org/fop/0.94/fonts.html

I use FOP 0.95beta1
but setUserConfig works only after I have excluded the default dependency
and add one manually.
That's from my pom.xml file : 

dependency
groupIdorg.apache.xmlgraphics/groupId
artifactIdfop/artifactId
version0.95beta-1/version
exclusions
exclusion
groupIdorg.apache.avalon.framework/groupId
artifactIdavalon-framework-api/artifactId
/exclusion
/exclusions
/dependency
dependency
groupIdavalon/groupId
artifactIdavalon-framework/artifactId
version4.1.4/version
/dependency





eborisow wrote:
 
 
 Alias John Brown wrote:
 
 
 According to the documentation at 
 http://xmlgraphics.apache.org/fop/0.95/fonts.html#basics
 
 It is currently not possible to easily configure fonts from Java code.
 
 I assume that this means that it is not impossible, but I have no idea
 how. Hopefully an expert will turn up soon.
 
 
 
 John,
 
 Thanks for the reply.  I have also tried specifying the config file using
 the method in the docs.  Here is what I tried:
 
 DefaultConfigurationBuilder cfgBuilder = new
 DefaultConfigurationBuilder();
 Configuration cfg = cfgBuilder.buildFromFile(new File(baseDir,
 Local\\personal\\durkan\\projects\\fop\\new-font.conf.xml));
 fopFactory.setUserConfig(cfg);
 
 This gives me the same result.  The fonts are not available.  So, I am
 probably doing something wrong.
 
 Thanks,
 Eric
 

-- 
View this message in context: 
http://www.nabble.com/Trying-to-programmatically-add-fonts-tp19334713p19840816.html
Sent from the FOP - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Trying to programmatically add fonts

2008-09-12 Thread Laurent Morel

eborisow a écrit :

Alias John Brown wrote:
  
According to the documentation at 
http://xmlgraphics.apache.org/fop/0.95/fonts.html#basics


It is currently not possible to easily configure fonts from Java code.

I assume that this means that it is not impossible, but I have no idea
how. Hopefully an expert will turn up soon.





John,

Thanks for the reply.  I have also tried specifying the config file using
the method in the docs.  Here is what I tried:

DefaultConfigurationBuilder cfgBuilder = new
DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(new File(baseDir,
Local\\personal\\durkan\\projects\\fop\\new-font.conf.xml));
fopFactory.setUserConfig(cfg);

This gives me the same result.  The fonts are not available.  So, I am
probably doing something wrong.

Thanks,
Eric
  

So did you manage to specify fonts programmatically ?
I am very interested in this feature because I'd like to embed the fonts 
required

by my software in the jar file.

AFAIK, this is currently not possible directly, because even if I embed the
configuration file and read it with cfgBuilder.build(InputStream), this file
still refers to a font file name that does not exist in the disk files 
hierarchy.
I'd had to copy the fonts files somewhere in a temp dir, then use 
setFontBaseURL()
to specify this dir : I don't like that approach. File copy shouldn't be 
required.


BTW, I want to embed one single OS installed font. Currently I use
fonts  auto-detect/  /fonts which works fine, but scans the whole
system fonts directory and that takes time (and probably memory).
Is the only other way to generate a font metric as described here
http://xmlgraphics.apache.org/fop/0.95/fonts.html#register ?

It would be nice if we could refer to a single font file by its name, 
and fop

would generate the font metric at execution time.
Well I could copy the font in a temp dir and still use auto-detect,
but I'd like to avoid this copy.

Thanks,

  Laurent Morel



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Trying to programmatically add fonts

2008-09-05 Thread eborisow

Hi,

I am trying to embed fonts in a program.  I was able to get my fonts to work
when I run fop.bat standalone.  Here were the relevant lines from the config
xml.

font-basefile:///C:/programs/apache/fop-0.94-bin-jdk1.3/fonts//font-base

!-- not sure if font tags will display on web site --
fonts

  font-triplet name=Verdana style=normal weight=normal/


  font-triplet name=Verdana style=normal weight=bold/


  font-triplet name=Verdana style=italic weight=bold/

/fonts

Like I said, this one works.  Now, in an application, I am trying to do the
same using the API.


// Set the Font Base URL
   
fopFactory.setFontBaseURL(file:///C:/programs/apache/fop-0.94-bin-jdk1.3/fonts/);

String font1 = verdana.xml;
String font1Url = verdana.ttf;

String font2 = verdanab.xml;
String font2Url = verdanab.ttf;

String font3 = verdanaz.xml;
String font3Url = verdanaz.ttf;

FontTriplet fontTriplet1 = new FontTriplet(Verdana,
Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
FontTriplet fontTriplet2 = new FontTriplet(Verdana,
Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
FontTriplet fontTriplet3 = new FontTriplet(Verdana,
Font.STYLE_ITALIC, Font.WEIGHT_BOLD);

List fontTriplets1 = new ArrayList();
fontTriplets1.add(fontTriplet1);

List fontTriplets2 = new ArrayList();
fontTriplets2.add(fontTriplet2);

List fontTriplets3 = new ArrayList();
fontTriplets3.add(fontTriplet3);

EmbedFontInfo verdanaFontInfo = new EmbedFontInfo(font1, true,
fontTriplets1, font1Url);
EmbedFontInfo verdanaBoldFontInfo = new EmbedFontInfo(font2,
true, fontTriplets2, font2Url);
EmbedFontInfo verdanaBoldItalicFontInfo = new
EmbedFontInfo(font3, true, fontTriplets3, font3Url);
FontCache fontCache = fopFactory.getFontCache();
fontCache.addFont(verdanaFontInfo);
fontCache.addFont(verdanaBoldFontInfo);
fontCache.addFont(verdanaBoldItalicFontInfo);
fontCache.save();

I test the cache using the following:

log.debug(Contains verdana font:  +
fontCache.containsFont(verdanaFontInfo));
log.debug(Verdana font info is:  +
fontCache.getFont(verdana.ttf).toString());

log.debug(Contains verdana-bold font:  +
fontCache.containsFont(verdanaBoldFontInfo));
log.debug(Verdana-bold font info is:  +
fontCache.getFont(verdanab.ttf).toString());

log.debug(Contains verdana-bold-italic font:  +
fontCache.containsFont(verdanaBoldItalicFontInfo));
log.debug(Verdana-bold-italic font info is:  +
fontCache.getFont(verdanaz.ttf).toString());

In the log, I get the following:

2008-09-05 12:05:12,014 [main] DEBUG
embedding.ExampleXML2PDF(ExampleXML2PDF.java:153)  - Contains verdana font:
true
2008-09-05 12:05:12,014 [main] DEBUG
embedding.ExampleXML2PDF(ExampleXML2PDF.java:154)  - Verdana font info is:
metrics-url=verdana.xml,embed-url=verdana.ttf, kerning=true,
font-triplet=[Verdana,normal,400], lastModified=-1
2008-09-05 12:05:12,014 [main] DEBUG
embedding.ExampleXML2PDF(ExampleXML2PDF.java:156)  - Contains verdana-bold
font: true
2008-09-05 12:05:12,014 [main] DEBUG
embedding.ExampleXML2PDF(ExampleXML2PDF.java:157)  - Verdana-bold font info
is: metrics-url=verdanab.xml,embed-url=verdanab.ttf, kerning=true,
font-triplet=[Verdana,normal,700], lastModified=-1
2008-09-05 12:05:12,014 [main] DEBUG
embedding.ExampleXML2PDF(ExampleXML2PDF.java:159)  - Contains
verdana-bold-italic font: true
2008-09-05 12:05:12,014 [main] DEBUG
embedding.ExampleXML2PDF(ExampleXML2PDF.java:160)  - Verdana-bold-italic
font info is: metrics-url=verdanaz.xml,embed-url=verdanaz.ttf, kerning=true,
font-triplet=[Verdana,italic,700], lastModified=-1

However, when it actually tries to convert the XML to PDF, I see the
following message in the log:

2008-09-05 12:05:26,905 [main] DEBUG
org.apache.fop.fonts.FontInfo(FontInfo.java:134)  - Font lookup: Verdana
normal 400
2008-09-05 12:05:26,905 [main] WARN 
org.apache.fop.fonts.FontInfo(FontInfo.java:263)  - Font
'Verdana,normal,400' not found. Substituting with 'any,normal,400'.

So, I am obviously doing something wrong.  Can someone see what the problem
is?

Thanks,
Eric
-- 
View this message in context: 
http://www.nabble.com/Trying-to-programmatically-add-fonts-tp19334713p19334713.html
Sent from the FOP - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Trying to programmatically add fonts

2008-09-05 Thread John Brown
eborisow eborisow at yahoo.com writes:

 
 
 Hi,
 
 I am trying to embed fonts in a program.  I was able to get my fonts to work
 when I run fop.bat standalone.  Here were the relevant lines from the config
 xml.
 

snip
Contents of config file
/snip
 
 Like I said, this one works.  Now, in an application, I am trying to do the
 same using the API.
 
snip
Code to do above programatically
/snip

snip
Contents of log
/snip 

 So, I am obviously doing something wrong.  Can someone see what the problem
 is?

According to the documentation at 
http://xmlgraphics.apache.org/fop/0.95/fonts.html#basics

It is currently not possible to easily configure fonts from Java code.

I assume that this means that it is not impossible, but I have no idea
how. Hopefully an expert will turn up soon.

 
 Thanks,
 Eric





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Trying to programmatically add fonts

2008-09-05 Thread eborisow


Alias John Brown wrote:
 
 
 According to the documentation at 
 http://xmlgraphics.apache.org/fop/0.95/fonts.html#basics
 
 It is currently not possible to easily configure fonts from Java code.
 
 I assume that this means that it is not impossible, but I have no idea
 how. Hopefully an expert will turn up soon.
 
 

John,

Thanks for the reply.  I have also tried specifying the config file using
the method in the docs.  Here is what I tried:

DefaultConfigurationBuilder cfgBuilder = new
DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(new File(baseDir,
Local\\personal\\durkan\\projects\\fop\\new-font.conf.xml));
fopFactory.setUserConfig(cfg);

This gives me the same result.  The fonts are not available.  So, I am
probably doing something wrong.

Thanks,
Eric
-- 
View this message in context: 
http://www.nabble.com/Trying-to-programmatically-add-fonts-tp19334713p19342339.html
Sent from the FOP - Users mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]