You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Arian <ar...@gmail.com> on 2010/03/09 20:09:03 UTC

how to embed fonts via java, using fop trunk

I saw the page http://xmlgraphics.apache.org/fop/0.94/embedding.html#config-internal
which recommends:
fopFactory.setFontBaseURL("file:///C:/Temp/fonts");
or via config file which would have fonts folder specified:
fopFactory.setUserConfig(new File("C:/Temp/mycfg.xml"));

but I think my coworker is saying eclipse says it is depreciated in
the fop trunk version, so thought I'd ask here.
So whats the new way to do it, and also is there a way to do it
without full filepaths on filesystem (with relative url's)?

Thanks!,
Ari

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: how to embed fonts via java, using fop trunk

Posted by Arian <ar...@gmail.com>.
Reopening this thread... curious if anyone could help...

I've made a simple java app (using FOP Trunk), and I point to a relative
location where my .xml config file is...
So in c:/dev/eclipse-workspace/pdf_project_test/, i have:

config/
xml_xsl_files/            (where i load the xml and xsl files to form the
fo)
xml_xsl_files/images/ (for the xsl files images)
fonts/                        (for the ttf fonts the .fo file refers to)
images/                    (i had to copy the images folder here, more info
on this later)
[
src/
bin/                          (Eclipse .java/.class files for the project)
]


Example:

fopFactory.setUserConfig("config/user_config.xml"); //config file in the
c:/dev/eclipse-workspace/pdf_project_test/config folder

This works, however i point to abs dir that xml...
I changed the xml to point relatively in the folder via:
   <font-base>.</font-base> <!-- not needed it seems, but added it -->
    ....<renderers>....
            <fonts>....
                <directory recursive="true">fonts</directory> <!-- points
relatively now, was set to c:/dev/eclipse-workspace/pdf_project_test/fonts
before -->
...
This now works ... But I dont want to use a .xml config file. I just want to
point to the fonts folder, (but I couldnt get that to work, hence why I went
the config file route above)?
Ive tried this relative path to no avail:

        FOUserAgent userAgent = fopFactory.newFOUserAgent();
             //
userAgent.setBaseURL("file:///c:/dev/eclipse-workspace/pdf_project_test/");
//? not sure if explicitly needed since .java is in that dir, but i tried
all combos i thought might be needed
        fopFactory.getFontManager().setFontBaseURL( "./fonts/" );

I've even tried abs paths like: fopFactory.getFontManager().setFontBaseURL(
"c:/dev/eclipse-workspace/pdf_project_test/fonts/" );
and various combos in there like
"file:///c:/dev/eclipse-workspace/pdf_project_test/fonts/". Again didnt
work.
What kind of file uri's will resolve (just testing on windows for now) and
what is it relative too, the xsl file or the .java file?

A 2nd related question: I figured the .xsl file, which lies in
xml_xsl_files/... i got errors about the image locations, so the image
filepaths werent looking relative to the .xsl file but to the eclipse
projects location. So I had to move images/ out of xsl/ and into
pdf_project_test/. Not sure if this also is best solution, or can feed an
arg to make the xsl look in its own directory.

Thanks for any help on file paths,
PS I did read a few threads I saw but none worked for the setFontBaseURL
(one guy claimed the abs filepaths worked, and i used the same filepath
string structure he used (with "file:///c:/to/my/fonts/") but didnt work),
Lates... I can attach code later if needed as its only 75 lines long,
Arian

Re: how to embed fonts via java, using fop trunk

Posted by Arian <ar...@gmail.com>.
Thanks Pascal!
I'll check it out.

On Wed, Mar 10, 2010 at 8:16 AM, Pascal Sancho <pa...@takoma.fr> wrote:
> Hi Arian,
>
> reading the source code, fopFactory.setFontBaseURL() is actually
> deprecated, and should be replaced in FOP TRUNK with:
> fopFactory.getFontManager().setFontBaseURL().
> Note that the font subsystem has been widely rewritten since FOP 0.94.
>
> Pascal

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: how to embed fonts via java, using fop trunk

Posted by Pascal Sancho <pa...@takoma.fr>.
Hi Arian,

reading the source code, fopFactory.setFontBaseURL() is actually
deprecated, and should be replaced in FOP TRUNK with:
fopFactory.getFontManager().setFontBaseURL().
Note that the font subsystem has been widely rewritten since FOP 0.94.

Pascal


Arian a écrit :
> I saw the page http://xmlgraphics.apache.org/fop/0.94/embedding.html#config-internal
> which recommends:
> fopFactory.setFontBaseURL("file:///C:/Temp/fonts");
> or via config file which would have fonts folder specified:
> fopFactory.setUserConfig(new File("C:/Temp/mycfg.xml"));
>
> but I think my coworker is saying eclipse says it is depreciated in
> the fop trunk version, so thought I'd ask here.
> So whats the new way to do it, and also is there a way to do it
> without full filepaths on filesystem (with relative url's)?
>
> Thanks!,
> Ari
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: how to embed fonts via java, using fop trunk

Posted by Red Light <sk...@yahoo.com>.
Hi Adrian,

i'm using 0.95  and i set up the font path in the servlet:


then i reference my font in my conf file:

*********************************************************************************
<font metrics-url="arial.xml" kerning="yes" embed-url="ARIAL.TTF">
          <font-triplet name="Arial" style="normal" weight="normal"/>        
        </font>
*********************************************************************************

where arial.xml and ARIAL.TTF are in placed in the repertory that i passed to the servlet;

may be i'm mistaken but yu need to ensure that yu have:

 <!-- Base URL for resolving relative URLs -->
  <base>.</base>

in your conf file.



and good luck