You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ac...@apache.org on 2008/05/06 18:18:55 UTC
svn commit: r653827 [1/2] - in
/xmlgraphics/fop/branches/Temp_AFPGOCAResources: ./
src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/apps/
src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/autodetect/
src/java/org/apache/fop/fon...
Author: acumiskey
Date: Tue May 6 09:18:51 2008
New Revision: 653827
URL: http://svn.apache.org/viewvc?rev=653827&view=rev
Log:
Merged revisions 653826 via svnmerge from
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk
........
r653826 | acumiskey | 2008-05-06 17:14:09 +0100 (Tue, 06 May 2008) | 6 lines
* Added font substitution configuration reader, model, business logic, junit test and docs.
* Added java 1.5 generics comments to many methods.
* Performed some preparatory cleanup and refactoring which includes (but is not limited to..)
- Creating a FontManager delegating class that is called upon when renderers are setting up fonts
- A new FontCollection interface and concrete implementing classes to supercede the static FontSetup mechanism.
........
Added:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/CustomFontCollection.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/CustomFontCollection.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontCollection.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontCollection.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManager.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/base14/Base14FontCollection.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/base14/Base14FontCollection.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/substitute/
- copied from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/substitute/
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/substitute/AttributeValue.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/substitute/AttributeValue.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/substitute/FontQualifier.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/substitute/FontQualifier.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/substitute/FontSubstitution.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/substitute/FontSubstitution.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/substitute/FontWeightRange.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/Base14FontCollection.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/Base14FontCollection.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/src/java/org/apache/fop/render/java2d/InstalledFontCollection.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/config/test_fonts_substitution.xconf
- copied unchanged from r653826, xmlgraphics/fop/trunk/test/config/test_fonts_substitution.xconf
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java
- copied unchanged from r653826, xmlgraphics/fop/trunk/test/java/org/apache/fop/config/FontsSubstitutionTestCase.java
Removed:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/FontSetup.java
Modified:
xmlgraphics/fop/branches/Temp_AFPGOCAResources/ (props changed)
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/documentation/content/xdocs/trunk/fonts.xml
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FOURIResolver.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FOUserAgent.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactory.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/EmbedFontInfo.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Font.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontCache.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontDescriptor.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontInfo.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSetup.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontTriplet.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontUtil.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractRendererConfigurator.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/PrintRenderer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/PrintRendererConfigurator.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/afp/AFPRenderer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/java2d/Java2DRenderer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/pcl/PCLRenderer.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/AbstractPSTranscoder.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/ps/NativeTextHandler.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/svg/PDFDocumentGraphics2D.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/svg/PDFGraphics2D.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/status.xml
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/config/BaseUserConfigTestCase.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/config/UserConfigTestSuite.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/layoutengine/LayoutEngineTester.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/render/pdf/BasePDFTestCase.java
xmlgraphics/fop/branches/Temp_AFPGOCAResources/test/java/org/apache/fop/render/pdf/PDFAConformanceTestCase.java
Propchange: xmlgraphics/fop/branches/Temp_AFPGOCAResources/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue May 6 09:18:51 2008
@@ -1 +1 @@
-/xmlgraphics/fop/trunk:1-653716
+/xmlgraphics/fop/trunk:1-653826
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/documentation/content/xdocs/trunk/fonts.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/documentation/content/xdocs/trunk/fonts.xml?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/documentation/content/xdocs/trunk/fonts.xml (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/documentation/content/xdocs/trunk/fonts.xml Tue May 6 09:18:51 2008
@@ -201,17 +201,20 @@
support fonts. These fonts will then automatically be registered.
</p>
<source><![CDATA[
-<fonts>
- <!-- register all the fonts found in a directory -->
- <directory>C:\MyFonts1</directory>
+<renderers>
+ <renderer mime="application/pdf">
+ <fonts>
+ <!-- register all the fonts found in a directory -->
+ <directory>C:\MyFonts1</directory>
- <!-- register all the fonts found in a directory
- and all of its sub directories (use with care) -->
- <directory recursive="true">C:\MyFonts2</directory>
+ <!-- register all the fonts found in a directory and all of its sub directories (use with care) -->
+ <directory recursive="true">C:\MyFonts2</directory>
- <!-- automatically detect operating system installed fonts -->
- <auto-detect/>
-</fonts>]]></source>
+ <!-- automatically detect operating system installed fonts -->
+ <auto-detect/>
+ </fonts>
+ </renderer>
+</renderers>]]></source>
<note>
Review the documentation for <a href="configuration.html">FOP Configuration</a>
for instructions on making the FOP configuration available to FOP when it runs.
@@ -318,23 +321,25 @@
<title>Register Fonts with FOP</title>
<p>You must tell FOP how to find and use the font metrics files by registering them in the <a href="configuration.html">FOP Configuration</a>. Add entries for your custom fonts, regardless of font type, to the configuration file in a manner similar to the following:</p>
<source><![CDATA[
-<fonts>
- <!-- register a particular font -->
- <font metrics-url="file:///C:/myfonts/FTL_____.xml" kerning="yes"
- embed-url="file:///C:/myfonts/FTL_____.pfb">
- <font-triplet name="FrutigerLight" style="normal" weight="normal"/>
- </font>
+<renderers>
+ <renderer mime="application/pdf">
+ <fonts>
+ <!-- register a particular font -->
+ <font metrics-url="file:///C:/myfonts/FTL_____.xml" kerning="yes" embed-url="file:///C:/myfonts/FTL_____.pfb">
+ <font-triplet name="FrutigerLight" style="normal" weight="normal"/>
+ </font>
- <!-- register all the fonts found in a directory -->
- <directory>C:\MyFonts1</directory>
+ <!-- register all the fonts found in a directory -->
+ <directory>C:\MyFonts1</directory>
- <!-- register all the fonts found in a directory
- and all of its sub directories (use with care) -->
- <directory recursive="true">C:\MyFonts2</directory>
+ <!-- register all the fonts found in a directory and all of its sub directories (use with care) -->
+ <directory recursive="true">C:\MyFonts2</directory>
- <!-- automatically detect operating system installed fonts -->
- <auto-detect/>
-</fonts>]]></source>
+ <!-- automatically detect operating system installed fonts -->
+ <auto-detect/>
+ </fonts>
+ </renderer>
+</renderers>]]></source>
<ul>
<li>
URLs are used to access the font metric and font files.
@@ -359,7 +364,7 @@
<!--note>Cocoon users will need to setup the config, see FOPSerializer for more information.</note-->
</section>
<section id="autodetect">
- <title>Auto-Detect and auto-embedd feature</title>
+ <title>Auto-Detect and auto-embed feature</title>
<p>When the "auto-detect" flag is set in the configuration, FOP will automatically search for fonts in the default paths for your operating system.</p>
<p>FOP will also auto-detect fonts which are available in the classpath, if they are described as "application/x-font" in the MANIFEST.MF file. For example, if your .jar file contains font/myfont.ttf:</p>
<source>Manifest-Version: 1.0
@@ -385,6 +390,30 @@
<p>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.</p>
</section>
+ <section id="substitution">
+ <title>Substitution</title>
+ <p>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.</p>
+ <ul>
+ <li>If a <substitution/> is declared, it is mandatory that both a <from/> and <to/> child element is declared with a font-family attribute.</li>
+ <li>Both font-weight and font-style are optional attributes, if they are provided then a value of 'normal' is assumed.</li>
+ </ul>
+ <p>For example you could make all FO font-family references to 'Arial' with weights between 700 and 900 reference the normal 'Arial Black' font.</p>
+ <source><![CDATA[
+<fop version="1.0">
+ <fonts>
+ <substitutions>
+ <substitution>
+ <from font-family="Arial" font-weight="700..900"/>
+ <to font-family="Arial Black"/>
+ </substitution>
+ <substitution>
+ <from font-family="FrutigerLight"/>
+ <to font-family="Times" font-weight="bold" font-style="italic"/>
+ </substitution>
+ </substitutions>
+ </fonts>
+</fop>]]></source>
+ </section>
<!-- The following section should no longer be required
<section id="embedding-base14">
<title>Explicitly embedding the base 14 fonts</title>
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FOURIResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FOURIResolver.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FOURIResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FOURIResolver.java Tue May 6 09:18:51 2008
@@ -60,6 +60,34 @@
private boolean throwExceptions = false;
/**
+ * Checks if the given base URL is acceptable. It also normalizes the URL.
+ * @param base the base URL to check
+ * @return the normalized URL
+ * @throws MalformedURLException if there's a problem with a file URL
+ */
+ public String checkBaseURL(String base) throws MalformedURLException {
+ if (!base.endsWith("/")) {
+ // The behavior described by RFC 3986 regarding resolution of relative
+ // references may be misleading for normal users:
+ // file://path/to/resources + myResource.res -> file://path/to/myResource.res
+ // file://path/to/resources/ + myResource.res -> file://path/to/resources/myResource.res
+ // We assume that even when the ending slash is missing, users have the second
+ // example in mind
+ base += "/";
+ }
+ File dir = new File(base);
+ try {
+ base = (dir.isDirectory() ? dir.toURL() : new URL(base)).toExternalForm();
+ } catch (MalformedURLException mfue) {
+ if (throwExceptions) {
+ throw mfue;
+ }
+ log.error(mfue.getMessage());
+ }
+ return base;
+ }
+
+ /**
* Default constructor
*/
public FOURIResolver() {
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FOUserAgent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FOUserAgent.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FOUserAgent.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FOUserAgent.java Tue May 6 09:18:51 2008
@@ -147,7 +147,7 @@
}
this.factory = factory;
setBaseURL(factory.getBaseURL());
- setFontBaseURL(factory.getFontBaseURL());
+ setFontBaseURL(factory.getFontManager().getFontBaseURL());
setTargetResolution(factory.getTargetResolution());
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactory.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactory.java Tue May 6 09:18:51 2008
@@ -24,7 +24,6 @@
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
-import java.net.URL;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
@@ -45,6 +44,7 @@
import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.ElementMappingRegistry;
import org.apache.fop.fonts.FontCache;
+import org.apache.fop.fonts.FontManager;
import org.apache.fop.hyphenation.HyphenationTreeResolver;
import org.apache.fop.layoutmgr.LayoutManagerMaker;
import org.apache.fop.render.RendererFactory;
@@ -84,6 +84,9 @@
/** Image manager for loading and caching image objects */
private ImageManager imageManager;
+ /** Font manager for font substitution, autodetection and caching **/
+ private FontManager fontManager;
+
/** Configuration layer used to configure fop */
private FopFactoryConfigurator config = null;
@@ -93,9 +96,6 @@
*/
private String base = null;
- /** The base URL for all font URL resolutions. */
- private String fontBase = null;
-
/** The base URL for all hyphen URL resolutions. */
private String hyphenBase = null;
@@ -113,12 +113,6 @@
*/
private boolean strictUserConfigValidation
= FopFactoryConfigurator.DEFAULT_STRICT_USERCONFIG_VALIDATION;
-
- /** Font cache to speed up auto-font configuration (null if disabled) */
- private FontCache fontCache = null;
-
- /** Allows enabling kerning on the base 14 fonts, default is false */
- private boolean enableBase14Kerning = false;
/** Source resolution in dpi */
private float sourceResolution = FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION;
@@ -155,7 +149,6 @@
this.rendererFactory = new RendererFactory();
this.xmlHandlers = new XMLHandlerRegistry();
this.ignoredNamespaces = new java.util.HashSet();
- setUseCache(FopFactoryConfigurator.DEFAULT_USE_CACHE);
}
/**
@@ -317,42 +310,14 @@
public LayoutManagerMaker getLayoutManagerMakerOverride() {
return this.lmMakerOverride;
}
-
- /**
- * Checks if the given base URL is acceptable. It also normalizes the URL.
- * @param base the base URL to check
- * @return the normalized URL
- * @throws MalformedURLException if there's a problem with a file URL
- */
- private String checkBaseURL(String base) throws MalformedURLException {
- if (!base.endsWith("/")) {
- // The behavior described by RFC 3986 regarding resolution of relative
- // references may be misleading for normal users:
- // file://path/to/resources + myResource.res -> file://path/to/myResource.res
- // file://path/to/resources/ + myResource.res -> file://path/to/resources/myResource.res
- // We assume that even when the ending slash is missing, users have the second
- // example in mind
- base += "/";
- }
- File dir = new File(base);
- try {
- base = (dir.isDirectory() ? dir.toURL() : new URL(base)).toExternalForm();
- } catch (MalformedURLException mfue) {
- if (strictUserConfigValidation) {
- throw mfue;
- }
- log.error(mfue.getMessage());
- }
- return base;
- }
/**
* Sets the base URL.
- * @param base base URL
+ * @param base the base URL
* @throws MalformedURLException if there's a problem with a file URL
*/
public void setBaseURL(String base) throws MalformedURLException {
- this.base = checkBaseURL(base);
+ this.base = foURIResolver.checkBaseURL(base);
}
/**
@@ -367,14 +332,18 @@
* Sets the font base URL.
* @param fontBase font base URL
* @throws MalformedURLException if there's a problem with a file URL
+ * @deprecated use getFontManager().setFontBaseURL(fontBase) instead
*/
public void setFontBaseURL(String fontBase) throws MalformedURLException {
- this.fontBase = checkBaseURL(fontBase);
+ getFontManager().setFontBaseURL(fontBase);
}
- /** @return the font base URL */
+ /**
+ * @return the font base URL
+ * @deprecated use getFontManager().setFontBaseURL(fontBase) instead
+ */
public String getFontBaseURL() {
- return this.fontBase;
+ return getFontManager().getFontBaseURL();
}
/** @return the hyphen base URL */
@@ -396,7 +365,7 @@
}
});
}
- this.hyphenBase = checkBaseURL(hyphenBase);
+ this.hyphenBase = foURIResolver.checkBaseURL(hyphenBase);
}
/**
@@ -416,6 +385,14 @@
return foURIResolver;
}
+ /**
+ * Returns the FO URI Resolver.
+ * @return the FO URI Resolver
+ */
+ public FOURIResolver getFOURIResolver() {
+ return foURIResolver;
+ }
+
/** @return the HyphenationTreeResolver for resolving user-supplied hyphenation patterns. */
public HyphenationTreeResolver getHyphenationTreeResolver() {
return this.hyphResolver;
@@ -471,17 +448,21 @@
this.breakIndentInheritanceOnReferenceAreaBoundary = value;
}
- /** @return true if kerning on base 14 fonts is enabled */
+ /**
+ * @return true if kerning on base 14 fonts is enabled
+ * @deprecated use getFontManager().isBase14KerningEnabled() instead
+ */
public boolean isBase14KerningEnabled() {
- return this.enableBase14Kerning;
+ return getFontManager().isBase14KerningEnabled();
}
/**
* Controls whether kerning is activated on base 14 fonts.
* @param value true if kerning should be activated
+ * @deprecated use getFontManager().setBase14KerningEnabled(boolean) instead
*/
public void setBase14KerningEnabled(boolean value) {
- this.enableBase14Kerning = value;
+ getFontManager().setBase14KerningEnabled(value);
}
/** @return the resolution for resolution-dependant input */
@@ -681,37 +662,44 @@
return this.strictUserConfigValidation;
}
- //------------------------------------------- Cache related stuff
+ //------------------------------------------- Font related stuff
/**
* Whether or not to cache results of font triplet detection/auto-config
* @param useCache use cache or not
+ * @deprecated use getFontManager().setUseCache(boolean) instead
*/
public void setUseCache(boolean useCache) {
- if (useCache) {
- this.fontCache = FontCache.load();
- if (this.fontCache == null) {
- this.fontCache = new FontCache();
- }
- } else {
- this.fontCache = null;
- }
+ getFontManager().setUseCache(useCache);
}
/**
* Cache results of font triplet detection/auto-config?
* @return whether this factory is uses the cache
+ * @deprecated use getFontManager().useCache() instead
*/
public boolean useCache() {
- return (this.fontCache != null);
+ return getFontManager().useCache();
}
/**
* Returns the font cache instance used by this factory.
* @return the font cache
+ * @deprecated use getFontManager().getFontCache() instead
*/
public FontCache getFontCache() {
- return this.fontCache;
+ return getFontManager().getFontCache();
+ }
+
+ /**
+ * Returns the font manager
+ * @return the font manager
+ */
+ public FontManager getFontManager() {
+ if (fontManager == null) {
+ this.fontManager = new FontManager(this);
+ }
+ return this.fontManager;
}
/**
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactoryConfigurator.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactoryConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/apps/FopFactoryConfigurator.java Tue May 6 09:18:51 2008
@@ -28,6 +28,8 @@
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.fop.fonts.FontManager;
+import org.apache.fop.fonts.FontManagerConfigurator;
import org.apache.fop.util.LogUtil;
import org.xml.sax.SAXException;
@@ -57,9 +59,6 @@
/** Defines the default target resolution (72dpi) for FOP */
public static final float DEFAULT_TARGET_RESOLUTION = 72.0f; //dpi
- /** Use cache (record previously detected font triplet info) */
- public static final boolean DEFAULT_USE_CACHE = true;
-
/** logger instance */
private final Log log = LogFactory.getLog(FopFactoryConfigurator.class);
@@ -119,14 +118,6 @@
LogUtil.handleException(log, mfue, strict);
}
}
- if (cfg.getChild("font-base", false) != null) {
- try {
- factory.setFontBaseURL(
- cfg.getChild("font-base").getValue(null));
- } catch (MalformedURLException mfue) {
- LogUtil.handleException(log, mfue, strict);
- }
- }
if (cfg.getChild("hyphenation-base", false) != null) {
try {
factory.setHyphenBaseURL(
@@ -180,15 +171,10 @@
}
}
- // caching (fonts)
- if (cfg.getChild("use-cache", false) != null) {
- try {
- factory.setUseCache(
- cfg.getChild("use-cache").getValueAsBoolean());
- } catch (ConfigurationException mfue) {
- LogUtil.handleException(log, mfue, strict);
- }
- }
+ // configure font manager
+ FontManager fontManager = factory.getFontManager();
+ FontManagerConfigurator fontManagerConfigurator = new FontManagerConfigurator(cfg);
+ fontManagerConfigurator.configure(fontManager);
}
/**
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/EmbedFontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/EmbedFontInfo.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/EmbedFontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/EmbedFontInfo.java Tue May 6 09:18:51 2008
@@ -36,14 +36,15 @@
protected String embedFile;
/** false, to disable kerning */
protected boolean kerning;
- /** the list of associated font triplets */
- protected List fontTriplets;
/** the PostScript name of the font */
protected String postScriptName = null;
/** the sub-fontname of the font (used for TrueType Collections, null otherwise) */
protected String subFontName = null;
+ /** the list of associated font triplets */
+ private List/*<FontTriplet>*/ fontTriplets = null;
+
/**
* Main constructor
* @param metricsFile Path to the xml file containing font metrics
@@ -53,7 +54,7 @@
* @param subFontName the sub-fontname used for TrueType Collections (null otherwise)
*/
public EmbedFontInfo(String metricsFile, boolean kerning,
- List fontTriplets, String embedFile, String subFontName) {
+ List/*<FontTriplet>*/ fontTriplets, String embedFile, String subFontName) {
this.metricsFile = metricsFile;
this.embedFile = embedFile;
this.kerning = kerning;
@@ -84,19 +85,11 @@
public boolean getKerning() {
return kerning;
}
-
- /**
- * Returns the list of font triplets associated with this font.
- * @return List of font triplets
- */
- public List getFontTriplets() {
- return fontTriplets;
- }
/**
- * Returns the sub-fontname name of the font. This is primarily used for TrueType Collections
+ * Returns the sub-font name name of the font. This is primarily used for TrueType Collections
* to select one of the sub-fonts. For all other fonts, this is always null.
- * @return the sub-fontname (or null)
+ * @return the sub-font name (or null)
*/
public String getSubFontName() {
return this.subFontName;
@@ -118,10 +111,20 @@
this.postScriptName = postScriptName;
}
- /** {@inheritDoc} */
+ /**
+ * Returns the list of font triplets associated with this font.
+ * @return List of font triplets
+ */
+ public List/*<FontTriplet>*/ getFontTriplets() {
+ return fontTriplets;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public String toString() {
return "metrics-url=" + metricsFile + ",embed-url=" + embedFile
- + ", kerning=" + kerning + ", font-triplet=" + fontTriplets
+ + ", kerning=" + kerning + ", " + "font-triplet=" + fontTriplets
+ (getSubFontName() != null ? ", sub-font=" + getSubFontName() : "");
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Font.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Font.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Font.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/Font.java Tue May 6 09:18:51 2008
@@ -48,9 +48,18 @@
/** Italic font style */
public static final String STYLE_ITALIC = "italic";
+ /** Oblique font style */
+ public static final String STYLE_OBLIQUE = "oblique";
+
+ /** Inclined font style */
+ public static final String STYLE_INCLINED = "inclined";
+
+ /** Default selection priority */
+ public static final int PRIORITY_DEFAULT = 0;
+
/** Default fallback key */
public static final FontTriplet DEFAULT_FONT = new FontTriplet(
- "any", STYLE_NORMAL, WEIGHT_NORMAL);
+ "any", STYLE_NORMAL, WEIGHT_NORMAL, PRIORITY_DEFAULT);
/** logger */
private static Log log = LogFactory.getLog(Font.class);
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontCache.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontCache.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontCache.java Tue May 6 09:18:51 2008
@@ -59,6 +59,7 @@
/** font cache file path */
private static final String DEFAULT_CACHE_FILENAME = "fop-fonts.cache";
+
/** has this cache been changed since it was last read? */
private transient boolean changed = false;
@@ -67,10 +68,10 @@
/** master mapping of font url -> font info. This needs to be
* a list, since a TTC file may contain more than 1 font. */
- private Map fontfileMap = new java.util.HashMap(); //Map<String, CachedFontFile>
+ private Map/*<String, CachedFontFile>*/ fontfileMap = null;
/** mapping of font url -> file modified date (for all fonts that have failed to load) */
- private Map failedFontMap = new java.util.HashMap();
+ private Map failedFontMap/*<String, Long>*/ = null;
/**
* Default constructor
@@ -221,7 +222,7 @@
*/
public boolean containsFont(String embedUrl) {
if (embedUrl != null) {
- return fontfileMap.containsKey(embedUrl);
+ return getFontFileMap().containsKey(embedUrl);
}
return false;
}
@@ -233,7 +234,7 @@
*/
public boolean containsFont(EmbedFontInfo fontInfo) {
if (fontInfo != null) {
- return fontfileMap.containsKey(getCacheKey(fontInfo));
+ return getFontFileMap().containsKey(getCacheKey(fontInfo));
}
return false;
}
@@ -268,6 +269,13 @@
return null;
}
+ private Map/*<String, CachedFontFile>*/ getFontFileMap() {
+ if (fontfileMap == null) {
+ fontfileMap = new java.util.HashMap/*<String, CachedFontFile>*/();
+ }
+ return fontfileMap;
+ }
+
/**
* Adds a font info to cache
* @param fontInfo font info
@@ -277,7 +285,7 @@
synchronized (changeLock) {
CachedFontFile cachedFontFile;
if (containsFont(cacheKey)) {
- cachedFontFile = (CachedFontFile)fontfileMap.get(cacheKey);
+ cachedFontFile = (CachedFontFile)getFontFileMap().get(cacheKey);
if (!cachedFontFile.containsFont(fontInfo)) {
cachedFontFile.put(fontInfo);
}
@@ -291,7 +299,7 @@
log.trace("Font added to cache: " + cacheKey);
}
cachedFontFile.put(fontInfo);
- fontfileMap.put(cacheKey, cachedFontFile);
+ getFontFileMap().put(cacheKey, cachedFontFile);
changed = true;
}
}
@@ -304,7 +312,7 @@
*/
public CachedFontFile getFontFile(String embedUrl) {
if (containsFont(embedUrl)) {
- return (CachedFontFile)fontfileMap.get(embedUrl);
+ return (CachedFontFile)getFontFileMap().get(embedUrl);
}
return null;
}
@@ -336,7 +344,7 @@
if (log.isTraceEnabled()) {
log.trace("Font removed from cache: " + embedUrl);
}
- fontfileMap.remove(embedUrl);
+ getFontFileMap().remove(embedUrl);
changed = true;
}
}
@@ -349,13 +357,13 @@
* @return whether this is a failed font
*/
public boolean isFailedFont(String embedUrl, long lastModified) {
- if (failedFontMap.containsKey(embedUrl)) {
+ if (getFailedFontMap().containsKey(embedUrl)) {
synchronized (changeLock) {
- long failedLastModified = ((Long)failedFontMap.get(embedUrl)).longValue();
+ long failedLastModified = ((Long)getFailedFontMap().get(embedUrl)).longValue();
if (lastModified != failedLastModified) {
// this font has been changed so lets remove it
// from failed font map for now
- failedFontMap.remove(embedUrl);
+ getFailedFontMap().remove(embedUrl);
changed = true;
}
}
@@ -365,19 +373,26 @@
}
/**
- * registers a failed font with the cache
+ * Registers a failed font with the cache
* @param embedUrl embed url
* @param lastModified time last modified
*/
public void registerFailedFont(String embedUrl, long lastModified) {
synchronized (changeLock) {
- if (!failedFontMap.containsKey(embedUrl)) {
- failedFontMap.put(embedUrl, new Long(lastModified));
+ if (!getFailedFontMap().containsKey(embedUrl)) {
+ getFailedFontMap().put(embedUrl, new Long(lastModified));
changed = true;
}
}
}
+ private Map/*<String, Long>*/ getFailedFontMap() {
+ if (failedFontMap == null) {
+ failedFontMap = new java.util.HashMap/*<String, Long>*/();
+ }
+ return failedFontMap;
+ }
+
/**
* Clears font cache
*/
@@ -386,8 +401,8 @@
if (log.isTraceEnabled()) {
log.trace("Font cache cleared.");
}
- fontfileMap.clear();
- failedFontMap.clear();
+ fontfileMap = null;
+ failedFontMap = null;
changed = true;
}
}
@@ -414,33 +429,38 @@
}
private static class CachedFontFile implements Serializable {
+ private static final long serialVersionUID = 4524237324330578883L;
+
/** file modify date (if available) */
private long lastModified = -1;
- private Map filefontsMap = new java.util.HashMap(); //Map<String, EmbedFontInfo>
+ private Map/*<String, EmbedFontInfo>*/ filefontsMap = null;
public CachedFontFile(long lastModified) {
setLastModified(lastModified);
}
+ private Map/*<String, EmbedFontInfo>*/ getFileFontsMap() {
+ if (filefontsMap == null) {
+ filefontsMap = new java.util.HashMap/*<String, EmbedFontInfo>*/();
+ }
+ return filefontsMap;
+ }
+
void put(EmbedFontInfo efi) {
- filefontsMap.put(efi.getPostScriptName(), efi);
+ getFileFontsMap().put(efi.getPostScriptName(), efi);
}
public boolean containsFont(EmbedFontInfo efi) {
if (efi.getPostScriptName() != null) {
- return filefontsMap.containsKey(efi.getPostScriptName());
+ return getFileFontsMap().containsKey(efi.getPostScriptName());
}
return false;
}
- public Map getFilefontsMap() {
- return filefontsMap;
- }
-
public EmbedFontInfo[] getEmbedFontInfos() {
- return (EmbedFontInfo[])this.filefontsMap.values().toArray(
- new EmbedFontInfo[this.filefontsMap.size()]);
+ return (EmbedFontInfo[])getFileFontsMap().values().toArray(
+ new EmbedFontInfo[getFileFontsMap().size()]);
}
/**
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontDescriptor.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontDescriptor.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontDescriptor.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontDescriptor.java Tue May 6 09:18:51 2008
@@ -35,7 +35,7 @@
/**
* Returns the capital height of the font.
- * @return the capiptal height
+ * @return the capital height
*/
int getCapHeight();
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontInfo.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontInfo.java Tue May 6 09:18:51 2008
@@ -19,19 +19,18 @@
package org.apache.fop.fonts;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
/**
- * The FontInfo for the layout and rendering of a fo document.
+ * The FontInfo holds font information for the layout and rendering of a fo document.
* This stores the list of available fonts that are setup by
* the renderer. The font name can be retrieved for the
* family style and weight.
@@ -47,38 +46,40 @@
protected static Log log = LogFactory.getLog(FontInfo.class);
/** Map containing fonts that have been used */
- private Map usedFonts; //Map<String,FontMetrics> (String = font key)
+ private Map/*<String,FontMetrics>*/ usedFonts = null; //(String = font key)
/** look up a font-triplet to find a font-name */
- private Map triplets; //Map<FontTriplet,String> (String = font key)
+ private Map/*<FontTriplet,String>*/ triplets = null; //(String = font key)
/** look up a font-triplet to find its priority
* (only used inside addFontProperties()) */
- private Map tripletPriorities; //Map<FontTriplet,Integer>
+ private Map/*<FontTriplet,Integer>*/ tripletPriorities = null; //Map<FontTriplet,Integer>
/** look up a font-name to get a font (that implements FontMetrics at least) */
- private Map fonts; //Map<String,FontMetrics> (String = font key)
+ private Map/*<String,FontMetrics>*/ fonts = null; //(String = font key)
- /** collection of missing fonts; used to make sure the user gets
+ /**
+ * a collection of missing fonts; used to make sure the user gets
* a warning for a missing font only once (not every time the font is used)
*/
- private Collection loggedFontKeys;
+ private Set/*<FontTriplet>*/ loggedFontKeys = null;
/** Cache for Font instances. */
- private Map fontInstanceCache = new java.util.HashMap();
-
- private FontEventListener eventListener;
+ private Map/*<FontTriplet, Map>*/ fontInstanceCache = null;
+ /** Event listener for font events */
+ private FontEventListener eventListener = null;
+
/**
* Main constructor
*/
public FontInfo() {
- this.triplets = new java.util.HashMap();
- this.tripletPriorities = new java.util.HashMap();
- this.fonts = new java.util.HashMap();
- this.usedFonts = new java.util.HashMap();
+ this.triplets = new java.util.HashMap/*<FontTriplet, String>*/();
+ this.tripletPriorities = new java.util.HashMap/*<FontTriplet, Integer>*/();
+ this.fonts = new java.util.HashMap/*<String, FontMetrics>*/();
+ this.usedFonts = new java.util.HashMap/*<String,FontMetrics>*/();
}
-
+
/**
* Sets the font event listener that can be used to receive events about particular events
* in this class.
@@ -112,16 +113,16 @@
/**
* Adds a new font triplet.
- * @param name internal key
+ * @param internalFontKey internal font key
* @param triplet the font triplet to associate with the internal key
*/
- public void addFontProperties(String name, FontTriplet triplet) {
+ public void addFontProperties(String internalFontKey, FontTriplet triplet) {
/*
* add the given family, style and weight as a lookup for the font
* with the given name
*/
if (log.isDebugEnabled()) {
- log.debug("Registering: " + triplet + " under " + name);
+ log.debug("Registering: " + triplet + " under " + internalFontKey);
}
String oldName = (String)triplets.get(triplet);
int newPriority = triplet.getPriority();
@@ -129,18 +130,20 @@
int oldPriority = ((Integer)tripletPriorities.get(triplet)).intValue();
if (oldPriority < newPriority) {
logDuplicateFont(triplet, false, oldName, oldPriority,
- name, newPriority);
+ internalFontKey, newPriority);
return;
} else {
logDuplicateFont(triplet, true, oldName, oldPriority,
- name, newPriority);
+ internalFontKey, newPriority);
}
}
- this.triplets.put(triplet, name);
+ this.triplets.put(triplet, internalFontKey);
this.tripletPriorities.put(triplet, new Integer(newPriority));
}
- /** Log warning about duplicate font triplets.
+ /**
+ * Log warning about duplicate font triplets.
+ *
* @param triplet the duplicate font triplet
* @param replacing true iff the new font will replace the old one
* @param oldKey the old internal font name
@@ -155,24 +158,24 @@
log.debug(triplet
+ (replacing ? ": Replacing " : ": Not replacing ")
+ ((FontMetrics)fonts.get(triplets.get(triplet))).getFullName()
- + " (" + oldPriority + ") by "
+ + " (priority=" + oldPriority + ") by "
+ ((FontMetrics)fonts.get(newKey)).getFullName()
- + " (" + newPriority + ")");
+ + " (priority=" + newPriority + ")");
}
}
/**
* Adds font metrics for a specific font.
- * @param name internal key
+ * @param internalFontKey internal key
* @param metrics metrics to register
*/
- public void addMetrics(String name, FontMetrics metrics) {
+ public void addMetrics(String internalFontKey, FontMetrics metrics) {
// add the given metrics as a font with the given name
if (metrics instanceof Typeface) {
((Typeface)metrics).setEventListener(this.eventListener);
}
- this.fonts.put(name, metrics);
+ this.fonts.put(internalFontKey, metrics);
}
/**
@@ -187,71 +190,72 @@
* @param weight font weight
* @param substFont true if the font may be substituted with the
* default font if not found
- * @return internal key
+ * @return internal font triplet key
*/
private FontTriplet fontLookup(String family, String style,
int weight, boolean substFont) {
if (log.isTraceEnabled()) {
log.trace("Font lookup: " + family + " " + style + " " + weight);
- }
+ }
+
FontTriplet startKey = createFontKey(family, style, weight);
- FontTriplet key = startKey;
+ FontTriplet fontTriplet = startKey;
// first try given parameters
- String f = getInternalFontKey(key);
- if (f == null) {
- key = doAdjustedLookup(family, style, weight, startKey, substFont);
+ String internalFontKey = getInternalFontKey(fontTriplet);
+ if (internalFontKey == null) {
+ fontTriplet = fuzzyFontLookup(family, style, weight, startKey, substFont);
}
- if (key != null) {
- if (key != startKey) {
- notifyFontReplacement(startKey, key);
+ if (fontTriplet != null) {
+ if (fontTriplet != startKey) {
+ notifyFontReplacement(startKey, fontTriplet);
}
- return key;
+ return fontTriplet;
} else {
return null;
}
}
- private FontTriplet doAdjustedLookup(String family, String style,
+ private FontTriplet fuzzyFontLookup(String family, String style,
int weight, FontTriplet startKey, boolean substFont) {
FontTriplet key;
- String f;
+ String internalFontKey;
if (!family.equals(startKey.getName())) {
key = createFontKey(family, style, weight);
- f = getInternalFontKey(key);
- if (f != null) {
+ internalFontKey = getInternalFontKey(key);
+ if (internalFontKey != null) {
return key;
}
}
// adjust weight, favouring normal or bold
key = findAdjustWeight(family, style, weight);
- f = getInternalFontKey(key);
+ internalFontKey = getInternalFontKey(key);
- if (!substFont && f == null) {
+ if (!substFont && internalFontKey == null) {
return null;
}
// only if the font may be substituted
// fallback 1: try the same font-family and weight with default style
- if (f == null && style != Font.STYLE_NORMAL) {
+ if (internalFontKey == null && style != Font.STYLE_NORMAL) {
key = createFontKey(family, Font.STYLE_NORMAL, weight);
- f = getInternalFontKey(key);
+ internalFontKey = getInternalFontKey(key);
}
- if (f == null && weight != Font.WEIGHT_NORMAL) {
+ if (internalFontKey == null && weight != Font.WEIGHT_NORMAL) {
int diffWeight = (Font.WEIGHT_NORMAL - weight) / 100;
int direction = diffWeight > 0 ? 1 : -1;
int tryWeight = weight;
while (tryWeight != Font.WEIGHT_NORMAL) {
tryWeight += 100 * direction;
key = createFontKey(family, style, weight);
- f = getInternalFontKey(key);
- if (f == null) {
+ internalFontKey = getInternalFontKey(key);
+ if (internalFontKey == null) {
key = createFontKey(family, Font.STYLE_NORMAL, weight);
- f = getInternalFontKey(key);
+ internalFontKey = getInternalFontKey(key);
}
- if (f != null) {
+ if (internalFontKey != null) {
break;
}
}
@@ -265,17 +269,17 @@
}*/
// fallback 3: try any family with orig style/weight
- if (f == null) {
- return doAdjustedLookup("any", style, weight, startKey, false);
+ if (internalFontKey == null) {
+ return fuzzyFontLookup("any", style, weight, startKey, false);
}
// last resort: use default
- if (f == null) {
+ if (internalFontKey == null) {
key = Font.DEFAULT_FONT;
- f = getInternalFontKey(key);
+ internalFontKey = getInternalFontKey(key);
}
- if (f != null) {
+ if (internalFontKey != null) {
return key;
} else {
return null;
@@ -290,6 +294,13 @@
usedFonts.put(internalName, fonts.get(internalName));
}
+ private Map/*<FontTriplet,Map<Integer,Font>>*/ getFontInstanceCache() {
+ if (fontInstanceCache == null) {
+ fontInstanceCache = new java.util.HashMap/*<FontTriplet, Map<Integer,Font>>*/();
+ }
+ return fontInstanceCache;
+ }
+
/**
* Retrieves a (possibly cached) Font instance based on a FontTriplet and a font size.
* @param triplet the font triplet designating the requested font
@@ -297,10 +308,11 @@
* @return the requested Font instance
*/
public Font getFontInstance(FontTriplet triplet, int fontSize) {
- Map sizes = (Map)fontInstanceCache.get(triplet);
+ Map/*<Integer,Font>*/ sizes
+ = (Map/*<Integer,Font>*/)getFontInstanceCache().get(triplet);
if (sizes == null) {
- sizes = new java.util.HashMap();
- fontInstanceCache.put(triplet, sizes);
+ sizes = new java.util.HashMap/*<Integer,Font>*/();
+ getFontInstanceCache().put(triplet, sizes);
}
Integer size = new Integer(fontSize);
Font font = (Font)sizes.get(size);
@@ -350,7 +362,7 @@
throw new IllegalArgumentException("Specify at least one font family");
}
FontTriplet triplet;
- List tmpTriplets = new ArrayList();
+ List tmpTriplets = new java.util.ArrayList();
for (int i = 0, c = families.length; i < c; i++) {
triplet = fontLookup(families[i], style, weight, (i >= families.length - 1));
if (triplet != null) {
@@ -372,12 +384,16 @@
+ "FontTriplet on the last call. Lookup: " + sb.toString());
}
- private void notifyFontReplacement(FontTriplet replacedKey, FontTriplet newKey) {
+ private Set/*<FontTriplet>*/ getLoggedFontKeys() {
if (loggedFontKeys == null) {
- loggedFontKeys = new java.util.HashSet();
+ loggedFontKeys = new java.util.HashSet/*<FontTriplet>*/();
}
- if (!loggedFontKeys.contains(replacedKey)) {
- loggedFontKeys.add(replacedKey);
+ return loggedFontKeys;
+ }
+
+ private void notifyFontReplacement(FontTriplet replacedKey, FontTriplet newKey) {
+ if (!getLoggedFontKeys().contains(replacedKey)) {
+ getLoggedFontKeys().add(replacedKey);
if (this.eventListener != null) {
this.eventListener.fontSubstituted(this, replacedKey, newKey);
} else {
@@ -477,16 +493,16 @@
* Gets a Map of all registered fonts.
* @return a read-only Map with font key/FontMetrics pairs
*/
- public Map getFonts() {
+ public Map/*<String,FontMetrics>*/ getFonts() {
return java.util.Collections.unmodifiableMap(this.fonts);
}
/**
* Gets a Map of all registered font triplets.
- * @return a read-only Map with FontTriplet/font key pairs
+ * @return a Map with FontTriplet/font key pairs
*/
- public Map getFontTriplets() {
- return java.util.Collections.unmodifiableMap(this.triplets);
+ public Map/*<FontTriplet,String>*/ getFontTriplets() {
+ return this.triplets;
}
/**
@@ -495,7 +511,7 @@
* This is for embedded font or creating a list of used fonts.
* @return a read-only Map with font key/FontMetrics pairs
*/
- public Map getUsedFonts() {
+ public Map/*<String,FontMetrics>*/ getUsedFonts() {
return this.usedFonts;
}
@@ -511,20 +527,30 @@
}
/**
- * Returns the first triplet matching the given font name.
- * As there may be multiple triplets matching the font name
- * the result set is sorted first to guarantee consistent results.
+ * Returns all font triplet matching the given font name.
* @param fontName The font name we are looking for
- * @return The first triplet for the given font name
+ * @return A list of matching font triplets
*/
- public FontTriplet getTripletFor(String fontName) {
- List foundTriplets = new ArrayList();
+ public List/*<FontTriplet>*/ getTripletsFor(String fontName) {
+ List/*<FontTriplet>*/ foundTriplets = new java.util.ArrayList();
for (Iterator iter = triplets.entrySet().iterator(); iter.hasNext();) {
Map.Entry tripletEntry = (Map.Entry) iter.next();
if (fontName.equals(((String)tripletEntry.getValue()))) {
foundTriplets.add(tripletEntry.getKey());
}
}
+ return foundTriplets;
+ }
+
+ /**
+ * Returns the first triplet matching the given font name.
+ * As there may be multiple triplets matching the font name
+ * the result set is sorted first to guarantee consistent results.
+ * @param fontName The font name we are looking for
+ * @return The first triplet for the given font name
+ */
+ public FontTriplet getTripletFor(String fontName) {
+ List/*<FontTriplet>*/ foundTriplets = getTripletsFor(fontName);
if (foundTriplets.size() > 0) {
Collections.sort(foundTriplets);
return (FontTriplet)foundTriplets.get(0);
@@ -570,17 +596,25 @@
* Diagnostic method for logging all registered fonts to System.out.
*/
public void dumpAllTripletsToSystemOut() {
+ System.out.print(toString());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString() {
Collection entries = new java.util.TreeSet();
Iterator iter = this.triplets.keySet().iterator();
while (iter.hasNext()) {
FontTriplet triplet = (FontTriplet)iter.next();
String key = getInternalFontKey(triplet);
FontMetrics metrics = getMetricsFor(key);
- entries.add(triplet.toString() + " -> " + key + " -> " + metrics.getFontName());
+ entries.add(triplet.toString() + " -> " + key + " -> " + metrics.getFontName() + "\n");
}
- iter = entries.iterator();
- while (iter.hasNext()) {
- System.out.println(iter.next());
+ StringBuffer stringBuffer = new StringBuffer();
+ for (iter = entries.iterator(); iter.hasNext();) {
+ stringBuffer.append(iter.next());
}
+ return stringBuffer.toString();
}
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSetup.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSetup.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontSetup.java Tue May 6 09:18:51 2008
@@ -42,6 +42,8 @@
import org.apache.fop.fonts.base14.TimesRoman;
import org.apache.fop.fonts.base14.ZapfDingbats;
+//TODO remove small dependency on and refactor this
+
/**
* Default fonts for FOP application; currently this uses PDF's fonts
* by default.
@@ -57,17 +59,11 @@
protected static Log log = LogFactory.getLog(FontSetup.class);
/**
- * Sets up the font info object.
- *
- * Adds metrics for basic fonts and useful family-style-weight
- * triplets for lookup.
- *
- * @param fontInfo the font info object to set up
- * @param embedList a list of EmbedFontInfo objects
- * @param resolver the font resolver
+ * Sets up a font info
+ * @param fontInfo font info
*/
- public static void setup(FontInfo fontInfo, List embedList, FontResolver resolver) {
- setup(fontInfo, embedList, resolver, false);
+ public static void setup(FontInfo fontInfo) {
+ setup(fontInfo, null, null);
}
/**
@@ -77,25 +73,23 @@
* triplets for lookup.
*
* @param fontInfo the font info object to set up
- * @param embedList a list of EmbedFontInfo objects
+ * @param embedFontInfoList a list of EmbedFontInfo objects
* @param resolver the font resolver
- * @param enableBase14Kerning true if kerning should be enabled for base 14 fonts
*/
- public static void setup(FontInfo fontInfo, List embedList, FontResolver resolver,
- boolean enableBase14Kerning) {
-
- fontInfo.addMetrics("F1", new Helvetica(enableBase14Kerning));
- fontInfo.addMetrics("F2", new HelveticaOblique(enableBase14Kerning));
- fontInfo.addMetrics("F3", new HelveticaBold(enableBase14Kerning));
- fontInfo.addMetrics("F4", new HelveticaBoldOblique(enableBase14Kerning));
- fontInfo.addMetrics("F5", new TimesRoman(enableBase14Kerning));
- fontInfo.addMetrics("F6", new TimesItalic(enableBase14Kerning));
- fontInfo.addMetrics("F7", new TimesBold(enableBase14Kerning));
- fontInfo.addMetrics("F8", new TimesBoldItalic(enableBase14Kerning));
- fontInfo.addMetrics("F9", new Courier(enableBase14Kerning));
- fontInfo.addMetrics("F10", new CourierOblique(enableBase14Kerning));
- fontInfo.addMetrics("F11", new CourierBold(enableBase14Kerning));
- fontInfo.addMetrics("F12", new CourierBoldOblique(enableBase14Kerning));
+ public static void setup(FontInfo fontInfo, List embedFontInfoList, FontResolver resolver) {
+ final boolean base14Kerning = false;
+ fontInfo.addMetrics("F1", new Helvetica(base14Kerning));
+ fontInfo.addMetrics("F2", new HelveticaOblique(base14Kerning));
+ fontInfo.addMetrics("F3", new HelveticaBold(base14Kerning));
+ fontInfo.addMetrics("F4", new HelveticaBoldOblique(base14Kerning));
+ fontInfo.addMetrics("F5", new TimesRoman(base14Kerning));
+ fontInfo.addMetrics("F6", new TimesItalic(base14Kerning));
+ fontInfo.addMetrics("F7", new TimesBold(base14Kerning));
+ fontInfo.addMetrics("F8", new TimesBoldItalic(base14Kerning));
+ fontInfo.addMetrics("F9", new Courier(base14Kerning));
+ fontInfo.addMetrics("F10", new CourierOblique(base14Kerning));
+ fontInfo.addMetrics("F11", new CourierBold(base14Kerning));
+ fontInfo.addMetrics("F12", new CourierBoldOblique(base14Kerning));
fontInfo.addMetrics("F13", new Symbol());
fontInfo.addMetrics("F14", new ZapfDingbats());
@@ -105,64 +99,64 @@
// fontInfo.addMetrics("F17", new BauerBodoniBoldItalic());
/* any is treated as serif */
- fontInfo.addFontProperties("F5", "any", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F6", "any", "italic", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F6", "any", "oblique", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F7", "any", "normal", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F8", "any", "italic", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F8", "any", "oblique", Font.WEIGHT_BOLD);
-
- fontInfo.addFontProperties("F1", "sans-serif", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F2", "sans-serif", "oblique", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F2", "sans-serif", "italic", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F3", "sans-serif", "normal", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F4", "sans-serif", "oblique", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F4", "sans-serif", "italic", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F1", "SansSerif", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F2", "SansSerif", "oblique", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F2", "SansSerif", "italic", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F3", "SansSerif", "normal", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F4", "SansSerif", "oblique", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F4", "SansSerif", "italic", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F5", "serif", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F6", "serif", "oblique", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F6", "serif", "italic", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F7", "serif", "normal", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F8", "serif", "oblique", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F8", "serif", "italic", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F9", "monospace", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F10", "monospace", "oblique", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F10", "monospace", "italic", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F11", "monospace", "normal", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F12", "monospace", "oblique", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F12", "monospace", "italic", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F9", "Monospaced", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F10", "Monospaced", "oblique", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F10", "Monospaced", "italic", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F11", "Monospaced", "normal", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F12", "Monospaced", "oblique", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F12", "Monospaced", "italic", Font.WEIGHT_BOLD);
-
- fontInfo.addFontProperties("F1", "Helvetica", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F2", "Helvetica", "oblique", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F2", "Helvetica", "italic", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F3", "Helvetica", "normal", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F4", "Helvetica", "oblique", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F4", "Helvetica", "italic", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F5", "Times", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F6", "Times", "oblique", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F6", "Times", "italic", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F7", "Times", "normal", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F8", "Times", "oblique", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F8", "Times", "italic", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F9", "Courier", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F10", "Courier", "oblique", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F10", "Courier", "italic", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F11", "Courier", "normal", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F12", "Courier", "oblique", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F12", "Courier", "italic", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F13", "Symbol", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F14", "ZapfDingbats", "normal", Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F5", "any", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "any", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "any", Font.STYLE_OBLIQUE, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F7", "any", Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "any", Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "any", Font.STYLE_OBLIQUE, Font.WEIGHT_BOLD);
+
+ fontInfo.addFontProperties("F1", "sans-serif", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F2", "sans-serif", Font.STYLE_OBLIQUE, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F2", "sans-serif", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F3", "sans-serif", Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F4", "sans-serif", Font.STYLE_OBLIQUE, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F4", "sans-serif", Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F1", "SansSerif", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F2", "SansSerif", Font.STYLE_OBLIQUE, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F2", "SansSerif", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F3", "SansSerif", Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F4", "SansSerif", Font.STYLE_OBLIQUE, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F4", "SansSerif", Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F5", "serif", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "serif", Font.STYLE_OBLIQUE, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "serif", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F7", "serif", Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "serif", Font.STYLE_OBLIQUE, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "serif", Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F9", "monospace", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F10", "monospace", Font.STYLE_OBLIQUE, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F10", "monospace", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F11", "monospace", Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F12", "monospace", Font.STYLE_OBLIQUE, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F12", "monospace", Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F9", "Monospaced", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F10", "Monospaced", Font.STYLE_OBLIQUE, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F10", "Monospaced", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F11", "Monospaced", Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F12", "Monospaced", Font.STYLE_OBLIQUE, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F12", "Monospaced", Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
+
+ fontInfo.addFontProperties("F1", "Helvetica", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F2", "Helvetica", Font.STYLE_OBLIQUE, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F2", "Helvetica", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F3", "Helvetica", Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F4", "Helvetica", Font.STYLE_OBLIQUE, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F4", "Helvetica", Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F5", "Times", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times", Font.STYLE_OBLIQUE, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F7", "Times", Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times", Font.STYLE_OBLIQUE, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times", Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F9", "Courier", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F10", "Courier", Font.STYLE_OBLIQUE, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F10", "Courier", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F11", "Courier", Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F12", "Courier", Font.STYLE_OBLIQUE, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F12", "Courier", Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F13", "Symbol", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F14", "ZapfDingbats", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
// Custom type 1 fonts step 2/2
// fontInfo.addFontProperties("F15", "OMEP", "normal", FontInfo.NORMAL);
@@ -170,50 +164,53 @@
// fontInfo.addFontProperties("F17", "BauerBodoni", "italic", FontInfo.BOLD);
/* for compatibility with PassiveTex */
- fontInfo.addFontProperties("F5", "Times-Roman", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F6", "Times-Roman", "oblique", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F6", "Times-Roman", "italic", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F7", "Times-Roman", "normal", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F8", "Times-Roman", "oblique", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F8", "Times-Roman", "italic", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F5", "Times Roman", "normal", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F6", "Times Roman", "oblique", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F6", "Times Roman", "italic", Font.WEIGHT_NORMAL);
- fontInfo.addFontProperties("F7", "Times Roman", "normal", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F8", "Times Roman", "oblique", Font.WEIGHT_BOLD);
- fontInfo.addFontProperties("F8", "Times Roman", "italic", Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F5", "Times-Roman", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times-Roman", Font.STYLE_OBLIQUE, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times-Roman", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F7", "Times-Roman", Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times-Roman", Font.STYLE_OBLIQUE, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times-Roman", Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F5", "Times Roman", Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times Roman", Font.STYLE_OBLIQUE, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F6", "Times Roman", Font.STYLE_ITALIC, Font.WEIGHT_NORMAL);
+ fontInfo.addFontProperties("F7", "Times Roman", Font.STYLE_NORMAL, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times Roman", Font.STYLE_OBLIQUE, Font.WEIGHT_BOLD);
+ fontInfo.addFontProperties("F8", "Times Roman", Font.STYLE_ITALIC, Font.WEIGHT_BOLD);
fontInfo.addFontProperties("F9", "Computer-Modern-Typewriter",
- "normal", Font.WEIGHT_NORMAL);
+ Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
+ // All base 14 configured now, so any custom embedded fonts start from 15
+ final int startNum = 15;
+
/* Add configured fonts */
- addConfiguredFonts(fontInfo, embedList, 15, resolver);
+ addConfiguredFonts(fontInfo, embedFontInfoList, startNum, resolver);
}
/**
* Add fonts from configuration file starting with internal name F<num>.
- * @param fontInfo the font info object to set up
- * @param fontInfoList a list of EmbedFontInfo objects
+ * @param fontInfo the font info to set up
+ * @param embedFontInfoList a list of EmbedFontInfo objects
* @param num starting index for internal font numbering
* @param resolver the font resolver
*/
- public static void addConfiguredFonts(FontInfo fontInfo, List fontInfoList
- , int num, FontResolver resolver) {
- if (fontInfoList == null) {
+ private static void addConfiguredFonts(FontInfo fontInfo,
+ List/*<EmbedFontInfo>*/ embedFontInfoList, int num, FontResolver resolver) {
+ if (embedFontInfoList == null) {
return; //No fonts to process
}
if (resolver == null) {
//Ensure that we have minimal font resolution capabilities
- resolver = createMinimalFontResolver();
+ resolver = createMinimalFontResolver1();
}
String internalName = null;
//FontReader reader = null;
- for (int i = 0; i < fontInfoList.size(); i++) {
- EmbedFontInfo configFontInfo = (EmbedFontInfo) fontInfoList.get(i);
+ for (int i = 0; i < embedFontInfoList.size(); i++) {
+ EmbedFontInfo embedFontInfo = (EmbedFontInfo)embedFontInfoList.get(i);
- String metricsFile = configFontInfo.getMetricsFile();
+ //String metricsFile = configFontInfo.getMetricsFile();
internalName = "F" + num;
num++;
/*
@@ -222,20 +219,20 @@
reader.setFontEmbedPath(configFontInfo.getEmbedFile());
fontInfo.addMetrics(internalName, reader.getFont());
*/
- LazyFont font = new LazyFont(configFontInfo, resolver);
+
+ LazyFont font = new LazyFont(embedFontInfo, resolver);
fontInfo.addMetrics(internalName, font);
- List triplets = configFontInfo.getFontTriplets();
- for (int c = 0; c < triplets.size(); c++) {
- FontTriplet triplet = (FontTriplet) triplets.get(c);
-
+ List triplets = embedFontInfo.getFontTriplets();
+ for (int tripletIndex = 0; tripletIndex < triplets.size(); tripletIndex++) {
+ FontTriplet triplet = (FontTriplet) triplets.get(tripletIndex);
fontInfo.addFontProperties(internalName, triplet);
}
}
}
/** @return a new FontResolver to be used by the font subsystem */
- public static FontResolver createMinimalFontResolver() {
+ public static FontResolver createMinimalFontResolver1() {
return new FontResolver() {
/** {@inheritDoc} */
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontTriplet.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontTriplet.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontTriplet.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontTriplet.java Tue May 6 09:18:51 2008
@@ -38,13 +38,21 @@
private transient String key;
/**
+ * Creates a new font triplet (for base14 use).
+ * @param name font name
+ */
+ public FontTriplet(String name) {
+ this.name = name;
+ }
+
+ /**
* Creates a new font triplet.
* @param name font name
* @param style font style (normal, italic etc.)
* @param weight font weight (100, 200, 300...800, 900)
*/
public FontTriplet(String name, String style, int weight) {
- this(name, style, weight, 0);
+ this(name, style, weight, Font.PRIORITY_DEFAULT);
}
/**
@@ -55,7 +63,7 @@
* @param priority priority of this triplet/font mapping
*/
public FontTriplet(String name, String style, int weight, int priority) {
- this.name = name;
+ this(name);
this.style = style;
this.weight = weight;
this.priority = priority;
@@ -120,6 +128,5 @@
public String toString() {
return getKey();
}
-
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontUtil.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontUtil.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/FontUtil.java Tue May 6 09:18:51 2008
@@ -59,25 +59,27 @@
/**
* Removes all white space from a string (used primarily for font names)
- * @param s the string
+ * @param str the string
* @return the processed result
*/
- public static String stripWhiteSpace(String s) {
- StringBuffer sb = new StringBuffer(s.length());
- for (int i = 0, c = s.length(); i < c; i++) {
- final char ch = s.charAt(i);
- if (ch != ' '
- && ch != '\r'
- && ch != '\n'
- && ch != '\t') {
- sb.append(ch);
+ public static String stripWhiteSpace(String str) {
+ if (str != null) {
+ StringBuffer stringBuffer = new StringBuffer(str.length());
+ for (int i = 0, strLen = str.length(); i < strLen; i++) {
+ final char ch = str.charAt(i);
+ if (ch != ' ' && ch != '\r' && ch != '\n' && ch != '\t') {
+ stringBuffer.append(ch);
+ }
}
+ return stringBuffer.toString();
}
- return sb.toString();
+ return str;
}
/** font constituent names which identify a font as being of "italic" style */
- private static final String[] ITALIC_WORDS = {"italic", "oblique", "inclined"};
+ private static final String[] ITALIC_WORDS = {
+ Font.STYLE_ITALIC, Font.STYLE_OBLIQUE, Font.STYLE_INCLINED
+ };
/** font constituent names which identify a font as being of "light" weight */
private static final String[] LIGHT_WORDS = {"light"};
@@ -97,9 +99,11 @@
* @return "normal" or "italic"
*/
public static String guessStyle(String fontName) {
- for (int i = 0; i < ITALIC_WORDS.length; i++) {
- if (fontName.indexOf(ITALIC_WORDS[i]) != -1) {
- return Font.STYLE_ITALIC;
+ if (fontName != null) {
+ for (int i = 0; i < ITALIC_WORDS.length; i++) {
+ if (fontName.indexOf(ITALIC_WORDS[i]) != -1) {
+ return Font.STYLE_ITALIC;
+ }
}
}
return Font.STYLE_NORMAL;
@@ -148,6 +152,4 @@
}
return weight;
}
-
-
}
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java Tue May 6 09:18:51 2008
@@ -156,7 +156,7 @@
*
* @param dir directory to search
* @return list of font files
- * @throws IOException io exception
+ * @throws IOException thrown if an I/O exception of some sort has occurred
*/
public List find(String dir) throws IOException {
List results = new java.util.ArrayList();
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java Tue May 6 09:18:51 2008
@@ -94,9 +94,9 @@
//Full Name usually includes style/weight info so don't use these traits
//If we still want to use these traits, we have to make FontInfo.fontLookup() smarter
- triplets.add(new FontTriplet(fullName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, 0));
+ triplets.add(new FontTriplet(fullName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL));
if (!fullName.equals(strippedName)) {
- triplets.add(new FontTriplet(strippedName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL, 0));
+ triplets.add(new FontTriplet(strippedName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL));
}
Set familyNames = customFont.getFamilyNames();
Iterator iter = familyNames.iterator();
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java Tue May 6 09:18:51 2008
@@ -58,8 +58,10 @@
/** True if this LayoutManager has handled all of its content. */
private boolean bFinished = false;
- /** child LM and child LM iterator during getNextKnuthElement phase */
+ /** child LM during getNextKnuthElement phase */
protected LayoutManager curChildLM = null;
+
+ /** child LM iterator during getNextKnuthElement phase */
protected ListIterator childLMiter = null;
private int lastGeneratedPosition = -1;
Modified: xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractRendererConfigurator.java?rev=653827&r1=653826&r2=653827&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_AFPGOCAResources/src/java/org/apache/fop/render/AbstractRendererConfigurator.java Tue May 6 09:18:51 2008
@@ -45,7 +45,6 @@
super();
this.userAgent = userAgent;
}
-
/**
* Returns the configuration subtree for a specific renderer.
@@ -61,16 +60,15 @@
return null;
}
- return getRendererConfig(userAgent, mimeType);
+ return getRendererConfig(mimeType);
}
/**
* Returns the configuration subtree for a specific renderer.
- * @param userAgent the user agent containing the user configuration
* @param mimeType the MIME type of the renderer
* @return the requested configuration subtree, null if there's no configuration
*/
- public static Configuration getRendererConfig(FOUserAgent userAgent, String mimeType) {
+ private Configuration getRendererConfig(String mimeType) {
Configuration cfg = userAgent.getFactory().getUserConfig();
if (cfg == null) {
if (log.isDebugEnabled()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org