pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1818374 - in /pdfbox/trunk/fontbox: pom.xml src/test/java/org/apache/fontbox/cff/CFFParserTest.java
Date Sat, 16 Dec 2017 06:08:34 GMT
Author: tilman
Date: Sat Dec 16 06:08:34 2017
New Revision: 1818374

URL: http://svn.apache.org/viewvc?rev=1818374&view=rev
Log:
PDFBOX-4038: add test by Petr Slaby; download test file into repository

Added:
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cff/CFFParserTest.java   (with props)
Modified:
    pdfbox/trunk/fontbox/pom.xml

Modified: pdfbox/trunk/fontbox/pom.xml
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/pom.xml?rev=1818374&r1=1818373&r2=1818374&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/pom.xml (original)
+++ pdfbox/trunk/fontbox/pom.xml Sat Dec 16 06:08:34 2017
@@ -1,71 +1,92 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-  <modelVersion>4.0.0</modelVersion>
-
-  <parent>
-    <groupId>org.apache.pdfbox</groupId>
-    <artifactId>pdfbox-parent</artifactId>
-    <version>3.0.0-SNAPSHOT</version>
-    <relativePath>../parent/pom.xml</relativePath>
-  </parent>
-
-  <artifactId>fontbox</artifactId>
-  <packaging>bundle</packaging>
-
-  <name>Apache FontBox</name>
-  <description>
-    The Apache FontBox library is an open source Java tool to obtain low level information
-    from font files. FontBox is a subproject of Apache PDFBox.
-  </description>
-
-  <inceptionYear>2008</inceptionYear>
-  <url>http://pdfbox.apache.org/</url>
-
-  <dependencies>
-    <dependency>
-      <groupId>commons-logging</groupId>
-      <artifactId>commons-logging</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-    </dependency>
-  </dependencies>
-
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <extensions>true</extensions>
-      </plugin>
-      <plugin>
-        <groupId>org.apache.rat</groupId>
-        <artifactId>apache-rat-plugin</artifactId>
-        <configuration>
-            <excludes>
-                <exclude>src/main/resources/org/apache/fontbox/cmap/*</exclude>
-            </excludes>
-        </configuration>
-    </plugin>
-    </plugins>
-  </build>
-
-</project>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.pdfbox</groupId>
+    <artifactId>pdfbox-parent</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+    <relativePath>../parent/pom.xml</relativePath>
+  </parent>
+
+  <artifactId>fontbox</artifactId>
+  <packaging>bundle</packaging>
+
+  <name>Apache FontBox</name>
+  <description>
+    The Apache FontBox library is an open source Java tool to obtain low level information
+    from font files. FontBox is a subproject of Apache PDFBox.
+  </description>
+
+  <inceptionYear>2008</inceptionYear>
+  <url>http://pdfbox.apache.org/</url>
+
+  <dependencies>
+    <dependency>
+      <groupId>commons-logging</groupId>
+      <artifactId>commons-logging</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.rat</groupId>
+        <artifactId>apache-rat-plugin</artifactId>
+        <configuration>
+            <excludes>
+                <exclude>src/main/resources/org/apache/fontbox/cmap/*</exclude>
+            </excludes>
+        </configuration>
+      </plugin>
+
+      <!-- download test files from JIRA and keep them in repository cache -->
+      <plugin>
+          <groupId>com.googlecode.maven-download-plugin</groupId>
+          <artifactId>download-maven-plugin</artifactId>
+          <version>1.3.0</version>
+          <executions>
+              <execution>
+                  <id>PDFBOX-4038</id>
+                  <phase>generate-test-resources</phase>
+                  <goals>
+                      <goal>wget</goal>
+                  </goals>
+                  <configuration>
+                      <url>https://issues.apache.org/jira/secure/attachment/12684264/SourceSansProBold.otf</url>
+                      <outputDirectory>${project.build.directory}/pdfs</outputDirectory>
+                      <sha512>28a044a2685fbc8da7810d9ac7b6b93a95542d504d7d8e671f009b8ebb2f5b70c974be7ea78974b188d8e6ab17d65b08f276c054927857315d5aad26f6fe36fc</sha512>
+                  </configuration>
+              </execution>
+          </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
+

Added: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cff/CFFParserTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cff/CFFParserTest.java?rev=1818374&view=auto
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cff/CFFParserTest.java (added)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cff/CFFParserTest.java Sat Dec 16
06:08:34 2017
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2017 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.fontbox.cff;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author Petr Slaby
+ */
+public class CFFParserTest
+{
+    /**
+     * PDFBOX-4038: Test whether BlueValues and other delta encoded lists are read correctly.
The
+     * test file is from FOP-2432.
+     *
+     * @throws IOException 
+     */
+    @Test
+    public void testDeltaLists() throws IOException
+    {
+        List<CFFFont> fonts = readFont(new FileInputStream("target/pdfs/SourceSansProBold.otf"));
+        CFFType1Font font = (CFFType1Font) fonts.get(0);
+        List<Number> blues = (List<Number>)font.getPrivateDict().get("BlueValues");
+
+        // Expected values found for this font
+        assertNumberList("Blue values are different than expected: " + blues.toString(),
                    
+                new int[]{-12, 0, 496, 508, 578, 590, 635, 647, 652, 664, 701, 713}, blues);
+
+        List<Number> otherBlues = (List<Number>)font.getPrivateDict().get("OtherBlues");
+        assertNumberList("Other blues are different than expected: " + otherBlues.toString(),
                    
+                new int[]{-196, -184}, otherBlues);
+
+        List<Number> familyBlues = (List<Number>)font.getPrivateDict().get("FamilyBlues");
+        assertNumberList("Other blues are different than expected: " + familyBlues.toString(),
                    
+                new int[]{-12, 0, 486, 498, 574, 586, 638, 650, 656, 668, 712, 724}, familyBlues);
+
+        List<Number> familyOtherBlues = (List<Number>)font.getPrivateDict().get("FamilyOtherBlues");
+        assertNumberList("Other blues are different than expected: " + familyOtherBlues.toString(),
                    
+                new int[]{-217, -205}, familyOtherBlues);
+
+        List<Number> stemSnapH = (List<Number>)font.getPrivateDict().get("StemSnapH");
+        assertNumberList("StemSnapH values are different than expected: " + stemSnapH.toString(),
                    
+                new int[]{115}, stemSnapH);
+
+        List<Number> stemSnapV = (List<Number>)font.getPrivateDict().get("StemSnapV");
+        assertNumberList("StemSnapV values are different than expected: " + stemSnapV.toString(),
                    
+                new int[]{146, 150}, stemSnapV);
+    }
+
+    private List<CFFFont> readFont(InputStream in) throws IOException
+    {
+        ByteArrayOutputStream content = new ByteArrayOutputStream();
+        byte[] buf = new byte[1024];
+        int len;
+        while ((len = in.read(buf)) > -1)
+        {
+            content.write(buf, 0, len);
+        }
+
+        CFFParser parser = new CFFParser();
+        return parser.parse(content.toByteArray());
+    }
+
+    private void assertNumberList(String message, int[] expected, List<Number> found)
+    {
+        assertEquals(message, expected.length, found.size());
+        for (int i = 0; i < expected.length; i++)
+        {
+            assertEquals(message, expected[i], found.get(i).intValue());
+        }
+    }
+}

Propchange: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/cff/CFFParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message