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 sp...@apache.org on 2010/10/06 09:57:40 UTC
svn commit: r1004918 - in /xmlgraphics/fop/branches/Temp_ComplexScripts: ./
src/documentation/content/xdocs/ src/documentation/content/xdocs/dev/
src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/afp/apps/
src/java/org/apache/fop/afp/fonts...
Author: spepping
Date: Wed Oct 6 07:57:40 2010
New Revision: 1004918
URL: http://svn.apache.org/viewvc?rev=1004918&view=rev
Log:
Merging changes from trunk up to revision 1004917
Added:
xmlgraphics/fop/branches/Temp_ComplexScripts/test/layoutengine/hyphenation-testcases/hyphenation-pattern_fallback.xml
- copied unchanged from r1004917, xmlgraphics/fop/trunk/test/layoutengine/hyphenation-testcases/hyphenation-pattern_fallback.xml
Modified:
xmlgraphics/fop/branches/Temp_ComplexScripts/ (props changed)
xmlgraphics/fop/branches/Temp_ComplexScripts/build.xml
xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/dev/release.xml
xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/download.xml
xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/trunk/compiling.xml
xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/trunk/configuration.xml
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/apps/ (props changed)
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/parser/ (props changed)
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/apps/FopFactory.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/hyphenation/Hyphenator.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/NativeTextPainter.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFTranscoder.java
xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/util/ColorExt.java (props changed)
xmlgraphics/fop/branches/Temp_ComplexScripts/xmlgraphics-fop-pom-template.pom
Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 6 07:57:40 2010
@@ -1,4 +1,4 @@
/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign:603620-746655
/xmlgraphics/fop/branches/fop-0_95:684572,688085,688696
/xmlgraphics/fop/branches/fop-1_0:959975-964707
-/xmlgraphics/fop/trunk:981451-998017
+/xmlgraphics/fop/trunk:981451-1004917
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/build.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/build.xml?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/build.xml (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/build.xml Wed Oct 6 07:57:40 2010
@@ -1056,7 +1056,6 @@ NOTE:
<pathelement path="${src.sandbox.dir}"/>
<pathelement path="${build.gensrc.dir}"/>
</sourcepath>
- <tag name="asf.todo" scope="all" description="To do:"/>
<tag name="event.severity" scope="all" description="Event severity level:"/>
<group title="Control and Startup">
<package name="org.apache.fop"/>
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/dev/release.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/dev/release.xml?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/dev/release.xml (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/dev/release.xml Wed Oct 6 07:57:40 2010
@@ -69,6 +69,7 @@ The purpose of documenting it here is to
<li>Update the tab names and directories in tabs.xml</li>
<li>Delete the previous version directory.</li>
<li>Update index.xml in the new version directory.</li>
+ <li>Update compiling.xml in the new version directory: change the intro for trunk to that for a release.</li>
<li>Build the dist files (<code>build[.sh] dist</code>)
and upload them to your web directory on
<code>people.apache.org</code></li>
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/download.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/download.xml?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/download.xml (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/download.xml Wed Oct 6 07:57:40 2010
@@ -51,8 +51,8 @@
<p>
Binary distributions include "-bin" in their names, and can be downloaded from a
<link href="http://www.apache.org/dyn/closer.cgi/xmlgraphics/fop">FOP Distribution mirror</link>.
- Nightly builds of trunk source code can be downloaded here:
- <link href="http://vc.apache.org/snapshots/fop/">Snapshot Trunk Builds</link>
+ Nightly builds of trunk code can be downloaded here:
+ <link href="http://ci.apache.org/projects/xmlgraphics/fop/snapshots/">Nightly Snapshots</link>.
</p>
</section>
<section id="source">
@@ -67,13 +67,12 @@
<link href="http://www.apache.org/dyn/closer.cgi/xmlgraphics/fop">FOP Distribution mirror</link>.
Source distributions include "-src" in their names.
</li>
- <!--li>
- Download a CVS snapshot from the cvs files
- <link href="http://xml.apache.org/from-cvs/xml-fop/">here</link>.
- These snapshots are built approximately every six hours, and have the GMT of
- their creation time embedded in their names. Please note that CVS snapshots
- are made only for the "redesign" branch.
- </li-->
+ <li>
+ Download a Subversion snapshot
+ <link href="http://vc.apache.org/snapshots/fop/">here</link>.
+ These snapshots are checked out from Subversion approximately every six hours, and have the GMT of
+ their creation time embedded in their names.
+ </li>
<li>
Download directly from the SVN repository.
Anyone can do this using the
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/trunk/compiling.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/trunk/compiling.xml?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/trunk/compiling.xml (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/trunk/compiling.xml Wed Oct 6 07:57:40 2010
@@ -25,16 +25,23 @@
<body>
<section id="build-needed">
<title>Do You Need To Build?</title>
- <p>
+<!-- text for released versions -->
+<!-- <p>
FOP distributions are either pre-compiled binary or source.
If you are using a binary distribution, it is already built and there is no need to build it again.
See the <a href="../download.html">Download Instructions</a> for information about whether a
binary or source distribution is best for your needs.
- </p>
+ </p>-->
+<!-- /text for released versions -->
+<!-- text for trunk -->
<p>
- If you got the source code from a repository snapshot or via Subversion you will need to build FOP
- in any case.
+ FOP snapshots are either pre-compiled binary or source.
+ If you are using a binary snapshot, it is already built and there is no need to build it again.
+ If you got the source code from a repository snapshot or via Subversion you will need to build FOP.
+ See the <a href="../download.html">Download Instructions</a> for information about where to obtain binary or repository snapshots, and whether a
+ binary or source snapshot is best for your needs.
</p>
+<!-- /text for trunk -->
</section>
<section id="env">
<title>Set Up Your Environment</title>
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/trunk/configuration.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/trunk/configuration.xml?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/trunk/configuration.xml (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/documentation/content/xdocs/trunk/configuration.xml Wed Oct 6 07:57:40 2010
@@ -89,6 +89,12 @@
</td>
<td>disabled</td>
</tr>
+ <tr>
+ <td>hyphenation-pattern</td>
+ <td>String, attribute lang, attribute country (optional)</td>
+ <td>Register a file name for the hyphenation pattern for the mentioned language and country. Language ll and country CC must both consist of two letters.</td>
+ <td>ll_CC</td>
+ </tr>
<tr>
<td>source-resolution</td>
<td>Integer, dpi</td>
@@ -215,6 +221,9 @@
<!-- default page-height and page-width, in case
value is specified as auto -->
<default-page-settings height="11in" width="8.26in"/>
+
+ <!-- Use file name nl_Bel instead of the default nl_BE -->
+ <hyphenation-pattern lang="nl" country="BE">nl_Bel</hyphenation-pattern>
<!-- etc. etc..... -->
</fop>]]></source>
Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/apps/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 6 07:57:40 2010
@@ -2,4 +2,4 @@
/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/afp/apps:603620-746655
/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/afp/apps:684572,688085,688696
/xmlgraphics/fop/branches/fop-1_0/src/java/org/apache/fop/afp/apps:959975-964707
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/apps:981451-998017
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/apps:981451-1004917
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/fonts/AFPFontCollection.java Wed Oct 6 07:57:40 2010
@@ -61,9 +61,9 @@ public class AFPFontCollection implement
List/*<FontTriplet>*/ tripletList = afpFontInfo.getFontTriplets();
for (Iterator it2 = tripletList.iterator(); it2.hasNext();) {
FontTriplet triplet = (FontTriplet)it2.next();
+ fontInfo.addMetrics("F" + num, afpFont);
fontInfo.addFontProperties("F" + num,
triplet.getName(), triplet.getStyle(), triplet.getWeight());
- fontInfo.addMetrics("F" + num, afpFont);
num++;
}
}
Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/afp/parser/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 6 07:57:40 2010
@@ -2,4 +2,4 @@
/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/afp/parser:603620-746655
/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/afp/parser:684572,688085,688696
/xmlgraphics/fop/branches/fop-1_0/src/java/org/apache/fop/afp/parser:959975-964707
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/parser:981451-998017
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/afp/parser:981451-1004917
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/apps/FopFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/apps/FopFactory.java?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/apps/FopFactory.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/apps/FopFactory.java Wed Oct 6 07:57:40 2010
@@ -26,6 +26,8 @@ import java.io.OutputStream;
import java.net.MalformedURLException;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import javax.xml.transform.Source;
@@ -109,6 +111,11 @@ public class FopFactory implements Image
private String hyphenBase = null;
/**
+ * Map of configured names of hyphenation pattern file names: ll_CC => name
+ */
+ private Map/*<String,String>*/ hyphPatNames = null;
+
+ /**
* FOP has the ability, for some FO's, to continue processing even if the
* input XSL violates that FO's content model. This is the default
* behavior for FOP. However, this flag, if set, provides the user the
@@ -407,6 +414,23 @@ public class FopFactory implements Image
}
/**
+ * @return the hyphPatNames
+ */
+ public Map getHyphPatNames() {
+ return hyphPatNames;
+ }
+
+ /**
+ * @param hyphPatNames the hyphPatNames to set
+ */
+ public void setHyphPatNames(Map hyphPatNames) {
+ if (hyphPatNames == null) {
+ hyphPatNames = new HashMap();
+ }
+ this.hyphPatNames = hyphPatNames;
+ }
+
+ /**
* Sets the URI Resolver. It is used for resolving factory-level URIs like hyphenation
* patterns and as backup for URI resolution performed during a rendering run.
* @param uriResolver the new URI resolver
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/apps/FopFactoryConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/apps/FopFactoryConfigurator.java?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/apps/FopFactoryConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/apps/FopFactoryConfigurator.java Wed Oct 6 07:57:40 2010
@@ -22,6 +22,8 @@ package org.apache.fop.apps;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
import org.xml.sax.SAXException;
@@ -35,6 +37,7 @@ import org.apache.xmlgraphics.image.load
import org.apache.xmlgraphics.image.loader.util.Penalty;
import org.apache.fop.fonts.FontManagerConfigurator;
+import org.apache.fop.hyphenation.HyphenationTreeCache;
import org.apache.fop.util.LogUtil;
/**
@@ -89,20 +92,7 @@ public class FopFactoryConfigurator {
* @param factory fop factory
* @throws FOPException fop exception
*/
- public void configure(FopFactory factory) throws FOPException {
- if (log.isDebugEnabled()) {
- log.debug("Initializing FopFactory Configuration");
- }
-
- if (cfg.getChild("accessibility", false) != null) {
- try {
- this.factory.setAccessibility(
- cfg.getChild("accessibility").getValueAsBoolean());
- } catch (ConfigurationException e) {
- throw new FOPException(e);
- }
- }
-
+ public void configure(FopFactory factory) throws FOPException { // CSOK: MethodLength
// strict configuration
if (cfg.getChild("strict-configuration", false) != null) {
try {
@@ -113,6 +103,19 @@ public class FopFactoryConfigurator {
}
}
boolean strict = factory.validateUserConfigStrictly();
+ if (log.isDebugEnabled()) {
+ log.debug("Initializing FopFactory Configuration"
+ + "with " + (strict ? "strict" : "permissive") + " validation");
+ }
+
+ if (cfg.getChild("accessibility", false) != null) {
+ try {
+ this.factory.setAccessibility(
+ cfg.getChild("accessibility").getValueAsBoolean());
+ } catch (ConfigurationException e) {
+ LogUtil.handleException(log, e, strict);
+ }
+ }
// strict fo validation
if (cfg.getChild("strict-validation", false) != null) {
@@ -142,6 +145,64 @@ public class FopFactoryConfigurator {
}
}
+ /**
+ * Read configuration elements hyphenation-pattern,
+ * construct a map ll_CC => filename, and set it on the factory
+ */
+ Configuration[] hyphPatConfig = cfg.getChildren("hyphenation-pattern");
+ if (hyphPatConfig.length != 0) {
+ Map/*<String,String>*/ hyphPatNames = new HashMap/*<String,String>*/();
+ for (int i = 0; i < hyphPatConfig.length; ++i) {
+ String lang, country, filename;
+ StringBuffer error = new StringBuffer();
+ String location = hyphPatConfig[i].getLocation();
+
+ lang = hyphPatConfig[i].getAttribute("lang", null);
+ if (lang == null) {
+ addError("The lang attribute of a hyphenation-pattern configuration"
+ + " element must exist (" + location + ")", error);
+ } else if (!lang.matches("[a-zA-Z]{2}")) {
+ addError("The lang attribute of a hyphenation-pattern configuration"
+ + " element must consist of exactly two letters ("
+ + location + ")", error);
+ }
+ lang = lang.toLowerCase();
+
+ country = hyphPatConfig[i].getAttribute("country", null);
+ if ("".equals(country)) {
+ country = null;
+ }
+ if (country != null) {
+ if (!country.matches("[a-zA-Z]{2}")) {
+ addError("The country attribute of a hyphenation-pattern configuration"
+ + " element must consist of exactly two letters ("
+ + location + ")", error);
+ }
+ country = country.toUpperCase();
+ }
+
+ filename = hyphPatConfig[i].getValue(null);
+ if (filename == null) {
+ addError("The value of a hyphenation-pattern configuration"
+ + " element may not be empty (" + location + ")", error);
+ }
+
+ if (error.length() != 0) {
+ LogUtil.handleError(log, error.toString(), strict);
+ continue;
+ }
+
+ String llccKey = HyphenationTreeCache.constructLlccKey(lang, country);
+ hyphPatNames.put(llccKey, filename);
+ if (log.isDebugEnabled()) {
+ log.debug("Using hyphenation pattern filename " + filename
+ + " for lang=\"" + lang + "\""
+ + (country != null ? ", country=\"" + country + "\"" : ""));
+ }
+ }
+ factory.setHyphPatNames(hyphPatNames);
+ }
+
// renderer options
if (cfg.getChild("source-resolution", false) != null) {
factory.setSourceResolution(
@@ -203,6 +264,13 @@ public class FopFactoryConfigurator {
configureImageLoading(cfg.getChild("image-loading", false), strict);
}
+ private static void addError(String message, StringBuffer error) {
+ if (error.length() != 0) {
+ error.append(". ");
+ }
+ error.append(message);
+ }
+
private void configureImageLoading(Configuration parent, boolean strict) throws FOPException {
if (parent == null) {
return;
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java Wed Oct 6 07:57:40 2010
@@ -20,6 +20,7 @@
package org.apache.fop.hyphenation;
import java.util.Hashtable;
+import java.util.Map;
import java.util.Set;
/**
@@ -39,7 +40,7 @@ public class HyphenationTreeCache {
* @return the HyhenationTree instance or null if it's not in the cache
*/
public HyphenationTree getHyphenationTree(String lang, String country) {
- String key = constructKey(lang, country);
+ String key = constructLlccKey(lang, country);
// first try to find it in the cache
if (hyphenTrees.containsKey(key)) {
@@ -57,7 +58,7 @@ public class HyphenationTreeCache {
* @param country the country (may be null or "none")
* @return the resulting key
*/
- public static String constructKey(String lang, String country) {
+ public static String constructLlccKey(String lang, String country) {
String key = lang;
// check whether the country code has been used
if (country != null && !country.equals("none")) {
@@ -67,6 +68,24 @@ public class HyphenationTreeCache {
}
/**
+ * If the user configured a hyphenation pattern file name
+ * for this (lang,country) value, return it. If not, return null.
+ * @param lang the language
+ * @param country the country (may be null or "none")
+ * @param hyphPatNames the map of user-configured hyphenation pattern file names
+ * @return the hyphenation pattern file name or null
+ */
+ public static String constructUserKey(String lang, String country, Map hyphPatNames) {
+ String userKey = null;
+ if (hyphPatNames != null) {
+ String key = constructLlccKey(lang, country);
+ key.replace('_', '-');
+ userKey = (String) hyphPatNames.get(key);
+ }
+ return userKey;
+ }
+
+ /**
* Cache a hyphenation tree under its key.
* @param key the key (ex. "de_CH" or "en")
* @param hTree the hyphenation tree
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/hyphenation/Hyphenator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/hyphenation/Hyphenator.java?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/hyphenation/Hyphenator.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/hyphenation/Hyphenator.java Wed Oct 6 07:57:40 2010
@@ -24,6 +24,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
+import java.util.Map;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
@@ -39,32 +40,20 @@ import org.xml.sax.InputSource;
*
* @author Carlos Villegas <ca...@uniscope.co.jp>
*/
-public class Hyphenator {
+public final class Hyphenator {
/** logging instance */
protected static Log log = LogFactory.getLog(Hyphenator.class);
private static HyphenationTreeCache hTreeCache = null;
- private HyphenationTree hyphenTree = null;
- private int remainCharCount = 2;
- private int pushCharCount = 2;
/** Enables a dump of statistics. Note: If activated content is sent to System.out! */
private static boolean statisticsDump = false;
/**
* Creates a new hyphenator.
- * @param lang the language
- * @param country the country (may be null or "none")
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
*/
- public Hyphenator(String lang, String country, int leftMin,
- int rightMin) {
- hyphenTree = getHyphenationTree(lang, country);
- remainCharCount = leftMin;
- pushCharCount = rightMin;
- }
+ private Hyphenator() { }
/** @return the default (static) hyphenation tree cache */
public static synchronized HyphenationTreeCache getHyphenationTreeCache() {
@@ -75,35 +64,76 @@ public class Hyphenator {
}
/**
- * Returns a hyphenation tree for a given language and country. The hyphenation trees are
- * cached.
+ * Returns a hyphenation tree for a given language and country,
+ * with fallback from (lang,country) to (lang).
+ * The hyphenation trees are cached.
* @param lang the language
* @param country the country (may be null or "none")
+ * @param resolver resolver to find the hyphenation files
+ * @param hyphPatNames the map with user-configured hyphenation pattern file names
* @return the hyphenation tree
*/
public static HyphenationTree getHyphenationTree(String lang,
- String country) {
- return getHyphenationTree(lang, country, null);
+ String country, HyphenationTreeResolver resolver, Map hyphPatNames) {
+ String llccKey = HyphenationTreeCache.constructLlccKey(lang, country);
+ HyphenationTreeCache cache = getHyphenationTreeCache();
+
+ // If this hyphenation tree has been registered as missing, return immediately
+ if (cache.isMissing(llccKey)) {
+ return null;
+ }
+
+ HyphenationTree hTree = getHyphenationTree2(lang, country, resolver, hyphPatNames);
+
+ // fallback to lang only
+ if (hTree == null && country != null && !country.equals("none")) {
+ String llKey = HyphenationTreeCache.constructLlccKey(lang, null);
+ if (!cache.isMissing(llKey)) {
+ hTree = getHyphenationTree2(lang, null, resolver, hyphPatNames);
+ if (hTree != null && log.isDebugEnabled()) {
+ log.debug("Couldn't find hyphenation pattern "
+ + "for lang=\"" + lang + "\",country=\"" + country + "\"."
+ + " Using general language pattern "
+ + "for lang=\"" + lang + "\" instead.");
+ }
+ if (hTree == null) {
+ // no fallback; register as missing
+ cache.noteMissing(llKey);
+ } else {
+ // also register for (lang,country)
+ cache.cache(llccKey, hTree);
+ }
+ }
+ }
+
+ if (hTree == null) {
+ // (lang,country) and (lang) tried; register as missing
+ cache.noteMissing(llccKey);
+ log.error("Couldn't find hyphenation pattern "
+ + "for lang=\"" + lang + "\""
+ + (country != null && !country.equals("none")
+ ? ",country=\"" + country + "\""
+ : "")
+ + ".");
+ }
+
+ return hTree;
}
/**
- * Returns a hyphenation tree for a given language and country. The hyphenation trees are
- * cached.
+ * Returns a hyphenation tree for a given language and country
+ * The hyphenation trees are cached.
* @param lang the language
* @param country the country (may be null or "none")
* @param resolver resolver to find the hyphenation files
+ * @param hyphPatNames the map with user-configured hyphenation pattern file names
* @return the hyphenation tree
*/
- public static HyphenationTree getHyphenationTree(String lang,
- String country, HyphenationTreeResolver resolver) {
- String key = HyphenationTreeCache.constructKey(lang, country);
+ private static HyphenationTree getHyphenationTree2(String lang,
+ String country, HyphenationTreeResolver resolver, Map hyphPatNames) {
+ String llccKey = HyphenationTreeCache.constructLlccKey(lang, country);
HyphenationTreeCache cache = getHyphenationTreeCache();
- // See if there was an error finding this hyphenation tree before
- if (cache.isMissing(key)) {
- return null;
- }
-
HyphenationTree hTree;
// first try to find it in the cache
hTree = getHyphenationTreeCache().getHyphenationTree(lang, country);
@@ -111,6 +141,11 @@ public class Hyphenator {
return hTree;
}
+ String key = HyphenationTreeCache.constructUserKey(lang, country, hyphPatNames);
+ if (key == null) {
+ key = llccKey;
+ }
+
if (resolver != null) {
hTree = getUserHyphenationTree(key, resolver);
}
@@ -120,11 +155,9 @@ public class Hyphenator {
// put it into the pattern cache
if (hTree != null) {
- cache.cache(key, hTree);
- } else {
- log.error("Couldn't find hyphenation pattern " + key);
- cache.noteMissing(key);
+ cache.cache(llccKey, hTree);
}
+
return hTree;
}
@@ -179,31 +212,11 @@ public class Hyphenator {
try {
is = getResourceStream(key);
if (is == null) {
- if (key.length() == 5) {
- String lang = key.substring(0, 2);
- is = getResourceStream(lang);
- if (is != null) {
- if (log.isDebugEnabled()) {
- log.debug("Couldn't find hyphenation pattern '"
- + key
- + "'. Using general language pattern '"
- + lang
- + "' instead.");
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Couldn't find precompiled hyphenation pattern "
- + lang + " in resources.");
- }
- return null;
- }
- } else {
- if (log.isDebugEnabled()) {
- log.debug("Couldn't find precompiled hyphenation pattern "
- + key + " in resources");
- }
- return null;
+ if (log.isDebugEnabled()) {
+ log.debug("Couldn't find precompiled hyphenation pattern "
+ + key + " in resources");
}
+ return null;
}
hTree = readHyphenationTree(is);
} finally {
@@ -335,6 +348,7 @@ public class Hyphenator {
* @param lang the language
* @param country the optional country code (may be null or "none")
* @param resolver resolver to find the hyphenation files
+ * @param hyphPatNames the map with user-configured hyphenation pattern file names
* @param word the word to hyphenate
* @param leftMin the minimum number of characters before the hyphenation point
* @param rightMin the minimum number of characters after the hyphenation point
@@ -342,121 +356,14 @@ public class Hyphenator {
*/
public static Hyphenation hyphenate(String lang, String country,
HyphenationTreeResolver resolver,
+ Map hyphPatNames,
String word,
int leftMin, int rightMin) {
- HyphenationTree hTree = getHyphenationTree(lang, country, resolver);
+ HyphenationTree hTree = getHyphenationTree(lang, country, resolver, hyphPatNames);
if (hTree == null) {
return null;
}
return hTree.hyphenate(word, leftMin, rightMin);
}
- /**
- * Hyphenates a word.
- * @param lang the language
- * @param country the optional country code (may be null or "none")
- * @param word the word to hyphenate
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
- * @return the hyphenation result
- */
- public static Hyphenation hyphenate(String lang, String country,
- String word,
- int leftMin, int rightMin) {
- return hyphenate(lang, country, null, word, leftMin, rightMin);
- }
-
- /**
- * Hyphenates a word.
- * @param lang the language
- * @param country the optional country code (may be null or "none")
- * @param resolver resolver to find the hyphenation files
- * @param word the word to hyphenate
- * @param offset the offset of the first character in the "word" character array
- * @param len the length of the word
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
- * @return the hyphenation result
- */
- public static Hyphenation hyphenate(String lang, // CSOK: ParameterNumber
- String country,
- HyphenationTreeResolver resolver,
- char[] word, int offset, int len,
- int leftMin, int rightMin) {
- HyphenationTree hTree = getHyphenationTree(lang, country, resolver);
- if (hTree == null) {
- return null;
- }
- return hTree.hyphenate(word, offset, len, leftMin, rightMin);
- }
-
- /**
- * Hyphenates a word.
- * @param lang the language
- * @param country the optional country code (may be null or "none")
- * @param word the word to hyphenate
- * @param offset the offset of the first character in the "word" character array
- * @param len the length of the word
- * @param leftMin the minimum number of characters before the hyphenation point
- * @param rightMin the minimum number of characters after the hyphenation point
- * @return the hyphenation result
- */
- public static Hyphenation hyphenate(String lang, String country,
- char[] word, int offset, int len,
- int leftMin, int rightMin) {
- return hyphenate(lang, country, null, word, offset, len, leftMin, rightMin);
- }
-
- /**
- * Sets the minimum number of characters before the hyphenation point
- * @param min the number of characters
- */
- public void setMinRemainCharCount(int min) {
- remainCharCount = min;
- }
-
- /**
- * Sets the minimum number of characters after the hyphenation point
- * @param min the number of characters
- */
- public void setMinPushCharCount(int min) {
- pushCharCount = min;
- }
-
- /**
- * Sets the language and country for the hyphenation process.
- * @param lang the language
- * @param country the country (may be null or "none")
- */
- public void setLanguage(String lang, String country) {
- hyphenTree = getHyphenationTree(lang, country);
- }
-
- /**
- * Hyphenates a word.
- * @param word the word to hyphenate
- * @param offset the offset of the first character in the "word" character array
- * @param len the length of the word
- * @return the hyphenation result
- */
- public Hyphenation hyphenate(char[] word, int offset, int len) {
- if (hyphenTree == null) {
- return null;
- }
- return hyphenTree.hyphenate(word, offset, len, remainCharCount,
- pushCharCount);
- }
-
- /**
- * Hyphenates a word.
- * @param word the word to hyphenate
- * @return the hyphenation result
- */
- public Hyphenation hyphenate(String word) {
- if (hyphenTree == null) {
- return null;
- }
- return hyphenTree.hyphenate(word, remainCharCount, pushCharCount);
- }
-
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Wed Oct 6 07:57:40 2010
@@ -1418,6 +1418,7 @@ public class LineLayoutManager extends I
= Hyphenator.hyphenate(hyphenationProperties.language.getString(),
hyphenationProperties.country.getString(),
getFObj().getUserAgent().getFactory().getHyphenationTreeResolver(),
+ getFObj().getUserAgent().getFactory().getHyphPatNames(),
sbChars.toString(),
hyphenationProperties.hyphenationRemainCharacterCount.getValue(),
hyphenationProperties.hyphenationPushCharacterCount.getValue());
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/AbstractFOPTranscoder.java Wed Oct 6 07:57:40 2010
@@ -29,6 +29,7 @@ import org.w3c.dom.DOMImplementation;
import org.xml.sax.EntityResolver;
+import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.configuration.DefaultConfiguration;
@@ -55,7 +56,7 @@ import org.apache.xmlgraphics.image.load
/**
* This is the common base class of all of FOP's transcoders.
*/
-public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder {
+public abstract class AbstractFOPTranscoder extends SVGAbstractTranscoder implements Configurable {
/**
* The key is used to specify the resolution for on-the-fly images generated
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/NativeTextPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/NativeTextPainter.java?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/NativeTextPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/NativeTextPainter.java Wed Oct 6 07:57:40 2010
@@ -111,9 +111,9 @@ public abstract class NativeTextPainter
String style = ((posture != null) && (posture.floatValue() > 0.0))
? Font.STYLE_ITALIC : Font.STYLE_NORMAL;
- int weight = ((taWeight != null)
- && (taWeight.floatValue() > 1.0)) ? Font.WEIGHT_BOLD
- : Font.WEIGHT_NORMAL;
+ int weight = toCSSWeight(taWeight != null
+ ? taWeight.floatValue()
+ : TextAttribute.WEIGHT_REGULAR.floatValue());
String firstFontFamily = null;
@@ -176,6 +176,28 @@ public abstract class NativeTextPainter
return (Font[])fonts.toArray(new Font[fonts.size()]);
}
+ private int toCSSWeight(float weight) {
+ if (weight <= TextAttribute.WEIGHT_EXTRA_LIGHT.floatValue()) {
+ return 100;
+ } else if (weight <= TextAttribute.WEIGHT_LIGHT.floatValue()) {
+ return 200;
+ } else if (weight <= TextAttribute.WEIGHT_DEMILIGHT.floatValue()) {
+ return 300;
+ } else if (weight <= TextAttribute.WEIGHT_REGULAR.floatValue()) {
+ return 400;
+ } else if (weight <= TextAttribute.WEIGHT_SEMIBOLD.floatValue()) {
+ return 500;
+ } else if (weight <= TextAttribute.WEIGHT_BOLD.floatValue()) {
+ return 600;
+ } else if (weight <= TextAttribute.WEIGHT_HEAVY.floatValue()) {
+ return 700;
+ } else if (weight <= TextAttribute.WEIGHT_EXTRABOLD.floatValue()) {
+ return 800;
+ } else {
+ return 900;
+ }
+ }
+
/**
* Collects all characters from an {@link AttributedCharacterIterator}.
* @param runaci the character iterator
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java Wed Oct 6 07:57:40 2010
@@ -25,12 +25,15 @@ import org.apache.avalon.framework.confi
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.fonts.CustomFontCollection;
+import org.apache.fop.fonts.FontCollection;
import org.apache.fop.fonts.FontEventListener;
import org.apache.fop.fonts.FontInfo;
import org.apache.fop.fonts.FontInfoConfigurator;
import org.apache.fop.fonts.FontManager;
+import org.apache.fop.fonts.FontManagerConfigurator;
import org.apache.fop.fonts.FontResolver;
-import org.apache.fop.fonts.FontSetup;
+import org.apache.fop.fonts.base14.Base14FontCollection;
import org.apache.fop.pdf.PDFDocument;
import org.apache.fop.render.pdf.PDFRendererConfigurator;
@@ -70,29 +73,30 @@ public class PDFDocumentGraphics2DConfig
*/
public static FontInfo createFontInfo(Configuration cfg) throws FOPException {
FontInfo fontInfo = new FontInfo();
+ final boolean strict = false;
+ FontResolver fontResolver = FontManager.createMinimalFontResolver();
+ //TODO The following could be optimized by retaining the FontManager somewhere
+ FontManager fontManager = new FontManager();
if (cfg != null) {
- FontResolver fontResolver = FontManager.createMinimalFontResolver();
- //TODO The following could be optimized by retaining the FontManager somewhere
- FontManager fontManager = new FontManager();
+ FontManagerConfigurator fmConfigurator = new FontManagerConfigurator(cfg);
+ fmConfigurator.configure(fontManager, strict);
+ }
- //TODO Make use of fontBaseURL, font substitution and referencing configuration
- //Requires a change to the expected configuration layout
+ List fontCollections = new java.util.ArrayList();
+ fontCollections.add(new Base14FontCollection(fontManager.isBase14KerningEnabled()));
+ if (cfg != null) {
//TODO Wire in the FontEventListener
- final FontEventListener listener = null;
- final boolean strict = false;
+ FontEventListener listener = null; //new FontEventAdapter(eventBroadcaster);
FontInfoConfigurator fontInfoConfigurator
= new FontInfoConfigurator(cfg, fontManager, fontResolver, listener, strict);
List/*<EmbedFontInfo>*/ fontInfoList = new java.util.ArrayList/*<EmbedFontInfo>*/();
fontInfoConfigurator.configure(fontInfoList);
-
- if (fontManager.useCache()) {
- fontManager.getFontCache().save();
- }
- FontSetup.setup(fontInfo, fontInfoList, fontResolver);
- } else {
- FontSetup.setup(fontInfo);
+ fontCollections.add(new CustomFontCollection(fontResolver, fontInfoList));
}
+ fontManager.setup(fontInfo,
+ (FontCollection[])fontCollections.toArray(
+ new FontCollection[fontCollections.size()]));
return fontInfo;
}
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFTranscoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFTranscoder.java?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFTranscoder.java (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/svg/PDFTranscoder.java Wed Oct 6 07:57:40 2010
@@ -27,7 +27,6 @@ import java.io.OutputStream;
import org.w3c.dom.Document;
import org.w3c.dom.svg.SVGLength;
-import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.batik.bridge.BridgeContext;
import org.apache.batik.bridge.UnitProcessor;
@@ -73,8 +72,7 @@ import org.apache.fop.fonts.FontInfo;
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
* @version $Id$
*/
-public class PDFTranscoder extends AbstractFOPTranscoder
- implements Configurable {
+public class PDFTranscoder extends AbstractFOPTranscoder {
/** Graphics2D instance that is used to paint to */
protected PDFDocumentGraphics2D graphics = null;
Propchange: xmlgraphics/fop/branches/Temp_ComplexScripts/src/java/org/apache/fop/util/ColorExt.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Oct 6 07:57:40 2010
@@ -2,4 +2,4 @@
/xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/util/ColorExt.java:745924-830281
/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/ColorExt.java:603620-746655
/xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/util/ColorExt.java:684572,688085,688696
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorExt.java:981451-998017
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorExt.java:981451-1004917
Modified: xmlgraphics/fop/branches/Temp_ComplexScripts/xmlgraphics-fop-pom-template.pom
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ComplexScripts/xmlgraphics-fop-pom-template.pom?rev=1004918&r1=1004917&r2=1004918&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ComplexScripts/xmlgraphics-fop-pom-template.pom (original)
+++ xmlgraphics/fop/branches/Temp_ComplexScripts/xmlgraphics-fop-pom-template.pom Wed Oct 6 07:57:40 2010
@@ -19,7 +19,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
-http://maven.apache.org/maven-v4_0_0.xsd">
+http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org