Return-Path: X-Original-To: apmail-xmlgraphics-commits-archive@www.apache.org Delivered-To: apmail-xmlgraphics-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B8559EB1A for ; Tue, 12 Feb 2013 23:53:52 +0000 (UTC) Received: (qmail 20326 invoked by uid 500); 12 Feb 2013 23:53:52 -0000 Mailing-List: contact commits-help@xmlgraphics.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: general@xmlgraphics.apache.org Delivered-To: mailing list commits@xmlgraphics.apache.org Received: (qmail 20318 invoked by uid 99); 12 Feb 2013 23:53:52 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Feb 2013 23:53:52 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Feb 2013 23:53:50 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id DB23A23889ED for ; Tue, 12 Feb 2013 23:53:31 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r850426 - in /websites/staging/xmlgraphics/trunk/content: ./ fop/trunk/fonts.html Date: Tue, 12 Feb 2013 23:53:31 -0000 To: commits@xmlgraphics.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130212235331.DB23A23889ED@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: buildbot Date: Tue Feb 12 23:53:31 2013 New Revision: 850426 Log: Staging update by buildbot for xmlgraphics Modified: websites/staging/xmlgraphics/trunk/content/ (props changed) websites/staging/xmlgraphics/trunk/content/fop/trunk/fonts.html Propchange: websites/staging/xmlgraphics/trunk/content/ ------------------------------------------------------------------------------ --- cms:source-revision (original) +++ cms:source-revision Tue Feb 12 23:53:31 2013 @@ -1 +1 @@ -1445389 +1445428 Modified: websites/staging/xmlgraphics/trunk/content/fop/trunk/fonts.html ============================================================================== --- websites/staging/xmlgraphics/trunk/content/fop/trunk/fonts.html (original) +++ websites/staging/xmlgraphics/trunk/content/fop/trunk/fonts.html Tue Feb 12 23:53:31 2013 @@ -350,7 +350,7 @@ $(document).ready(function () {
-

Apache™ FOP: Fonts

+

Apache™ FOP: Fonts

Summary

The following table summarizes the font capabilities of the various Apache™ FOP renderers:

@@ -472,17 +472,9 @@ $(document).ready(function () {

The Java2D family of renderers (Java2D, AWT, Print, TIFF, PNG), use the Java AWT subsystem for font metric information. Through operating system registration, the AWT subsystem knows what fonts are available on the system, and the font metrics for each one.

When working with one of these output formats and you're missing a font, just install it in your operating system and they should be available for these renderers. Please note that this is not true for other output formats such as PDF or PostScript.

Custom Fonts

-

Support for custom fonts is highly output format dependent (see above table). This section shows how to add Type 1 and TrueType fonts to the PDF, PostScript and Java2D-based renderers. Other renderers (like AFP) support other font formats. Details in this case can be found on the page about output formats.

-

In earlier FOP versions, it was always necessary to create an XML font metrics file if you wanted to add a custom font. This unconvenient step has been removed and in addition to that, FOP supports auto-registration of fonts, i.e. FOP can find fonts installed in your operating system or can scan user-specified directories for fonts. Font registration via XML font metrics file is still supported and may still be necessary for some very special cases as fallback variant while we stabilize font auto-detection.

-

Basic information about fonts can be found at:

- +

Support for custom fonts is highly output format dependent (see above table). This section shows how to add Type 1 and TrueType fonts to the PDF, PostScript and Java2D-based renderers. Other renderers (like AFP) support other font formats. Details in this case can be found on the page about output formats. FOP does not support yet OpenType fonts yet, although that is in the roadmap for the next release.

+

In earlier FOP versions, it was always necessary to create an XML font metrics file if you wanted to add a custom font. This unconvenient step has been removed and in addition to that, FOP supports auto-registration of fonts, i.e. FOP can find fonts installed in your operating system or can scan user-specified directories for fonts. Font registration via XML font metrics has been deprecated and is not recommended although it is still supported by the current code.

+

More information about fonts can be found at Adobe Font Technical Notes.

Bulk Font Configuration

If you want FOP to use custom fonts, you need to tell it where to find them. This is done in the configuration file and once per renderer (because each output format is a little different). For convenience, FOP allows bulk registering of fonts; you can either tell FOP to find your operating system fonts or you can specify directories that it will search for support fonts. These fonts will then automatically be registered.

<renderers>
@@ -510,9 +502,9 @@ $(document).ready(function () {
        <fonts>
            <!-- register a particular font -->
            <font kerning="yes"
-                 embed-url="file:///C:/myfonts/FTL_____.pfb"
-                 encoding-mode="single-byte">
-               <font-triplet name="FrutigerLight" style="normal" weight="normal"/>
+                 embed-url="/System/Library/fonts/Arial.ttf"
+                 embedding-mode="subset">
+               <font-triplet name="Arial" style="normal" weight="normal"/>
            </font>
        </fonts>
    </renderer>
@@ -522,21 +514,15 @@ $(document).ready(function () {
 
 
  • -

    URLs are used to access the font metric and font files. Relative URLs are resolved relative to the font-base property (or base) if available. See FOP: Configuration for more information.

    +

    The "embed-url" attribute is used to specify the font file. Relative URLs are resolved relative to the font-base property (or base) if available. See FOP: Configuration for more information.

  • -

    The "metrics-url" attribute is generally not necessary except if you run into problems with certain fonts.

    -
  • -
  • -

    Either an "embed-url" or a "metrics-url" must be specified for font tag configurations.

    +

    The "embedding-mode" attribute is optional and can take two values: subset (the default) and full. If not specified the font is subset embedded unless is explicitly referenced (see below).

  • The font "kerning" attribute is optional. Default is "true".

  • -

    If embedding is off (i.e. embed-url is not set), the output will position the text correctly (from the metrics file), but it will not be displayed or printed correctly unless the viewer has the applicable font available to their local system.

    -
  • -
  • When setting the "embed-url" attribute for Type 1 fonts, be sure to specify the PFB (actual font data), not PFM (font metrics) file that you used to generate the XML font metrics file.

  • @@ -568,18 +554,12 @@ $(document).ready(function () {
  • If relative URLs are specified, they are evaluated relative to the value of the "font-base" setting. If there is no "font-base" setting, the fonts are evaluated relative to the base directory.

  • +
  • +

    If a fop.xconf is not used, or the "embed-url" attribute is missing, the fonts are referenced (and the default Base-14 is used in this case).

    +

TrueType Collections

-

TrueType collections (.ttc files) contain more than one font. To create metrics files for these fonts, you must specify which font in the collection should be generated, by using the "-ttcname" option with the TTFReader.

-

To get a list of the fonts in a collection, just start the TTFReader as if it were a normal TrueType file (without the -ttcname option). It will display all of the font names and exit with an Exception.

-

Here is an example of generating a metrics file for a .ttc file:

-
java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar
-      org.apache.fop.fonts.apps.TTFReader -ttcname "MS Mincho"
-      msmincho.ttc msminch.xml
-
- - -

Alternatively, the individual sub-fonts of a TrueType Collections can be selected using the "sub-font" attribute on the "font" element. That means that generating an XML font metrics file for TrueType collections is not necessary anymore. Example:

+

TrueType collections (.ttc files) contain more than one font. The individual sub-fonts of a TrueType Collection can be selected using the "sub-font" attribute on the "font" element. Example:

<font embed-url="gulim.ttc" sub-font="GulimChe">
   <font-triplet name="GulimChe" style="normal" weight="normal"/>
 </font>
@@ -600,79 +580,12 @@ $(document).ready(function () {
 

The font cache

Apache FOP maintains a cache file that is used to speed up auto-detection. This file is usually found in the ".fop" directory under the user's home directory. It's called "fop-fonts.cache". When the user's home directory is not writable, the font cache file is put in the directory for temporary files.

If there was a problem loading a particular font, it is flagged in the cache file so it is not loaded anymore. So, if a font is actually around but is still not found by Apache FOP, it's worth a try to delete the font cache file which forces Apache FOP to reparse all fonts.

-

Type 1 Font Metrics

-

Note that metrics files are optional and no longer required

-

FOP includes PFMReader, which reads the PFM file that normally comes with a Type 1 font, and generates an appropriate font metrics file for it. To use it, run the class org.apache.fop.fonts.apps.PFMReader:

-

Windows:

-
java -cp build\fop.jar;lib\avalon-framework.jar;lib\commons-logging.jar;lib\commons-io.jar
-      org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file
-
- - -

Unix:

-
java -cp build/fop.jar:lib/avalon-framework.jar:lib/commons-logging.jar:lib/commons-io.jar
-      org.apache.fop.fonts.apps.PFMReader [options] pfm-file xml-file
-
- - -

PFMReader [options]:

-
    -
  • -fn By default, FOP uses the fontname from the .pfm file when embedding the font. Use the "-fn" option to override this name with one you have chosen. This may be useful in some cases to ensure that applications using the output document (Acrobat Reader for example) use the embedded font instead of a local font with the same name.
  • -
-

The classpath in the above example has been simplified for readability. You will have to adjust the classpath to the names of the actual JAR files in the lib directory. xml-apis.jar, xercesImpl.jar, xalan.jar and serializer.jar are not necessary for JDK version 1.4 or later.

-

The tool will construct some values (FontBBox, StemV and ItalicAngle) based on assumptions and calculations which are only an approximation to the real values. FontBBox and Italic Angle can be found in the human-readable part of the PFB file or in the AFM file. The PFMReader tool does not yet interpret PFB or AFM files, so if you want to be correct, you may have to adjust the values in the XML file manually. The constructed values however appear to have no visible influence.

-

TrueType Font Metrics

-

Note that metrics files are optional and no longer required

-

FOP includes TTFReader, which reads the TTF file and generates an appropriate font metrics file for it. Use it in a similar manner to PFMReader. For example, to create such a metrics file in Windows from the TrueType font at c:\myfonts\cmr10.ttf:

-
java -cp build\fop.jar;lib\avalon-framework-4.2.0.jar;lib\commons-logging-1.0.4.jar;lib\commons-io-1.3.1.<
 span class="n">jar;lib\commons-logging-1.0.4.jar;lib\xmlgraphics-commons-1.5.jar
-      org.apache.fop.fonts.apps.TTFReader [options]
-      C:\myfonts\cmr10.ttf ttfcm.xml
-
- - -

TTFReader [options]:

-
    -
  • -

    -d Sets the debug level (default is INFO).

    -
  • -
  • -

    -fn Same as for PFMReader.

    -
  • -
  • -

    -ttcname If you're reading data from a TrueType Collection (.ttc file) you must specify which font from the collection you will read metrics from. If you read from a .ttc file without this option, the fontnames will be listed for you.

    -
  • -
  • -

    -enc ansi Creates a WinAnsi-encoded font metrics file. Without this option, a CID-keyed font metrics file is created. The table below summarizes the differences between these two encoding options as currently used within FOP. Please note that this information only applies to TrueType fonts and TrueType collections:

    -
  • -
- - - - - - - - - - - - - - - - - - - - -
IssueWinAnsiCID-keyed
Usable Character SetLimited to WinAnsi character set, which is roughly equivalent to iso-8889-1.Limited only by the characters in the font itself.
Embedding the FontOptional.Mandatory. Not embedding the font produces invalid PDF documents.
-

You may experience failures with certain TrueType fonts, especially if they don't contain the so-called Unicode "cmap" table. TTFReader can currently not deal with font like this.

-

Embedding

+

Referencing Fonts

By default, all fonts are embedded if an output format supports font embedding. In some cases, however, it is preferred that some fonts are only referenced. When working with referenced fonts it is important to be in control of the target environment where the produced document is consumed, i.e. the necessary fonts have to be installed there.

There are two different ways how you can specify that a font should be referenced:

  1. -

    When using the old-style "font" element to configure a single font, font referencing is controlled by the embed-url attribute. If you don't specify the embed-url attribute the font will not be embedded, but will only be referenced.

    +

    When explicitly configuring a font, font referencing is controlled by the embed-url attribute. If you don't specify the embed-url attribute the font will not be embedded, but will only be referenced.

  2. For automatically configured fonts there's a different mechanism to specify which fonts should be referenced rather than embedded. This is done in the "referenced-fonts" element in the configuration. Here's an example:

    @@ -691,16 +604,11 @@ $(document).ready(function () {

At the moment, you can only match fonts against their font-family. It is possible to use regular expressions as is shown in the second example above ("DejaVu.*"). The syntax for the regular expressions used here are the one used by the package. So, in the above snippet "Helvetica" and all variants of the "DejaVu" font family are referenced. If you want to reference all fonts, just specify font-family=".*".

The referenced-fonts element can be placed either inside the general fonts element (right under the root) or in the fonts element under the renderer configuration. In the first case, matches apply to all renderers. In the second case, matches only apply to the renderer where the element was specified. Both cases can be used at the same time.

-

Various notes related to embedded fonts:

+

Embedding Fonts

+

Some notes related to embedded fonts:

  • -

    The PostScript renderer does not yet support TrueType fonts, but can embed Type 1 fonts.

    -
  • -
  • -

    The font is simply embedded into the PDF file, it is not converted.

    -
  • -
  • -

    When FOP embeds a font, it adds a prefix to the fontname to ensure that the name will not match the fontname of an installed font. This is helpful with older versions of Acrobat Reader that preferred installed fonts over embedded fonts.

    +

    When FOP embeds a font in PDF, it adds a prefix to the fontname to ensure that the name will not match the fontname of an installed font. This is helpful with older versions of Acrobat Reader that preferred installed fonts over embedded fonts.

  • When embedding PostScript fonts, the entire font is always embedded.

    @@ -709,7 +617,7 @@ $(document).ready(function () {

    When embedding TrueType fonts (ttf) or TrueType Collections (ttc), a subset of the original font, containing only the glyphs used, is embedded in the output document. That's the default, but if you specify encoding-mode="single-byte" (see above), the complete font is embedded.

-

Substitution

+

Font Substitution

When a <substitutions/> section is defined in the configuration, FOP will re-map any font-family references found in your FO input to a given substitution font.

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