Loading ...
Sorry, an error occurred while loading the content.

Re: [XSL-FO] FOP font embed, configuration question

Expand Messages
  • Chris Bowditch
    Mark Ivs wrote: ... What you need is the font base dir. Documented here: http://xml.apache.org/fop/configuration.html#summary-key-value So put relative
    Message 1 of 6 , Mar 2, 2004
    • 0 Attachment
      Mark Ivs wrote:

      <snip/>

      > Everything works fine. My question is, about the hard
      > coded path to the "msgothic.ttc" file in the
      > embed-file attribute.
      > I was wondering if there is a generic way to tell fop
      > where to look for the .ttc file. Because users can
      > have their fonts directory anywhere. It can be C drive
      > or D drive or anything right.

      What you need is the font base dir. Documented here:

      http://xml.apache.org/fop/configuration.html#summary-key-value

      So put relative paths in your font metrics definition, e.g. just
      "msgothic.ttc" and then FOP will resolve the path relative to the FOP
      base dir. The FOP base dir doesnt need to be hard coded in the
      userconfig.xml either, you can change it in the code, e.g.

      org.apache.fop.configuration.Configuration.put("baseDir","C:\my\base\dir");

      >
      > Second question:
      > Let's say the font is not installed in a users
      > machine. FOP throws an error saying that it cannot
      > recognize the font. In this case, it looks like it
      > chooses a default font. Is it possible to do that in
      > the xsl or in the java code ? Meaning....look for
      > msgothic font, if you can't find it then use
      > helvettica.

      Well the XSL-FO spec says you can do font-family="msgothic, helvettica,
      sans-serif" and the formatter will behave as you describe, but IIRC,
      then this feature isnt implemented in FOP, but I could be wrong...

      Chris
    • Mark Ivs
      Thanks a lot for your response Chris. I made changes to userconfig.xml
      Message 2 of 6 , Mar 2, 2004
      • 0 Attachment
        Thanks a lot for your response Chris.

        I made changes to userconfig.xml
        <font metrics-file="arialuni.xml"
        embed-file="arialuni.ttf" kerning="yes">
        <font-triplet name="ArialUnicodeMS" style="normal"
        weight="normal"/>
        </font>

        And in the code, I have
        Configuration.put(
        "baseDir","C:/home/foptest");

        Configuration.put(
        "fontBaseDir",
        "C:/home/foptest");

        But I get an error in the console saying "Unknown font
        ArialUnicodeMS". I have arialuni.xml, arialuni.ttf and
        userconfig.xml in the foptest directory.

        I am not sure where I am going wrong. Another thing I
        wasn't sure was, no where in the code I tell fop to
        look for userconfig.xml file. Dose fop automatically
        look for that file in the baseDir ?

        Any help will be appreciated.

        Thanks.
        -M

        --- Chris Bowditch <bowditch_chris@...> wrote:
        > Mark Ivs wrote:
        >
        > <snip/>
        >
        > > Everything works fine. My question is, about the
        > hard
        > > coded path to the "msgothic.ttc" file in the
        > > embed-file attribute.
        > > I was wondering if there is a generic way to tell
        > fop
        > > where to look for the .ttc file. Because users can
        > > have their fonts directory anywhere. It can be C
        > drive
        > > or D drive or anything right.
        >
        > What you need is the font base dir. Documented here:
        >
        >
        http://xml.apache.org/fop/configuration.html#summary-key-value
        >
        > So put relative paths in your font metrics
        > definition, e.g. just
        > "msgothic.ttc" and then FOP will resolve the path
        > relative to the FOP
        > base dir. The FOP base dir doesnt need to be hard
        > coded in the
        > userconfig.xml either, you can change it in the
        > code, e.g.
        >
        >
        org.apache.fop.configuration.Configuration.put("baseDir","C:\my\base\dir");
        >
        > >
        > > Second question:
        > > Let's say the font is not installed in a users
        > > machine. FOP throws an error saying that it cannot
        > > recognize the font. In this case, it looks like it
        > > chooses a default font. Is it possible to do that
        > in
        > > the xsl or in the java code ? Meaning....look for
        > > msgothic font, if you can't find it then use
        > > helvettica.
        >
        > Well the XSL-FO spec says you can do
        > font-family="msgothic, helvettica,
        > sans-serif" and the formatter will behave as you
        > describe, but IIRC,
        > then this feature isnt implemented in FOP, but I
        > could be wrong...
        >
        > Chris
        >
        >
        >


        __________________________________
        Do you Yahoo!?
        Yahoo! Search - Find what you�re looking for faster
        http://search.yahoo.com
      • Chris Bowditch
        Mark Ivs wrote: ... A couple of possibilities: 1) FOP isnt finding your user config xml file as you suggest below. 2) You have specified
        Message 3 of 6 , Mar 3, 2004
        • 0 Attachment
          Mark Ivs wrote:

          <snip/>

          > But I get an error in the console saying "Unknown font
          > ArialUnicodeMS". I have arialuni.xml, arialuni.ttf and
          > userconfig.xml in the foptest directory.

          A couple of possibilities:
          1) FOP isnt finding your user config xml file as you suggest below.
          2) You have specified font-weight="bold" somewhere in your FO. The Font
          triplet you have defined above is for normal weight glyphs only. Could
          you Copy and paste the precise error message, as it will say whether it
          was looking for bold/italic, etc.

          >
          > I am not sure where I am going wrong. Another thing I
          > wasn't sure was, no where in the code I tell fop to
          > look for userconfig.xml file. Dose fop automatically
          > look for that file in the baseDir ?

          You need to do something like:

          userConfigFile = new File("c:\home\foptest\userconfig.xml");
          options = new Options(userConfigFile);

          I thought I saw you doing this in the code snippet you provided.

          BTW: It is best to ask FOP specific questions on the FOP user list
          rather than the more generic XSL-FO list. Sign up here:

          http://xml.apache.org/fop/maillist.html#fop-user

          <snip/>

          Chris
        • Mark Ivs
          Chirs, Again, thanks for response. Now I see what the problem is. Earlier I was under the assumption that there are two ways to embed font. 1. Using the
          Message 4 of 6 , Mar 3, 2004
          • 0 Attachment
            Chirs,
            Again, thanks for response.
            Now I see what the problem is. Earlier I was under the
            assumption that
            there are two ways to embed font.
            1. Using the options class.
            options = new Options(userConfigFile);
            2. Using Configuration.put

            That's why I was confused. Anyway, now it works fine.
            Since I have arialuni.xml, arialuni.ttf and
            userconfig.xml in the same directory, I didn't even
            have to set the baseDir and fontBaseDir using
            Configuration.put

            I do not have any bold or italic. So I didn't add the
            font triplet for those.

            Yes, I will register at fop mailing list.

            Once again, thanks for your help.

            -M


            --- Chris Bowditch <bowditch_chris@...> wrote:
            > Mark Ivs wrote:
            >
            > <snip/>
            >
            > > But I get an error in the console saying "Unknown
            > font
            > > ArialUnicodeMS". I have arialuni.xml, arialuni.ttf
            > and
            > > userconfig.xml in the foptest directory.
            >
            > A couple of possibilities:
            > 1) FOP isnt finding your user config xml file as you
            > suggest below.
            > 2) You have specified font-weight="bold" somewhere
            > in your FO. The Font
            > triplet you have defined above is for normal weight
            > glyphs only. Could
            > you Copy and paste the precise error message, as it
            > will say whether it
            > was looking for bold/italic, etc.
            >
            > >
            > > I am not sure where I am going wrong. Another
            > thing I
            > > wasn't sure was, no where in the code I tell fop
            > to
            > > look for userconfig.xml file. Dose fop
            > automatically
            > > look for that file in the baseDir ?
            >
            > You need to do something like:
            >
            > userConfigFile = new
            > File("c:\home\foptest\userconfig.xml");
            > options = new Options(userConfigFile);
            >
            > I thought I saw you doing this in the code snippet
            > you provided.
            >
            > BTW: It is best to ask FOP specific questions on the
            > FOP user list
            > rather than the more generic XSL-FO list. Sign up
            > here:
            >
            > http://xml.apache.org/fop/maillist.html#fop-user
            >
            > <snip/>
            >
            > Chris
            >
            >
            >


            __________________________________
            Do you Yahoo!?
            Yahoo! Search - Find what you�re looking for faster
            http://search.yahoo.com
          • Mark Ivs
            I was not fully correct earlier. I do need Configuration.put for fontBaseDir. So basically what I have right now in the code is... userConfigFile = new
            Message 5 of 6 , Mar 3, 2004
            • 0 Attachment
              I was not fully correct earlier.
              I do need Configuration.put for fontBaseDir.

              So basically what I have right now in the code is...
              userConfigFile = new
              File("c:\home\foptest\userconfig.xml");
              options = new Options(userConfigFile);

              Configuration.put("fontBaseDir","c:\home\foptest");

              And my userconfig.xml....
              <font metrics-file="arialuni.xml"
              embed-file="arialuni.ttf" kerning="yes">
              <font-triplet name="ArialUnicodeMS" style="normal"
              weight="normal"/>
              </font>

              I have arialuni.xml, arialuni.ttf and
              userconfig.xml in the foptest directory.

              Things work fine. Thanks !! Hope this helps for
              someone else who might experience similar problems.

              -M


              --- Mark Ivs <markivs2003@...> wrote:
              > Chirs,
              > Again, thanks for response.
              > Now I see what the problem is. Earlier I was under
              > the
              > assumption that
              > there are two ways to embed font.
              > 1. Using the options class.
              > options = new Options(userConfigFile);
              > 2. Using Configuration.put
              >
              > That's why I was confused. Anyway, now it works
              > fine.
              > Since I have arialuni.xml, arialuni.ttf and
              > userconfig.xml in the same directory, I didn't even
              > have to set the baseDir and fontBaseDir using
              > Configuration.put
              >
              > I do not have any bold or italic. So I didn't add
              > the
              > font triplet for those.
              >
              > Yes, I will register at fop mailing list.
              >
              > Once again, thanks for your help.
              >
              > -M
              >
              >
              > --- Chris Bowditch <bowditch_chris@...>
              > wrote:
              > > Mark Ivs wrote:
              > >
              > > <snip/>
              > >
              > > > But I get an error in the console saying
              > "Unknown
              > > font
              > > > ArialUnicodeMS". I have arialuni.xml,
              > arialuni.ttf
              > > and
              > > > userconfig.xml in the foptest directory.
              > >
              > > A couple of possibilities:
              > > 1) FOP isnt finding your user config xml file as
              > you
              > > suggest below.
              > > 2) You have specified font-weight="bold" somewhere
              > > in your FO. The Font
              > > triplet you have defined above is for normal
              > weight
              > > glyphs only. Could
              > > you Copy and paste the precise error message, as
              > it
              > > will say whether it
              > > was looking for bold/italic, etc.
              > >
              > > >
              > > > I am not sure where I am going wrong. Another
              > > thing I
              > > > wasn't sure was, no where in the code I tell fop
              > > to
              > > > look for userconfig.xml file. Dose fop
              > > automatically
              > > > look for that file in the baseDir ?
              > >
              > > You need to do something like:
              > >
              > > userConfigFile = new
              > > File("c:\home\foptest\userconfig.xml");
              > > options = new Options(userConfigFile);
              > >
              > > I thought I saw you doing this in the code snippet
              > > you provided.
              > >
              > > BTW: It is best to ask FOP specific questions on
              > the
              > > FOP user list
              > > rather than the more generic XSL-FO list. Sign up
              > > here:
              > >
              > > http://xml.apache.org/fop/maillist.html#fop-user
              > >
              > > <snip/>
              > >
              > > Chris
              > >
              > >
              > >
              >
              >
              > __________________________________
              > Do you Yahoo!?
              > Yahoo! Search - Find what you�re looking for faster
              > http://search.yahoo.com
              >
              >
              >
              > Yahoo! Groups Links
              >
              >
              > XSL-FO-unsubscribe@yahoogroups.com
              >
              >
              >


              __________________________________
              Do you Yahoo!?
              Yahoo! Search - Find what you�re looking for faster
              http://search.yahoo.com
            Your message has been successfully submitted and would be delivered to recipients shortly.