Skip to content

Commit

Permalink
Merge pull request #250 from metanorma/update
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
Intelligent2013 authored May 23, 2024
2 parents 42e55a9 + 60bf44f commit ae5925f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 7 deletions.
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.88.jar --xml-file <XML-FileName> --xsl-file <XSLT-FileName> --pdf-file <Output-PDF-FileName> [--syntax-highlight]
java -Xss5m -Xmx2048m -jar target/mn2pdf-1.89.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.88.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.89.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.88</version>
<version>1.89</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.88
git push origin v1.88
git tag v1.89
git push origin v1.89
----

Then the corresponding GitHub release will be automatically created at:
Expand Down
2 changes: 1 addition & 1 deletion 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.88</version>
<version>1.89</version>
<name>Metanorma XML to PDF converter</name>
<packaging>jar</packaging>
<url>https://www.metanorma.org</url>
Expand Down
28 changes: 27 additions & 1 deletion src/main/java/org/metanorma/fop/SourceXMLDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ public List<String> getDocumentFonts() {
try {
Attr attr = (Attr) nList.item(i);
for (String fname: attr.getNodeValue().split(",")) {
fname = fname.trim();
fname = fname.trim().replace("'","")
.replace("\"","");
if (!documentFontList.contains(fname)) {
documentFontList.add(fname);
}
Expand Down Expand Up @@ -178,6 +179,31 @@ public List<String> getDocumentFonts() {
} catch (Exception ex) {}
}

try {
query = xPath.compile("//*/*[local-name() = 'style'][@type = 'text/css'][contains(., 'font-family')]/text()");
String textCSS = (String)query.evaluate(srcXML, XPathConstants.STRING);
boolean foundFontFamily = true;
while (foundFontFamily) {
int fontFamilyStart = textCSS.indexOf("{font-family:");
foundFontFamily = fontFamilyStart != -1;
if (foundFontFamily) {
textCSS = textCSS.substring(fontFamilyStart);
textCSS = textCSS.substring(textCSS.indexOf(":") + 1);
if (textCSS.indexOf(";") != -1) {
String attrText = textCSS.substring(0, textCSS.indexOf(";"));
for (String fname : attrText.split(",")) {
fname = fname.trim().replace("'", "")
.replace("\"", "");
if (!documentFontList.contains(fname)) {
documentFontList.add(fname);
}
}
}
}
}
} catch (Exception ex) {
//Experimental feature
}
} catch (XPathExpressionException ex) {
logger.info(ex.toString());
}
Expand Down

0 comments on commit ae5925f

Please sign in to comment.