You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlgraphics.apache.org by "matthias8283 (via GitHub)" <gi...@apache.org> on 2025/10/10 15:12:55 UTC
[PR] FOP-3277: add font substitution support for PDFTranscoder [xmlgraphics-fop]
matthias8283 opened a new pull request, #91:
URL: https://github.com/apache/xmlgraphics-fop/pull/91
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org
Re: [PR] FOP-3277: add font substitution support for PDFTranscoder [xmlgraphics-fop]
Posted by "simonsteiner1984 (via GitHub)" <gi...@apache.org>.
simonsteiner1984 commented on PR #91:
URL: https://github.com/apache/xmlgraphics-fop/pull/91#issuecomment-3396652613
Branch name should be called temp/username-xxx
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org
Re: [PR] FOP-3277: add font substitution support for PDFTranscoder [xmlgraphics-fop]
Posted by "matthias8283 (via GitHub)" <gi...@apache.org>.
matthias8283 closed pull request #91: FOP-3277: add font substitution support for PDFTranscoder
URL: https://github.com/apache/xmlgraphics-fop/pull/91
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org
Re: [PR] FOP-3277: add font substitution support for PDFTranscoder [xmlgraphics-fop]
Posted by "simonsteiner1984 (via GitHub)" <gi...@apache.org>.
simonsteiner1984 commented on code in PR #91:
URL: https://github.com/apache/xmlgraphics-fop/pull/91#discussion_r2425663098
##########
fop-core/src/test/java/org/apache/fop/svg/BasicPDFTranscoderTestCase.java:
##########
@@ -52,4 +74,70 @@ public void testFontAutoDetect() {
autoDetectConf.getClass().getSimpleName());
}
+ @Test
+ public void testFontSubstitution() throws ConfigurationException, IOException, TranscoderException {
+
+ PDFTranscoder transcoder = (PDFTranscoder) createTranscoder();
+
+ DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
+ String cfgFragment =
+ "<pdf-renderer>"
+ + "<fonts>"
+ + "<substitutions>"
+ + "<substitution>"
+ + "<from font-family=\"Helvetica\"/>"
+ + "<to font-family=\"Courier\"/>"
+ + "</substitution>"
+ + "</substitutions>"
+ + "</fonts>"
+ + "</pdf-renderer>";
+ Configuration cfg = cfgBuilder.build(new ByteArrayInputStream(cfgFragment.getBytes()));
+ transcoder.configure(cfg);
+
+ String svgFragment = "<svg xml:space=\"preserve\" x=\"-1.70458in\" y=\"0.198315in\" "
+ + "width=\"2.6622in\" height=\"1.89672in\""
+ + " viewBox=\"-4330 0 6762 4818\" xmlns=\"http://www.w3.org/2000/svg\">"
+ + " <text x=\"-3653\" y=\"841\" style=\"fill:#1F1A17;font-size:639;font-family:Helvetica\">H</text>"
+ + "</svg>";
+ TranscoderInput input = new TranscoderInput(new ByteArrayInputStream(svgFragment.getBytes()));
+
+ File outputFile = tempFolder.newFile("output.pdf");
+ OutputStream os = new FileOutputStream(outputFile);
+ TranscoderOutput output = new TranscoderOutput(os);
+
+ try {
+ transcoder.transcode(input, output);
+ } finally {
+ os.close();
+ }
+
+ PDDocument pdfDocument = null;
+ try {
+ pdfDocument = Loader.loadPDF(outputFile);
Review Comment:
try (x pdfDocument = Loader.loadPDF(outputFile)) {
xxx
}
##########
fop-core/src/test/java/org/apache/fop/svg/BasicPDFTranscoderTestCase.java:
##########
@@ -52,4 +74,70 @@ public void testFontAutoDetect() {
autoDetectConf.getClass().getSimpleName());
}
+ @Test
+ public void testFontSubstitution() throws ConfigurationException, IOException, TranscoderException {
+
+ PDFTranscoder transcoder = (PDFTranscoder) createTranscoder();
+
+ DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
+ String cfgFragment =
+ "<pdf-renderer>"
+ + "<fonts>"
+ + "<substitutions>"
+ + "<substitution>"
+ + "<from font-family=\"Helvetica\"/>"
+ + "<to font-family=\"Courier\"/>"
+ + "</substitution>"
+ + "</substitutions>"
+ + "</fonts>"
+ + "</pdf-renderer>";
+ Configuration cfg = cfgBuilder.build(new ByteArrayInputStream(cfgFragment.getBytes()));
+ transcoder.configure(cfg);
+
+ String svgFragment = "<svg xml:space=\"preserve\" x=\"-1.70458in\" y=\"0.198315in\" "
+ + "width=\"2.6622in\" height=\"1.89672in\""
+ + " viewBox=\"-4330 0 6762 4818\" xmlns=\"http://www.w3.org/2000/svg\">"
+ + " <text x=\"-3653\" y=\"841\" style=\"fill:#1F1A17;font-size:639;font-family:Helvetica\">H</text>"
+ + "</svg>";
+ TranscoderInput input = new TranscoderInput(new ByteArrayInputStream(svgFragment.getBytes()));
+
+ File outputFile = tempFolder.newFile("output.pdf");
+ OutputStream os = new FileOutputStream(outputFile);
+ TranscoderOutput output = new TranscoderOutput(os);
+
+ try {
+ transcoder.transcode(input, output);
+ } finally {
+ os.close();
+ }
+
+ PDDocument pdfDocument = null;
+ try {
+ pdfDocument = Loader.loadPDF(outputFile);
+ FontExtractor fontExtractor = new FontExtractor();
+ fontExtractor.getText(pdfDocument);
+ assertEquals("Courier", fontExtractor.getFontUsage().get("H"));
+ } finally {
+ if (pdfDocument != null) {
+ pdfDocument.close();
+ }
+ }
+ }
+
+ class FontExtractor extends PDFTextStripper {
Review Comment:
shouldnt this be static
##########
fop-core/src/test/java/org/apache/fop/svg/BasicPDFTranscoderTestCase.java:
##########
@@ -52,4 +74,70 @@ public void testFontAutoDetect() {
autoDetectConf.getClass().getSimpleName());
}
+ @Test
+ public void testFontSubstitution() throws ConfigurationException, IOException, TranscoderException {
+
+ PDFTranscoder transcoder = (PDFTranscoder) createTranscoder();
+
+ DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
+ String cfgFragment =
+ "<pdf-renderer>"
+ + "<fonts>"
+ + "<substitutions>"
+ + "<substitution>"
+ + "<from font-family=\"Helvetica\"/>"
+ + "<to font-family=\"Courier\"/>"
+ + "</substitution>"
+ + "</substitutions>"
+ + "</fonts>"
+ + "</pdf-renderer>";
+ Configuration cfg = cfgBuilder.build(new ByteArrayInputStream(cfgFragment.getBytes()));
+ transcoder.configure(cfg);
+
+ String svgFragment = "<svg xml:space=\"preserve\" x=\"-1.70458in\" y=\"0.198315in\" "
+ + "width=\"2.6622in\" height=\"1.89672in\""
+ + " viewBox=\"-4330 0 6762 4818\" xmlns=\"http://www.w3.org/2000/svg\">"
+ + " <text x=\"-3653\" y=\"841\" style=\"fill:#1F1A17;font-size:639;font-family:Helvetica\">H</text>"
+ + "</svg>";
+ TranscoderInput input = new TranscoderInput(new ByteArrayInputStream(svgFragment.getBytes()));
+
+ File outputFile = tempFolder.newFile("output.pdf");
+ OutputStream os = new FileOutputStream(outputFile);
Review Comment:
why not a bytearrayoutputstream
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org
Re: [PR] FOP-3277: add font substitution support for PDFTranscoder [xmlgraphics-fop]
Posted by "matthias8283 (via GitHub)" <gi...@apache.org>.
matthias8283 closed pull request #91: FOP-3277: add font substitution support for PDFTranscoder
URL: https://github.com/apache/xmlgraphics-fop/pull/91
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org