diff options
author | Simon Steiner <ssteiner@apache.org> | 2021-10-26 10:33:12 +0000 |
---|---|---|
committer | Simon Steiner <ssteiner@apache.org> | 2021-10-26 10:33:12 +0000 |
commit | eaeaa5cea448ff84e22071fa2c46b7e3d65fb9b4 (patch) | |
tree | 5a58c0d11052376d46578735f3e6feca53244b35 | |
parent | ef417ff708b890491bb6d65e97255ddfb1b84c38 (diff) | |
download | xmlgraphics-fop-eaeaa5cea448ff84e22071fa2c46b7e3d65fb9b4.tar.gz xmlgraphics-fop-eaeaa5cea448ff84e22071fa2c46b7e3d65fb9b4.zip |
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
-rw-r--r-- | fop-core/src/main/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java | 6 | ||||
-rw-r--r-- | fop-core/src/test/java/org/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 = "<fop version=\"1.0\">\n" + + " <renderers>\n" + + " <renderer mime=\"application/x-afp\">\n" + + " <fonts>\n" + + " <font name=\"Univers\" embed-url=\"test/resources/fonts/ttf/DejaVuLGCSerif.ttf\">\n" + + " <font-triplet name=\"Univers\" style=\"normal\" weight=\"normal\"/>\n" + + " <font-triplet name=\"any\" style=\"normal\" weight=\"normal\"/>\n" + + " </font>\n" + + " <font>\n" + + " <afp-font name=\"Times Roman\" type=\"raster\" codepage=\"T1V10500\" encoding=\"Cp500\">\n" + + " <afp-raster-font size=\"12\" characterset=\"C0N200B0\" base14-font=\"TimesRoman\"/>\n" + + " </afp-font>\n" + + " <font-triplet name=\"Times\" style=\"normal\" weight=\"normal\"/>\n" + + " </font>" + + " </fonts>\n" + + " </renderer>\n" + + " </renderers>\n" + + "</fop>"; @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" @@ -119,6 +137,58 @@ public class AFPTrueTypeTestCase { } @Test + public void testTTFMixedWithRaster() throws Exception { + String fo = "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">\n" + + " <fo:layout-master-set>\n" + + " <fo:simple-page-master master-name=\"simple\">\n" + + " <fo:region-body />\n" + + " </fo:simple-page-master>\n" + + " </fo:layout-master-set>\n" + + " <fo:page-sequence master-reference=\"simple\">\n" + + " <fo:flow flow-name=\"xsl-region-body\">\n" + + " <fo:block font-family=\"Times New Roman\">a</fo:block>\n" + + " <fo:block font-family=\"1\">a</fo:block>\n" + + " <fo:block font-family=\"2\">b</fo:block>\n" + + " <fo:block font-family=\"3\">c</fo:block>\n" + + " <fo:block font-family=\"4\">d</fo:block>" + + " </fo:flow>\n" + + " </fo:page-sequence>\n" + + "</fo:root>"; + StringBuilder sb = new StringBuilder(); + for (int i = 1; i < 5; i++) { + sb.append("<font>\n" + + " <afp-font name=\"3OF9\" type=\"raster\" codepage=\"T1V10500\" encoding=\"Cp500\">\n" + + " <afp-raster-font size=\"18\" characterset=\"C0920AB0\" base14-font=\"TimesRoman\"/>\n" + + " </afp-font>\n" + + " <font-triplet name=\"" + i + "\" style=\"normal\" weight=\"normal\"/>\n" + + "</font>"); + } + fopxconf = "<fop version=\"1.0\">\n" + + " <renderers>\n" + + " <renderer mime=\"application/x-afp\">\n" + + " <fonts>\n" + + sb.toString() + + "<font embed-url=\"test/resources/fonts/ttf/DejaVuLGCSerif.ttf\" name=\"TimesNewRomanBold\"> \n" + + " <font-triplet name=\"Times New Roman\" style=\"normal\" weight=\"bold\"/> \n" + + " <font-triplet name=\"any\" style=\"normal\" weight=\"normal\"/> \n" + + "</font>" + + " </fonts>\n" + + " </renderer>\n" + + " </renderers>\n" + + "</fop>"; + 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 = "<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\" " + "xmlns:fox=\"http://xmlgraphics.apache.org/fop/extensions\" " @@ -159,24 +229,6 @@ public class AFPTrueTypeTestCase { } private String getAFP(String fo) throws IOException, TransformerException, SAXException, URISyntaxException { - String fopxconf = "<fop version=\"1.0\">\n" - + " <renderers>\n" - + " <renderer mime=\"application/x-afp\">\n" - + " <fonts>\n" - + " <font name=\"Univers\" embed-url=\"test/resources/fonts/ttf/DejaVuLGCSerif.ttf\">\n" - + " <font-triplet name=\"Univers\" style=\"normal\" weight=\"normal\"/>\n" - + " <font-triplet name=\"any\" style=\"normal\" weight=\"normal\"/>\n" - + " </font>\n" - + " <font>\n" - + " <afp-font name=\"Times Roman\" type=\"raster\" codepage=\"T1V10500\" encoding=\"Cp500\">\n" - + " <afp-raster-font size=\"12\" characterset=\"C0N200B0\" base14-font=\"TimesRoman\"/>\n" - + " </afp-font>\n" - + " <font-triplet name=\"Times\" style=\"normal\" weight=\"normal\"/>\n" - + " </font>" - + " </fonts>\n" - + " </renderer>\n" - + " </renderers>\n" - + "</fop>"; FopFactoryBuilder confBuilder = new FopConfParser( new ByteArrayInputStream(fopxconf.getBytes()), EnvironmentalProfileFactory.createRestrictedIO(new URI("."), |