Author: ssteiner
Date: Mon Jan 16 14:07:18 2023
New Revision: 1906708

URL: http://svn.apache.org/viewvc?rev=1906708&view=rev
Log:
FOP-3114: Font size was rounded to 0 for AFP TTF

Added:
    
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/modca/ActiveEnvironmentGroupTestCase.java
   (with props)
Modified:
    
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java

Modified: 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java?rev=1906708&r1=1906707&r2=1906708&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java
 (original)
+++ 
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/afp/modca/ActiveEnvironmentGroup.java
 Mon Jan 16 14:07:18 2023
@@ -196,7 +196,7 @@ public final class ActiveEnvironmentGrou
             mdr.addTriplet(new FontFullyQualifiedNameTriplet((byte) fontRef));
 
             setupTruetypeMDR(mdr, false);
-            mdr.addTriplet(new DataObjectFontTriplet(size / 1000));
+            mdr.addTriplet(new DataObjectFontTriplet(size / 1000f));
             mdr.finishElement();
         } else {
             if (mapCodedFont == null) {
@@ -248,9 +248,9 @@ public final class ActiveEnvironmentGrou
     }
 
     static class DataObjectFontTriplet extends AbstractTriplet {
-        private int pointSize;
+        private float pointSize;
 
-        public DataObjectFontTriplet(int size) {
+        public DataObjectFontTriplet(float size) {
             super(DATA_OBJECT_FONT_DESCRIPTOR);
             pointSize = size;
         }
@@ -262,7 +262,7 @@ public final class ActiveEnvironmentGrou
         public void writeToStream(OutputStream os) throws IOException {
             byte[] data = getData();
             data[3] = 0x20;
-            byte[] pointSizeBytes = BinaryUtils.convert(pointSize * 20, 2);
+            byte[] pointSizeBytes = BinaryUtils.convert(Math.round(pointSize * 
20), 2);
             data[4] = pointSizeBytes[0]; //vfs
             data[5] = pointSizeBytes[1];
 //            data[6] = pointSizeBytes[0]; //hsf

Added: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/modca/ActiveEnvironmentGroupTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/modca/ActiveEnvironmentGroupTestCase.java?rev=1906708&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/modca/ActiveEnvironmentGroupTestCase.java
 (added)
+++ 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/modca/ActiveEnvironmentGroupTestCase.java
 Mon Jan 16 14:07:18 2023
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+package org.apache.fop.afp.modca;
+
+import java.io.ByteArrayOutputStream;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ActiveEnvironmentGroupTestCase {
+    @Test
+    public void testDataObjectFontTriplet() throws Exception {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        new 
ActiveEnvironmentGroup.DataObjectFontTriplet(0.5f).writeToStream(bos);
+        Assert.assertEquals(bos.toByteArray()[5], 10);
+    }
+}

Propchange: 
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/afp/modca/ActiveEnvironmentGroupTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org

Reply via email to