Skip to content

Commit

Permalink
Merge pull request #234 from metanorma/update_fop_2_9
Browse files Browse the repository at this point in the history
added changed from FOP 2.9, #228
  • Loading branch information
Intelligent2013 authored Mar 27, 2024
2 parents 4295027 + 27f67bb commit d9101ef
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 997 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SHELL ?= /bin/bash
endif

#JAR_VERSION := $(shell mvn -q -Dexec.executable="echo" -Dexec.args='$${project.version}' --non-recursive exec:exec -DforceStdout)
JAR_VERSION := 1.85
JAR_VERSION := 1.86
JAR_FILE := mn2pdf-$(JAR_VERSION).jar

all: target/$(JAR_FILE)
Expand Down
10 changes: 5 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ You will need the Java Development Kit (JDK) version 8, Update 241 (8u241) or hi

[source,sh]
----
java -Xss5m -Xmx2048m -jar target/mn2pdf-1.70.jar --xml-file <XML-FileName> --xsl-file <XSLT-FileName> --pdf-file <Output-PDF-FileName> [--syntax-highlight]
java -Xss5m -Xmx2048m -jar target/mn2pdf-1.86.jar --xml-file <XML-FileName> --xsl-file <XSLT-FileName> --pdf-file <Output-PDF-FileName> [--syntax-highlight]
----

e.g.

[source,sh]
----
java -Xss5m -Xmx2048m -jar target/mn2pdf-1.70.jar --xml-file tests/G.191.xml --xsl-file tests/itu.recommendation.xsl --pdf-file tests/G.191.pdf
java -Xss5m -Xmx2048m -jar target/mn2pdf-1.86.jar --xml-file tests/G.191.xml --xsl-file tests/itu.recommendation.xsl --pdf-file tests/G.191.pdf
----

=== PDF encryption features
Expand Down Expand Up @@ -100,7 +100,7 @@ Update version in `pom.xml`, e.g.:
----
<groupId>org.metanorma.fop</groupId>
<artifactId>mn2pdf</artifactId>
<version>1.85</version>
<version>1.86</version>
<name>Metanorma XML to PDF converter</name>
----

Expand All @@ -111,8 +111,8 @@ Tag the same version in Git:

[source,xml]
----
git tag v1.85
git push origin v1.85
git tag v1.86
git push origin v1.86
----

Then the corresponding GitHub release will be automatically created at:
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.metanorma.fop</groupId>
<artifactId>mn2pdf</artifactId>
<version>1.85</version>
<version>1.86</version>
<name>Metanorma XML to PDF converter</name>
<packaging>jar</packaging>
<url>https://www.metanorma.org</url>
Expand Down Expand Up @@ -140,17 +140,17 @@
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>2.8</version>
<version>2.9</version>
</dependency>
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop-pdf-images</artifactId>
<version>2.8</version>
<version>2.9</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>fontbox</artifactId>
<version>2.0.24</version>
<version>2.0.27</version>
</dependency>
<!-- https://mvnrepository.com/artifact/de.rototor.jeuclid/jeuclid-fop -->
<dependency>
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/org/apache/fop/apps/FopConfParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class FopConfParser {
private static final String PREFER_RENDERER = "prefer-renderer";
private static final String TABLE_BORDER_OVERPAINT = "table-border-overpaint";
private static final String SIMPLE_LINE_BREAKING = "simple-line-breaking";
private static final String SKIP_PAGE_POSITION_ONLY_ALLOWED = "skip-page-position-only-allowed";

private final Log log = LogFactory.getLog(FopConfParser.class);

Expand Down Expand Up @@ -290,6 +291,15 @@ private void configure(final URI baseURI, final ResourceResolver resourceResolve
}
}

if (cfg.getChild(SKIP_PAGE_POSITION_ONLY_ALLOWED, false) != null) {
try {
fopFactoryBuilder.setSkipPagePositionOnlyAllowed(
cfg.getChild(SKIP_PAGE_POSITION_ONLY_ALLOWED).getValueAsBoolean());
} catch (ConfigurationException e) {
LogUtil.handleException(log, e, false);
}
}

// configure font manager
new FontManagerConfigurator(cfg, baseURI, fopFactoryBuilder.getBaseURI(), resourceResolver)
.configure(fopFactoryBuilder.getFontManager(), strict);
Expand Down
15 changes: 10 additions & 5 deletions src/main/java/org/apache/fop/fonts/MultiByteFont.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
* limitations under the License.
*/

/* $Id: MultiByteFont.java 1886124 2021-02-02 14:48:54Z ssteiner $ */
/* $Id$ */

package org.apache.fop.fonts;

import java.awt.Rectangle;
import java.io.InputStream;
import java.nio.Buffer;
import java.nio.CharBuffer;
import java.nio.IntBuffer;
import java.util.ArrayList;
Expand Down Expand Up @@ -689,8 +690,10 @@ private GlyphSequence mapCharsToGlyphs(CharSequence cs, List associations) {
cb.put(cc);
gb.put(gi);
}
cb.flip();
gb.flip();
Buffer cbBase = cb;
cbBase.flip();
Buffer gbBase = gb;
gbBase.flip();
if ((associations != null) && (associations.size() == cs.length())) {
associations = new java.util.ArrayList(associations);
} else {
Expand Down Expand Up @@ -739,7 +742,8 @@ private CharSequence mapGlyphsToChars(GlyphSequence gs) {
cb.put(c);
}

cb.flip();
Buffer cbBase = cb;
cbBase.flip();
return cb;
}

Expand Down Expand Up @@ -806,7 +810,8 @@ private static GlyphSequence elideControls(GlyphSequence gs) {
nal.add(a);
}
}
ngb.flip();
Buffer ngbBase = ngb;
ngbBase.flip();
return new GlyphSequence(gs.getCharacters(), ngb, nal, gs.getPredications());
} else {
return gs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

/* $Id: TextLayoutManager.java 1890190 2021-05-25 09:08:58Z ssteiner $ */
/* $Id$ */

package org.apache.fop.layoutmgr.inline;

Expand Down Expand Up @@ -782,6 +782,8 @@ public List getNextKnuthElements(final LayoutContext context, final int alignmen
int level = -1;
int prevLevel = -1;
boolean retainControls = false;
Font lastFont = null;
int lastFontPos = -1;
while (nextStart < foText.length()) {
ch = foText.charAt(nextStart);
level = foText.bidiLevelAt(nextStart);
Expand Down Expand Up @@ -814,10 +816,22 @@ public List getNextKnuthElements(final LayoutContext context, final int alignmen
+ "}");
}
if (inWord) {
if (breakOpportunity
|| GlyphMapping.isSpace(ch)
|| CharUtilities.isExplicitBreak(ch)
|| ((prevLevel != -1) && (level != prevLevel))) {
boolean processWord = breakOpportunity
|| GlyphMapping.isSpace(ch)
|| CharUtilities.isExplicitBreak(ch)
|| ((prevLevel != -1) && (level != prevLevel));
if (!processWord && foText.getCommonFont().getFontSelectionStrategy() == EN_CHARACTER_BY_CHARACTER) {
if (lastFont == null || lastFontPos != nextStart - 1) {
lastFont = FontSelector.selectFontForCharactersInText(
foText, nextStart - 1, nextStart, foText, this);
}
Font font = FontSelector.selectFontForCharactersInText(
foText, nextStart, nextStart + 1, foText, this);
processWord = font != lastFont;
lastFont = font;
lastFontPos = nextStart;
}
if (processWord) {
// this.foText.charAt(lastIndex) == CharUtilities.SOFT_HYPHEN
prevMapping = processWord(alignment, sequence, prevMapping, ch,
breakOpportunity, true, prevLevel, retainControls);
Expand Down
Loading

0 comments on commit d9101ef

Please sign in to comment.