Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update #250

Merged
merged 2 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading