From eaeaa5cea448ff84e22071fa2c46b7e3d65fb9b4 Mon Sep 17 00:00:00 2001 From: Simon Steiner Date: Tue, 26 Oct 2021 10:33:12 +0000 Subject: FOP-3031: Add MCF before MDR in AFP git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1894576 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/afp/modca/ActiveEnvironmentGroup.java | 6 +- .../apache/fop/render/afp/AFPTrueTypeTestCase.java | 92 +++++++++++++++++----- 2 files changed, 75 insertions(+), 23 deletions(-) diff --git a/fop-core/src/main/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java b/fop-core/src/main/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java index 653229c93..687fea75f 100644 --- a/fop-core/src/main/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java +++ b/fop-core/src/main/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java @@ -73,6 +73,7 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { private final Factory factory; private MapDataResource mdr; + private MapCodedFont mapCodedFont; /** * Constructor for the ActiveEnvironmentGroup, this takes a @@ -198,17 +199,16 @@ public final class ActiveEnvironmentGroup extends AbstractEnvironmentGroup { mdr.addTriplet(new DataObjectFontTriplet(size / 1000)); mdr.finishElement(); } else { - MapCodedFont mapCodedFont = getCurrentMapCodedFont(); if (mapCodedFont == null) { mapCodedFont = factory.createMapCodedFont(); - mapCodedFonts.add(mapCodedFont); + mapCodedFonts.add(0, mapCodedFont); } try { mapCodedFont.addFont(fontRef, font, size, orientation); } catch (MaximumSizeExceededException msee) { mapCodedFont = factory.createMapCodedFont(); - mapCodedFonts.add(mapCodedFont); + mapCodedFonts.add(0, mapCodedFont); try { mapCodedFont.addFont(fontRef, font, size, orientation); diff --git a/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java b/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java index 992436b43..9a9e5bed7 100644 --- a/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java +++ b/fop-core/src/test/java/org/apache/fop/render/afp/AFPTrueTypeTestCase.java @@ -70,6 +70,24 @@ import org.apache.fop.render.intermediate.IFException; public class AFPTrueTypeTestCase { private String font; + private String fopxconf = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " " + + " \n" + + " \n" + + " \n" + + ""; @Test public void testAFPTrueType() throws IOException, SAXException, TransformerException, URISyntaxException { @@ -100,10 +118,10 @@ public class AFPTrueTypeTestCase { + "BEGIN PAGE_GROUP PGP00001\n" + "BEGIN PAGE PGN00001\n" + "BEGIN ACTIVE_ENVIRONMENT_GROUP AEG00001\n" - + "MAP DATA_RESOURCE Triplets: 0x01,FULLY_QUALIFIED_NAME,FULLY_QUALIFIED_NAME,OBJECT_CLASSIFICATION," - + "DATA_OBJECT_FONT_DESCRIPTOR,\n" + "MAP CODED_FONT Triplets: FULLY_QUALIFIED_NAME,FULLY_QUALIFIED_NAME,CHARACTER_ROTATION," + "RESOURCE_LOCAL_IDENTIFIER,\n" + + "MAP DATA_RESOURCE Triplets: 0x01,FULLY_QUALIFIED_NAME,FULLY_QUALIFIED_NAME,OBJECT_CLASSIFICATION," + + "DATA_OBJECT_FONT_DESCRIPTOR,\n" + "DESCRIPTOR PAGE\n" + "MIGRATION PRESENTATION_TEXT\n" + "END ACTIVE_ENVIRONMENT_GROUP AEG00001\n" @@ -118,6 +136,58 @@ public class AFPTrueTypeTestCase { Assert.assertEquals("test/resources/fonts/ttf/DejaVuLGCSerif.ttf", font); } + @Test + public void testTTFMixedWithRaster() throws Exception { + String fo = "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " a\n" + + " a\n" + + " b\n" + + " c\n" + + " d" + + " \n" + + " \n" + + ""; + StringBuilder sb = new StringBuilder(); + for (int i = 1; i < 5; i++) { + sb.append("\n" + + " \n" + + " \n" + + " \n" + + " \n" + + ""); + } + fopxconf = "\n" + + " \n" + + " \n" + + " \n" + + sb.toString() + + " \n" + + " \n" + + " \n" + + "" + + " \n" + + " \n" + + " \n" + + ""; + Assert.assertTrue(getAFP(fo).contains("BEGIN ACTIVE_ENVIRONMENT_GROUP AEG00001\n" + + "MAP CODED_FONT Triplets: FULLY_QUALIFIED_NAME,FULLY_QUALIFIED_NAME,CHARACTER_ROTATION," + + "RESOURCE_LOCAL_IDENTIFIER,EXTENDED_RESOURCE_LOCAL_IDENTIFIER,FULLY_QUALIFIED_NAME," + + "FULLY_QUALIFIED_NAME,CHARACTER_ROTATION,RESOURCE_LOCAL_IDENTIFIER," + + "EXTENDED_RESOURCE_LOCAL_IDENTIFIER,FULLY_QUALIFIED_NAME,FULLY_QUALIFIED_NAME,CHARACTER_ROTATION," + + "RESOURCE_LOCAL_IDENTIFIER,EXTENDED_RESOURCE_LOCAL_IDENTIFIER,FULLY_QUALIFIED_NAME," + + "FULLY_QUALIFIED_NAME,CHARACTER_ROTATION,RESOURCE_LOCAL_IDENTIFIER,\n" + + "MAP DATA_RESOURCE Triplets: 0x01,FULLY_QUALIFIED_NAME,FULLY_QUALIFIED_NAME,OBJECT_CLASSIFICATION," + + "DATA_OBJECT_FONT_DESCRIPTOR,\n" + + "DESCRIPTOR PAGE")); + } + @Test public void testSVGAFPTrueType() throws IOException, SAXException, TransformerException, URISyntaxException { String fo = "\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " " - + " \n" - + " \n" - + " \n" - + ""; FopFactoryBuilder confBuilder = new FopConfParser( new ByteArrayInputStream(fopxconf.getBytes()), EnvironmentalProfileFactory.createRestrictedIO(new URI("."), -- cgit v1.2.3