You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2020/10/25 16:38:02 UTC

svn commit: r1882845 - in /pdfbox/trunk/fontbox/src: main/java/org/apache/fontbox/afm/ test/java/org/apache/fontbox/afm/

Author: lehmi
Date: Sun Oct 25 16:38:02 2020
New Revision: 1882845

URL: http://svn.apache.org/viewvc?rev=1882845&view=rev
Log:
PDFBOX-5001:  simplify AFMParser, make some smaller classes immutable, add tests

Added:
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CharMetricTest.java   (with props)
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CompositePartTest.java   (with props)
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CompositeTest.java   (with props)
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/FontMetricsTest.java   (with props)
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/KernPairTest.java   (with props)
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/LigatureTest.java   (with props)
    pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/TrackKernTest.java   (with props)
Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/AFMParser.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/CharMetric.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/Composite.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/CompositePart.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/FontMetrics.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/KernPair.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/Ligature.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/TrackKern.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/AFMParser.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/AFMParser.java?rev=1882845&r1=1882844&r2=1882845&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/AFMParser.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/AFMParser.java Sun Oct 25 16:38:02 2020
@@ -335,13 +335,13 @@ public class AFMParser
      */
     private FontMetrics parseFontMetric(boolean reducedDataset) throws IOException
     {
-        FontMetrics fontMetrics = new FontMetrics();
         String startFontMetrics = readString();
         if( !START_FONT_METRICS.equals( startFontMetrics ) )
         {
             throw new IOException( "Error: The AFM file should start with " + START_FONT_METRICS +
                                    " and not '" + startFontMetrics + "'" );
         }
+        FontMetrics fontMetrics = new FontMetrics();
         fontMetrics.setAFMVersion( readFloat() );
         String nextCommand;
         boolean charMetricsRead = false;
@@ -442,37 +442,12 @@ public class AFMParser
                 fontMetrics.setFixedPitch( readBoolean() );
                 break;
             case START_CHAR_METRICS:
-                int countMetrics = readInt();
-                List<CharMetric> charMetrics = new ArrayList<>(countMetrics);
-                for (int i = 0; i < countMetrics; i++)
-                {
-                    CharMetric charMetric = parseCharMetric();
-                    charMetrics.add( charMetric );
-                }
-                String endCharMetrics = readString();
-                if (!endCharMetrics.equals(END_CHAR_METRICS))
-                {
-                    throw new IOException( "Error: Expected '" + END_CHAR_METRICS + "' actual '" +
-                            endCharMetrics + "'");
-                }
-                charMetricsRead = true;
-                fontMetrics.setCharMetrics(charMetrics);
+                charMetricsRead = parseCharMetrics(fontMetrics);
                 break;
             case START_COMPOSITES:
                 if( !reducedDataset)
                 {
-                    int countComposites = readInt();
-                    for (int i = 0; i < countComposites; i++)
-                    {
-                        Composite part = parseComposite();
-                        fontMetrics.addComposite( part );
-                    }
-                    String endComposites = readString();
-                    if (!endComposites.equals(END_COMPOSITES))
-                    {
-                        throw new IOException( "Error: Expected '" + END_COMPOSITES + "' actual '" +
-                                endComposites + "'");
-                    }
+                    parseComposites(fontMetrics);
                 }
                 break;
             case START_KERN_DATA:
@@ -482,11 +457,8 @@ public class AFMParser
                 }
                 break;
             default:
-                if (reducedDataset && charMetricsRead)
-                {
-                    break;
-                }
-                throw new IOException( "Unknown AFM key '" + nextCommand + "'" );
+                if (!reducedDataset || !charMetricsRead)
+                    throw new IOException("Unknown AFM key '" + nextCommand + "'");
             }
         }
         return fontMetrics;
@@ -510,13 +482,8 @@ public class AFMParser
                 int countTrackKern = readInt();
                 for (int i = 0; i < countTrackKern; i++)
                 {
-                    TrackKern kern = new TrackKern();
-                    kern.setDegree( readInt() );
-                    kern.setMinPointSize( readFloat() );
-                    kern.setMinKern( readFloat() );
-                    kern.setMaxPointSize( readFloat() );
-                    kern.setMaxKern( readFloat() );
-                    fontMetrics.addTrackKern( kern );
+                    fontMetrics.addTrackKern(new TrackKern(readInt(), readFloat(), readFloat(),
+                            readFloat(), readFloat()));
                 }
                 String endTrackKern = readString();
                 if (!endTrackKern.equals(END_TRACK_KERN))
@@ -526,46 +493,13 @@ public class AFMParser
                 }
                 break;
             case START_KERN_PAIRS:
-                int countKernPairs = readInt();
-                for (int i = 0; i < countKernPairs; i++)
-                {
-                    KernPair pair = parseKernPair();
-                    fontMetrics.addKernPair( pair );
-                }
-                String endKernPairs = readString();
-                if (!endKernPairs.equals(END_KERN_PAIRS))
-                {
-                    throw new IOException( "Error: Expected '" + END_KERN_PAIRS + "' actual '" +
-                            endKernPairs + "'");
-                }
+                parseKernPairs(fontMetrics);
                 break;
             case START_KERN_PAIRS0:
-                int countKernPairs0 = readInt();
-                for (int i = 0; i < countKernPairs0; i++)
-                {
-                    KernPair pair = parseKernPair();
-                    fontMetrics.addKernPair0( pair );
-                }
-                String endKernPairs0 = readString();
-                if (!endKernPairs0.equals(END_KERN_PAIRS))
-                {
-                    throw new IOException( "Error: Expected '" + END_KERN_PAIRS + "' actual '" +
-                            endKernPairs0 + "'");
-                }
+                parseKernPairs0(fontMetrics);
                 break;
             case START_KERN_PAIRS1:
-                int countKernPairs1 = readInt();
-                for (int i = 0; i < countKernPairs1; i++)
-                {
-                    KernPair pair = parseKernPair();
-                    fontMetrics.addKernPair1( pair );
-                }
-                String endKernPairs1 = readString();
-                if (!endKernPairs1.equals(END_KERN_PAIRS))
-                {
-                    throw new IOException( "Error: Expected '" + END_KERN_PAIRS + "' actual '" +
-                            endKernPairs1 + "'");
-                }
+                parseKernPairs1(fontMetrics);
                 break;
             default:
                 throw new IOException( "Unknown kerning data type '" + nextCommand + "'" );
@@ -573,6 +507,51 @@ public class AFMParser
         }
     }
 
+    private void parseKernPairs(FontMetrics fontMetrics) throws IOException
+    {
+        int countKernPairs = readInt();
+        for (int i = 0; i < countKernPairs; i++)
+        {
+            fontMetrics.addKernPair(parseKernPair());
+        }
+        String endKernPairs = readString();
+        if (!endKernPairs.equals(END_KERN_PAIRS))
+        {
+            throw new IOException(
+                    "Error: Expected '" + END_KERN_PAIRS + "' actual '" + endKernPairs + "'");
+        }
+    }
+
+    private void parseKernPairs0(FontMetrics fontMetrics) throws IOException
+    {
+        int countKernPairs = readInt();
+        for (int i = 0; i < countKernPairs; i++)
+        {
+            fontMetrics.addKernPair0(parseKernPair());
+        }
+        String endKernPairs = readString();
+        if (!endKernPairs.equals(END_KERN_PAIRS))
+        {
+            throw new IOException(
+                    "Error: Expected '" + END_KERN_PAIRS + "' actual '" + endKernPairs + "'");
+        }
+    }
+
+    private void parseKernPairs1(FontMetrics fontMetrics) throws IOException
+    {
+        int countKernPairs = readInt();
+        for (int i = 0; i < countKernPairs; i++)
+        {
+            fontMetrics.addKernPair1(parseKernPair());
+        }
+        String endKernPairs = readString();
+        if (!endKernPairs.equals(END_KERN_PAIRS))
+        {
+            throw new IOException(
+                    "Error: Expected '" + END_KERN_PAIRS + "' actual '" + endKernPairs + "'");
+        }
+    }
+
     /**
      * This will parse a kern pair from the data stream.
      *
@@ -582,38 +561,24 @@ public class AFMParser
      */
     private KernPair parseKernPair() throws IOException
     {
-        KernPair kernPair = new KernPair();
         String cmd = readString();
-        switch(cmd)
+        switch (cmd)
         {
         case KERN_PAIR_KP:
-            kernPair.setFirstKernCharacter(readString());
-            kernPair.setSecondKernCharacter(readString());
-            kernPair.setX(readFloat());
-            kernPair.setY(readFloat());
-            break;
+            return new KernPair(readString(), readString(), //
+                    readFloat(), readFloat());
         case KERN_PAIR_KPH:
-            kernPair.setFirstKernCharacter(hexToString(readString()));
-            kernPair.setSecondKernCharacter(hexToString(readString()));
-            kernPair.setX(readFloat());
-            kernPair.setY(readFloat());
-            break;
+            return new KernPair(hexToString(readString()), hexToString(readString()), //
+                    readFloat(), readFloat());
         case KERN_PAIR_KPX:
-            kernPair.setFirstKernCharacter(readString());
-            kernPair.setSecondKernCharacter(readString());
-            kernPair.setX(readFloat());
-            kernPair.setY( 0 );
-            break;
+            return new KernPair(readString(), readString(), //
+                    readFloat(), 0);
         case KERN_PAIR_KPY:
-            kernPair.setFirstKernCharacter(readString());
-            kernPair.setSecondKernCharacter(readString());
-            kernPair.setX( 0 );
-            kernPair.setY(readFloat());
-            break;
+            return new KernPair(readString(), readString(), //
+                    0, readFloat());
         default:
             throw new IOException( "Error expected kern pair command actual='" + cmd + "'" );
         }
-        return kernPair;
     }
 
     /**
@@ -625,18 +590,18 @@ public class AFMParser
      *
      * @throws IOException If the string is in an invalid format.
      */
-    private String hexToString( String hexString ) throws IOException
+    private String hexToString(String hexToString) throws IOException
     {
-        if( hexString.length() < 2 )
+        if (hexToString.length() < 2)
         {
-            throw new IOException( "Error: Expected hex string of length >= 2 not='" + hexString );
+            throw new IOException("Error: Expected hex string of length >= 2 not='" + hexToString);
         }
-        if( hexString.charAt( 0 ) != '<' ||
-            hexString.charAt( hexString.length() -1 ) != '>' )
+        if (hexToString.charAt(0) != '<' || hexToString.charAt(hexToString.length() - 1) != '>')
         {
-            throw new IOException( "String should be enclosed by angle brackets '" + hexString+ "'" );
+            throw new IOException(
+                    "String should be enclosed by angle brackets '" + hexToString + "'");
         }
-        hexString = hexString.substring( 1, hexString.length() -1 );
+        String hexString = hexToString.substring(1, hexToString.length() - 1);
         byte[] data = new byte[hexString.length() / 2];
         for( int i=0; i<hexString.length(); i+=2 )
         {
@@ -653,6 +618,21 @@ public class AFMParser
         return new String( data, StandardCharsets.ISO_8859_1 );
     }
 
+    private void parseComposites(FontMetrics fontMetrics) throws IOException
+    {
+        int countComposites = readInt();
+        for (int i = 0; i < countComposites; i++)
+        {
+            fontMetrics.addComposite(parseComposite());
+        }
+        String endComposites = readString();
+        if (!endComposites.equals(END_COMPOSITES))
+        {
+            throw new IOException(
+                    "Error: Expected '" + END_COMPOSITES + "' actual '" + endComposites + "'");
+        }
+    }
+
     /**
      * This will parse a composite part from the stream.
      *
@@ -662,7 +642,6 @@ public class AFMParser
      */
     private Composite parseComposite() throws IOException
     {
-        Composite composite = new Composite();
         String partData = readLine();
         StringTokenizer tokenizer = new StringTokenizer( partData, " ;" );
 
@@ -673,7 +652,7 @@ public class AFMParser
             throw new IOException( "Expected '" + CC + "' actual='" + cc + "'" );
         }
         String name = tokenizer.nextToken();
-        composite.setName( name );
+        Composite composite = new Composite(name);
 
         int partCount;
         try
@@ -686,7 +665,6 @@ public class AFMParser
         }
         for( int i=0; i<partCount; i++ )
         {
-            CompositePart part = new CompositePart();
             String pcc = tokenizer.nextToken();
             if( !pcc.equals( PCC ) )
             {
@@ -697,11 +675,7 @@ public class AFMParser
             {
                 int x = Integer.parseInt( tokenizer.nextToken() );
                 int y = Integer.parseInt( tokenizer.nextToken() );
-
-                part.setName( partName );
-                part.setXDisplacement( x );
-                part.setYDisplacement( y );
-                composite.addPart( part );
+                composite.addPart(new CompositePart(partName, x, y));
             }
             catch( NumberFormatException e )
             {
@@ -711,6 +685,25 @@ public class AFMParser
         return composite;
     }
 
+    private boolean parseCharMetrics(FontMetrics fontMetrics) throws IOException
+    {
+        int countMetrics = readInt();
+        List<CharMetric> charMetrics = new ArrayList<>(countMetrics);
+        for (int i = 0; i < countMetrics; i++)
+        {
+            CharMetric charMetric = parseCharMetric();
+            charMetrics.add(charMetric);
+        }
+        String endCharMetrics = readString();
+        if (!endCharMetrics.equals(END_CHAR_METRICS))
+        {
+            throw new IOException(
+                    "Error: Expected '" + END_CHAR_METRICS + "' actual '" + endCharMetrics + "'");
+        }
+        fontMetrics.setCharMetrics(charMetrics);
+        return true;
+    }
+
     /**
      * This will parse a single CharMetric object from the stream.
      *
@@ -808,9 +801,8 @@ public class AFMParser
                     verifySemicolon( metricsTokenizer );
                     break;
                 case CHARMETRICS_L:
-                    Ligature lig = new Ligature();
-                    lig.setSuccessor(metricsTokenizer.nextToken());
-                    lig.setLigature(metricsTokenizer.nextToken());
+                    Ligature lig = new Ligature(metricsTokenizer.nextToken(),
+                            metricsTokenizer.nextToken());
                     charMetric.addLigature( lig );
                     verifySemicolon( metricsTokenizer );
                     break;
@@ -857,8 +849,7 @@ public class AFMParser
      */
     private boolean readBoolean() throws IOException
     {
-        String theBoolean = readString();
-        return Boolean.valueOf( theBoolean );
+        return Boolean.valueOf(readString());
     }
 
     /**
@@ -868,10 +859,9 @@ public class AFMParser
      */
     private int readInt() throws IOException
     {
-        String theInt = readString();
         try
         {
-            return Integer.parseInt( theInt );
+            return Integer.parseInt(readString());
         }
         catch( NumberFormatException e )
         {
@@ -886,8 +876,7 @@ public class AFMParser
      */
     private float readFloat() throws IOException
     {
-        String theFloat = readString();
-        return Float.parseFloat( theFloat );
+        return Float.parseFloat(readString());
     }
 
     /**

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/CharMetric.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/CharMetric.java?rev=1882845&r1=1882844&r2=1882845&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/CharMetric.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/CharMetric.java Sun Oct 25 16:38:02 2020
@@ -17,6 +17,7 @@
 package org.apache.fontbox.afm;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.fontbox.util.BoundingBox;
@@ -45,7 +46,7 @@ public class CharMetric
 
     private String name;
     private BoundingBox boundingBox;
-    private List<Ligature> ligatures = new ArrayList<>();
+    private final List<Ligature> ligatures = new ArrayList<>();
 
     /** Getter for property boundingBox.
      * @return Value of property boundingBox.
@@ -94,15 +95,7 @@ public class CharMetric
      */
     public List<Ligature> getLigatures()
     {
-        return ligatures;
-    }
-
-    /** Setter for property ligatures.
-     * @param lig New value of property ligatures.
-     */
-    public void setLigatures(List<Ligature> lig)
-    {
-        this.ligatures = lig;
+        return Collections.unmodifiableList(ligatures);
     }
 
     /** Getter for property name.

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/Composite.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/Composite.java?rev=1882845&r1=1882844&r2=1882845&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/Composite.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/Composite.java Sun Oct 25 16:38:02 2020
@@ -17,6 +17,7 @@
 package org.apache.fontbox.afm;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 /**
@@ -26,8 +27,13 @@ import java.util.List;
  */
 public class Composite
 {
-    private String name;
-    private List<CompositePart> parts = new ArrayList<>();
+    private final String name;
+    private final List<CompositePart> parts = new ArrayList<>();
+
+    public Composite(String name)
+    {
+        this.name = name;
+    }
 
     /** Getter for property name.
      * @return Value of property name.
@@ -37,14 +43,6 @@ public class Composite
         return name;
     }
 
-    /** Setter for property name.
-     * @param nameValue New value of property name.
-     */
-    public void setName(String nameValue)
-    {
-        this.name = nameValue;
-    }
-
     /**
      * This will add a composite part.
      *
@@ -60,15 +58,6 @@ public class Composite
      */
     public List<CompositePart> getParts()
     {
-        return parts;
-    }
-
-    /** Setter for property parts.
-     * @param partsList New value of property parts.
-     */
-    public void setParts(List<CompositePart> partsList)
-    {
-        this.parts = partsList;
+        return Collections.unmodifiableList(parts);
     }
-
 }
\ No newline at end of file

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/CompositePart.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/CompositePart.java?rev=1882845&r1=1882844&r2=1882845&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/CompositePart.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/CompositePart.java Sun Oct 25 16:38:02 2020
@@ -23,26 +23,25 @@ package org.apache.fontbox.afm;
  */
 public class CompositePart
 {
-    private String name;
-    private int xDisplacement;
-    private int yDisplacement;
+    private final String name;
+    private final int xDisplacement;
+    private final int yDisplacement;
+
+    public CompositePart(String name, int xDisplacement, int yDisplacement)
+    {
+        this.name = name;
+        this.xDisplacement = xDisplacement;
+        this.yDisplacement = yDisplacement;
+    }
 
     /** Getter for property name.
      * @return Value of property name.
      */
-    public java.lang.String getName()
+    public String getName()
     {
         return name;
     }
 
-    /** Setter for property name.
-     * @param nameValue New value of property name.
-     */
-    public void setName(String nameValue)
-    {
-        name = nameValue;
-    }
-
     /** Getter for property xDisplacement.
      * @return Value of property xDisplacement.
      */
@@ -51,14 +50,6 @@ public class CompositePart
         return xDisplacement;
     }
 
-    /** Setter for property xDisplacement.
-     * @param xDisp New value of property xDisplacement.
-     */
-    public void setXDisplacement(int xDisp)
-    {
-        xDisplacement = xDisp;
-    }
-
     /** Getter for property yDisplacement.
      * @return Value of property yDisplacement.
      */
@@ -66,13 +57,4 @@ public class CompositePart
     {
         return yDisplacement;
     }
-
-    /** Setter for property yDisplacement.
-     * @param yDisp New value of property yDisplacement.
-     */
-    public void setYDisplacement(int yDisp)
-    {
-        yDisplacement = yDisp;
-    }
-
 }
\ No newline at end of file

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/FontMetrics.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/FontMetrics.java?rev=1882845&r1=1882844&r2=1882845&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/FontMetrics.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/FontMetrics.java Sun Oct 25 16:38:02 2020
@@ -67,11 +67,11 @@ public class FontMetrics
 
     private List<CharMetric> charMetrics = new ArrayList<>();
     private Map<String,CharMetric> charMetricsMap = new HashMap<>();
-    private List<TrackKern> trackKern = new ArrayList<>();
-    private List<Composite> composites = new ArrayList<>();
-    private List<KernPair> kernPairs = new ArrayList<>();
-    private List<KernPair> kernPairs0 = new ArrayList<>();
-    private List<KernPair> kernPairs1 = new ArrayList<>();
+    private final List<TrackKern> trackKern = new ArrayList<>();
+    private final List<Composite> composites = new ArrayList<>();
+    private final List<KernPair> kernPairs = new ArrayList<>();
+    private final List<KernPair> kernPairs0 = new ArrayList<>();
+    private final List<KernPair> kernPairs1 = new ArrayList<>();
 
     /**
      * Constructor.
@@ -730,14 +730,6 @@ public class FontMetrics
         return Collections.unmodifiableList(trackKern);
     }
 
-    /** Setter for property trackKern.
-     * @param trackKernValue New value of property trackKern.
-     */
-    public void setTrackKern(List<TrackKern> trackKernValue)
-    {
-        trackKern = trackKernValue;
-    }
-
     /**
      * This will add another track kern.
      *
@@ -756,14 +748,6 @@ public class FontMetrics
         return Collections.unmodifiableList(composites);
     }
 
-    /** Setter for property composites.
-     * @param compositesList New value of property composites.
-     */
-    public void setComposites(List<Composite> compositesList)
-    {
-        composites = compositesList;
-    }
-
     /**
      * This will add a single composite part to the picture.
      *
@@ -792,14 +776,6 @@ public class FontMetrics
         kernPairs.add( kernPair );
     }
 
-    /** Setter for property kernPairs.
-     * @param kernPairsList New value of property kernPairs.
-     */
-    public void setKernPairs(List<KernPair> kernPairsList)
-    {
-        kernPairs = kernPairsList;
-    }
-
     /** Getter for property kernPairs0.
      * @return Value of property kernPairs0.
      */
@@ -818,14 +794,6 @@ public class FontMetrics
         kernPairs0.add( kernPair );
     }
 
-    /** Setter for property kernPairs0.
-     * @param kernPairs0List New value of property kernPairs0.
-     */
-    public void setKernPairs0(List<KernPair> kernPairs0List)
-    {
-        kernPairs0 = kernPairs0List;
-    }
-
     /** Getter for property kernPairs1.
      * @return Value of property kernPairs1.
      */
@@ -844,14 +812,6 @@ public class FontMetrics
         kernPairs1.add( kernPair );
     }
 
-    /** Setter for property kernPairs1.
-     * @param kernPairs1List New value of property kernPairs1.
-     */
-    public void setKernPairs1(List<KernPair> kernPairs1List)
-    {
-        kernPairs1 = kernPairs1List;
-    }
-
     /** Getter for property standardHorizontalWidth.
      * @return Value of property standardHorizontalWidth.
      */

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/KernPair.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/KernPair.java?rev=1882845&r1=1882844&r2=1882845&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/KernPair.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/KernPair.java Sun Oct 25 16:38:02 2020
@@ -23,43 +23,35 @@ package org.apache.fontbox.afm;
  */
 public class KernPair
 {
-    private String firstKernCharacter;
-    private String secondKernCharacter;
-    private float x;
-    private float y;
+    private final String firstKernCharacter;
+    private final String secondKernCharacter;
+    private final float x;
+    private final float y;
+
+    public KernPair(String firstKernCharacter, String secondKernCharacter, float x, float y)
+    {
+        this.firstKernCharacter = firstKernCharacter;
+        this.secondKernCharacter = secondKernCharacter;
+        this.x = x;
+        this.y = y;
+    }
 
     /** Getter for property firstKernCharacter.
      * @return Value of property firstKernCharacter.
      */
-    public java.lang.String getFirstKernCharacter()
+    public String getFirstKernCharacter()
     {
         return firstKernCharacter;
     }
 
-    /** Setter for property firstKernCharacter.
-     * @param firstKernCharacterValue New value of property firstKernCharacter.
-     */
-    public void setFirstKernCharacter(String firstKernCharacterValue)
-    {
-        firstKernCharacter = firstKernCharacterValue;
-    }
-
     /** Getter for property secondKernCharacter.
      * @return Value of property secondKernCharacter.
      */
-    public java.lang.String getSecondKernCharacter()
+    public String getSecondKernCharacter()
     {
         return secondKernCharacter;
     }
 
-    /** Setter for property secondKernCharacter.
-     * @param secondKernCharacterValue New value of property secondKernCharacter.
-     */
-    public void setSecondKernCharacter(String secondKernCharacterValue)
-    {
-        secondKernCharacter = secondKernCharacterValue;
-    }
-
     /** Getter for property x.
      * @return Value of property x.
      */
@@ -68,14 +60,6 @@ public class KernPair
         return x;
     }
 
-    /** Setter for property x.
-     * @param xValue New value of property x.
-     */
-    public void setX(float xValue)
-    {
-        x = xValue;
-    }
-
     /** Getter for property y.
      * @return Value of property y.
      */
@@ -83,13 +67,4 @@ public class KernPair
     {
         return y;
     }
-
-    /** Setter for property y.
-     * @param yValue New value of property y.
-     */
-    public void setY(float yValue)
-    {
-        y = yValue;
-    }
-
 }
\ No newline at end of file

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/Ligature.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/Ligature.java?rev=1882845&r1=1882844&r2=1882845&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/Ligature.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/Ligature.java Sun Oct 25 16:38:02 2020
@@ -23,23 +23,21 @@ package org.apache.fontbox.afm;
  */
 public class Ligature
 {
-    private String successor;
-    private String ligature;
+    private final String successor;
+    private final String liga;
 
-    /** Getter for property ligature.
-     * @return Value of property ligature.
-     */
-    public String getLigature()
+    public Ligature(String successor, String ligature)
     {
-        return ligature;
+        this.successor = successor;
+        this.liga = ligature;
     }
 
-    /** Setter for property ligature.
-     * @param lig New value of property ligature.
+    /** Getter for property ligature.
+     * @return Value of property ligature.
      */
-    public void setLigature(String lig)
+    public String getLigature()
     {
-        ligature = lig;
+        return liga;
     }
 
     /** Getter for property successor.
@@ -50,12 +48,4 @@ public class Ligature
         return successor;
     }
 
-    /** Setter for property successor.
-     * @param successorValue New value of property successor.
-     */
-    public void setSuccessor(String successorValue)
-    {
-        successor = successorValue;
-    }
-
 }
\ No newline at end of file

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/TrackKern.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/TrackKern.java?rev=1882845&r1=1882844&r2=1882845&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/TrackKern.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/afm/TrackKern.java Sun Oct 25 16:38:02 2020
@@ -23,11 +23,21 @@ package org.apache.fontbox.afm;
  */
 public class TrackKern
 {
-    private int degree;
-    private float minPointSize;
-    private float minKern;
-    private float maxPointSize;
-    private float maxKern;
+    private final int degree;
+    private final float minPointSize;
+    private final float minKern;
+    private final float maxPointSize;
+    private final float maxKern;
+
+    public TrackKern(int degree, float minPointSize, float minKern, float maxPointSize,
+            float maxKern)
+    {
+        this.degree = degree;
+        this.minPointSize = minPointSize;
+        this.minKern = minKern;
+        this.maxPointSize = maxPointSize;
+        this.maxKern = maxKern;
+    }
 
     /** Getter for property degree.
      * @return Value of property degree.
@@ -37,14 +47,6 @@ public class TrackKern
         return degree;
     }
 
-    /** Setter for property degree.
-     * @param degreeValue New value of property degree.
-     */
-    public void setDegree(int degreeValue)
-    {
-        degree = degreeValue;
-    }
-
     /** Getter for property maxKern.
      * @return Value of property maxKern.
      */
@@ -53,14 +55,6 @@ public class TrackKern
         return maxKern;
     }
 
-    /** Setter for property maxKern.
-     * @param maxKernValue New value of property maxKern.
-     */
-    public void setMaxKern(float maxKernValue)
-    {
-        maxKern = maxKernValue;
-    }
-
     /** Getter for property maxPointSize.
      * @return Value of property maxPointSize.
      */
@@ -69,14 +63,6 @@ public class TrackKern
         return maxPointSize;
     }
 
-    /** Setter for property maxPointSize.
-     * @param maxPointSizeValue New value of property maxPointSize.
-     */
-    public void setMaxPointSize(float maxPointSizeValue)
-    {
-        maxPointSize = maxPointSizeValue;
-    }
-
     /** Getter for property minKern.
      * @return Value of property minKern.
      */
@@ -85,14 +71,6 @@ public class TrackKern
         return minKern;
     }
 
-    /** Setter for property minKern.
-     * @param minKernValue New value of property minKern.
-     */
-    public void setMinKern(float minKernValue)
-    {
-        minKern = minKernValue;
-    }
-
     /** Getter for property minPointSize.
      * @return Value of property minPointSize.
      */
@@ -100,13 +78,4 @@ public class TrackKern
     {
         return minPointSize;
     }
-
-    /** Setter for property minPointSize.
-     * @param minPointSizeValue New value of property minPointSize.
-     */
-    public void setMinPointSize(float minPointSizeValue)
-    {
-        minPointSize = minPointSizeValue;
-    }
-
 }
\ No newline at end of file

Added: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CharMetricTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CharMetricTest.java?rev=1882845&view=auto
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CharMetricTest.java (added)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CharMetricTest.java Sun Oct 25 16:38:02 2020
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+package org.apache.fontbox.afm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.apache.fontbox.util.BoundingBox;
+import org.junit.Test;
+
+public class CharMetricTest
+{
+    @Test
+    public void testCharMetricSimpleValues()
+    {
+        CharMetric charMetric = new CharMetric();
+        charMetric.setCharacterCode(0);
+        charMetric.setName("name");
+        charMetric.setWx(10f);
+        charMetric.setW0x(20f);
+        charMetric.setW1x(30f);
+        charMetric.setWy(40f);
+        charMetric.setW0y(50f);
+        charMetric.setW1y(60f);
+
+        assertEquals(0, charMetric.getCharacterCode());
+        assertEquals("name", charMetric.getName());
+        assertEquals(10f, charMetric.getWx(), 0.0f);
+        assertEquals(20f, charMetric.getW0x(), 0.0f);
+        assertEquals(30f, charMetric.getW1x(), 0.0f);
+        assertEquals(40f, charMetric.getWy(), 0.0f);
+        assertEquals(50f, charMetric.getW0y(), 0.0f);
+        assertEquals(60f, charMetric.getW1y(), 0.0f);
+    }
+
+    @Test
+    public void testCharMetricArrayValues()
+    {
+        CharMetric charMetric = new CharMetric();
+        charMetric.setW(new float[] { 10f, 20f });
+        charMetric.setW0(new float[] { 30f, 40f });
+        charMetric.setW1(new float[] { 50f, 60f });
+        charMetric.setVv(new float[] { 70f, 80f });
+        assertEquals(10f, charMetric.getW()[0], 0.0f);
+        assertEquals(20f, charMetric.getW()[1], 0.0f);
+        assertEquals(30f, charMetric.getW0()[0], 0.0f);
+        assertEquals(40f, charMetric.getW0()[1], 0.0f);
+        assertEquals(50f, charMetric.getW1()[0], 0.0f);
+        assertEquals(60f, charMetric.getW1()[1], 0.0f);
+        assertEquals(70f, charMetric.getVv()[0], 0.0f);
+        assertEquals(80f, charMetric.getVv()[1], 0.0f);
+    }
+
+    @Test
+    public void testCharMetricComplexValues()
+    {
+        CharMetric charMetric = new CharMetric();
+        charMetric.setBoundingBox(new BoundingBox(10, 20, 30, 40));
+        assertEquals(10, charMetric.getBoundingBox().getLowerLeftX(), 0);
+        assertEquals(20, charMetric.getBoundingBox().getLowerLeftY(), 0);
+        assertEquals(30, charMetric.getBoundingBox().getUpperRightX(), 0);
+        assertEquals(40, charMetric.getBoundingBox().getUpperRightY(), 0);
+
+        assertEquals(0, charMetric.getLigatures().size());
+        charMetric.addLigature(new Ligature("successor", "ligature"));
+        assertEquals(1, charMetric.getLigatures().size());
+        assertEquals("successor", charMetric.getLigatures().get(0).getSuccessor());
+        try
+        {
+            charMetric.getLigatures().add(new Ligature("successor", "ligature"));
+            fail("An UnsupportedOperationException should have been thrown");
+        }
+        catch (UnsupportedOperationException exception)
+        {
+            // do nothing
+        }
+    }
+}

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

Added: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CompositePartTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CompositePartTest.java?rev=1882845&view=auto
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CompositePartTest.java (added)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CompositePartTest.java Sun Oct 25 16:38:02 2020
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+
+package org.apache.fontbox.afm;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class CompositePartTest
+{
+    @Test
+    public void testCompositePart()
+    {
+        CompositePart compositePart = new CompositePart("name", 10, 20);
+        assertEquals("name", compositePart.getName());
+        assertEquals(10, compositePart.getXDisplacement());
+        assertEquals(20, compositePart.getYDisplacement());
+    }
+}

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

Added: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CompositeTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CompositeTest.java?rev=1882845&view=auto
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CompositeTest.java (added)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/CompositeTest.java Sun Oct 25 16:38:02 2020
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+package org.apache.fontbox.afm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
+public class CompositeTest
+{
+    @Test
+    public void testComposite()
+    {
+        Composite composite = new Composite("name");
+        assertEquals("name", composite.getName());
+        assertEquals(0, composite.getParts().size());
+        composite.addPart(new CompositePart("name", 10, 20));
+        assertEquals(1, composite.getParts().size());
+        assertEquals("name", composite.getParts().get(0).getName());
+        try
+        {
+            composite.getParts().add(new CompositePart("name", 10, 20));
+            fail("An UnsupportedOperationException should have been thrown");
+        }
+        catch (UnsupportedOperationException exception)
+        {
+            // do nothing
+        }
+    }
+}

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

Added: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/FontMetricsTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/FontMetricsTest.java?rev=1882845&view=auto
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/FontMetricsTest.java (added)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/FontMetricsTest.java Sun Oct 25 16:38:02 2020
@@ -0,0 +1,211 @@
+/*
+ * 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.
+ */
+
+package org.apache.fontbox.afm;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.apache.fontbox.util.BoundingBox;
+import org.junit.Test;
+
+public class FontMetricsTest
+{
+    @Test
+    public void testFontMetricsNames()
+    {
+        FontMetrics fontMetrics = new FontMetrics();
+        fontMetrics.setFontName("fontName");
+        fontMetrics.setFamilyName("familyName");
+        fontMetrics.setFullName("fullName");
+        fontMetrics.setFontVersion("fontVersion");
+        fontMetrics.setNotice("notice");
+        assertEquals("fontName", fontMetrics.getFontName());
+        assertEquals("familyName", fontMetrics.getFamilyName());
+        assertEquals("fullName", fontMetrics.getFullName());
+        assertEquals("fontVersion", fontMetrics.getFontVersion());
+        assertEquals("notice", fontMetrics.getNotice());
+
+        assertEquals(0, fontMetrics.getComments().size());
+        fontMetrics.addComment("comment");
+        assertEquals(1, fontMetrics.getComments().size());
+        try
+        {
+            fontMetrics.getComments().add("comment");
+            fail("An UnsupportedOperationException should have been thrown");
+        }
+        catch (UnsupportedOperationException exception)
+        {
+            // do nothing
+        }
+    }
+
+    @Test
+    public void testFontMetricsSimpleValues()
+    {
+        FontMetrics fontMetrics = new FontMetrics();
+        fontMetrics.setWeight("weight");
+        fontMetrics.setEncodingScheme("encodingScheme");
+        fontMetrics.setMappingScheme(0);
+        fontMetrics.setEscChar(0);
+        fontMetrics.setCharacterSet("characterSet");
+        fontMetrics.setCharacters(10);
+        fontMetrics.setIsBaseFont(true);
+        fontMetrics.setIsFixedV(true);
+        fontMetrics.setCapHeight(10f);
+        fontMetrics.setXHeight(20f);
+        fontMetrics.setAscender(30f);
+        fontMetrics.setDescender(40f);
+        fontMetrics.setStandardHorizontalWidth(50f);
+        fontMetrics.setStandardVerticalWidth(60f);
+        fontMetrics.setUnderlinePosition(70f);
+        fontMetrics.setUnderlineThickness(80f);
+        fontMetrics.setItalicAngle(90f);
+        fontMetrics.setFixedPitch(true);
+
+        assertEquals("weight", fontMetrics.getWeight());
+        assertEquals("encodingScheme", fontMetrics.getEncodingScheme());
+        assertEquals(0, fontMetrics.getMappingScheme());
+        assertEquals(0, fontMetrics.getEscChar());
+        assertEquals("characterSet", fontMetrics.getCharacterSet());
+        assertEquals(10, fontMetrics.getCharacters());
+        assertTrue(fontMetrics.isBaseFont());
+        assertTrue(fontMetrics.isFixedV());
+        assertEquals(10f, fontMetrics.getCapHeight(), 0f);
+        assertEquals(20f, fontMetrics.getXHeight(), 0f);
+        assertEquals(30f, fontMetrics.getAscender(), 0f);
+        assertEquals(40f, fontMetrics.getDescender(), 0f);
+        assertEquals(50f, fontMetrics.getStandardHorizontalWidth(), 0f);
+        assertEquals(60f, fontMetrics.getStandardVerticalWidth(), 0f);
+        assertEquals(70f, fontMetrics.getUnderlinePosition(), 0f);
+        assertEquals(80f, fontMetrics.getUnderlineThickness(), 0f);
+        assertEquals(90f, fontMetrics.getItalicAngle(), 0f);
+        assertTrue(fontMetrics.isFixedPitch());
+    }
+
+    @Test
+    public void testFontMetricsComplexValues()
+    {
+        FontMetrics fontMetrics = new FontMetrics();
+        fontMetrics.setFontBBox(new BoundingBox(10, 20, 30, 40));
+        fontMetrics.setVVector(new float[] { 10, 20 });
+        fontMetrics.setCharWidth(new float[] { 30, 40 });
+        assertEquals(10, fontMetrics.getFontBBox().getLowerLeftX(), 0);
+        assertEquals(20, fontMetrics.getFontBBox().getLowerLeftY(), 0);
+        assertEquals(30, fontMetrics.getFontBBox().getUpperRightX(), 0);
+        assertEquals(40, fontMetrics.getFontBBox().getUpperRightY(), 0);
+        assertEquals(10, fontMetrics.getVVector()[0], 0);
+        assertEquals(20, fontMetrics.getVVector()[1], 0);
+        assertEquals(30, fontMetrics.getCharWidth()[0], 0);
+        assertEquals(40, fontMetrics.getCharWidth()[1], 0);
+    }
+
+    @Test
+    public void testCharMetrics()
+    {
+        FontMetrics fontMetrics = new FontMetrics();
+        assertEquals(0, fontMetrics.getCharMetrics().size());
+        fontMetrics.addCharMetric(new CharMetric());
+        assertEquals(1, fontMetrics.getCharMetrics().size());
+        try
+        {
+            fontMetrics.getCharMetrics().add(new CharMetric());
+            fail("An UnsupportedOperationException should have been thrown");
+        }
+        catch (UnsupportedOperationException exception)
+        {
+            // do nothing
+        }
+    }
+
+    @Test
+    public void testComposites()
+    {
+        FontMetrics fontMetrics = new FontMetrics();
+        assertEquals(0, fontMetrics.getComposites().size());
+        fontMetrics.addComposite(new Composite("name"));
+        assertEquals(1, fontMetrics.getComposites().size());
+        try
+        {
+            fontMetrics.getComposites().add(new Composite("name"));
+            fail("An UnsupportedOperationException should have been thrown");
+        }
+        catch (UnsupportedOperationException exception)
+        {
+            // do nothing
+        }
+    }
+
+    @Test
+    public void testKernData()
+    {
+        FontMetrics fontMetrics = new FontMetrics();
+        // KernPairs
+        assertEquals(0, fontMetrics.getKernPairs().size());
+        fontMetrics.addKernPair(new KernPair("first", "second", 10, 20));
+        assertEquals(1, fontMetrics.getKernPairs().size());
+        try
+        {
+            fontMetrics.getKernPairs().add(new KernPair("first", "second", 10, 20));
+            fail("An UnsupportedOperationException should have been thrown");
+        }
+        catch (UnsupportedOperationException exception)
+        {
+            // do nothing
+        }
+        // KernPairs0
+        assertEquals(0, fontMetrics.getKernPairs0().size());
+        fontMetrics.addKernPair0(new KernPair("first", "second", 10, 20));
+        assertEquals(1, fontMetrics.getKernPairs0().size());
+        try
+        {
+            fontMetrics.getKernPairs0().add(new KernPair("first", "second", 10, 20));
+            fail("An UnsupportedOperationException should have been thrown");
+        }
+        catch (UnsupportedOperationException exception)
+        {
+            // do nothing
+        }
+        // KernPairs1
+        assertEquals(0, fontMetrics.getKernPairs1().size());
+        fontMetrics.addKernPair1(new KernPair("first", "second", 10, 20));
+        assertEquals(1, fontMetrics.getKernPairs1().size());
+        try
+        {
+            fontMetrics.getKernPairs1().add(new KernPair("first", "second", 10, 20));
+            fail("An UnsupportedOperationException should have been thrown");
+        }
+        catch (UnsupportedOperationException exception)
+        {
+            // do nothing
+        }
+        // TrackKern
+        assertEquals(0, fontMetrics.getTrackKern().size());
+        fontMetrics.addTrackKern(new TrackKern(0, 1, 1, 10, 10));
+        assertEquals(1, fontMetrics.getTrackKern().size());
+        try
+        {
+            fontMetrics.getTrackKern().add(new TrackKern(0, 1, 1, 10, 10));
+            fail("An UnsupportedOperationException should have been thrown");
+        }
+        catch (UnsupportedOperationException exception)
+        {
+            // do nothing
+        }
+    }
+}

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

Added: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/KernPairTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/KernPairTest.java?rev=1882845&view=auto
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/KernPairTest.java (added)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/KernPairTest.java Sun Oct 25 16:38:02 2020
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+package org.apache.fontbox.afm;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class KernPairTest
+{
+    @Test
+    public void testKernPair()
+    {
+        KernPair kernPair = new KernPair("firstKernCharacter", "secondKernCharacter", 10f, 20f);
+        assertEquals("firstKernCharacter", kernPair.getFirstKernCharacter());
+        assertEquals("secondKernCharacter", kernPair.getSecondKernCharacter());
+        assertEquals(10f, kernPair.getX(), 0.0f);
+        assertEquals(20f, kernPair.getY(), 0.0f);
+    }
+}

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

Added: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/LigatureTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/LigatureTest.java?rev=1882845&view=auto
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/LigatureTest.java (added)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/LigatureTest.java Sun Oct 25 16:38:02 2020
@@ -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.
+ */
+
+package org.apache.fontbox.afm;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class LigatureTest
+{
+    @Test
+    public void testLigature()
+    {
+        Ligature ligature = new Ligature("successor", "ligature");
+        assertEquals("successor", ligature.getSuccessor());
+        assertEquals("ligature", ligature.getLigature());
+    }
+}

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

Added: pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/TrackKernTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/TrackKernTest.java?rev=1882845&view=auto
==============================================================================
--- pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/TrackKernTest.java (added)
+++ pdfbox/trunk/fontbox/src/test/java/org/apache/fontbox/afm/TrackKernTest.java Sun Oct 25 16:38:02 2020
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+package org.apache.fontbox.afm;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public class TrackKernTest
+{
+    @Test
+    public void testTrackKern()
+    {
+        TrackKern trackKern = new TrackKern(0, 1.0f, 1.0f, 10.0f, 10.0f);
+        assertEquals(0, trackKern.getDegree());
+        assertEquals(1.0f, trackKern.getMinPointSize(), 0.0f);
+        assertEquals(1.0f, trackKern.getMinKern(), 0.0f);
+        assertEquals(10.0f, trackKern.getMaxPointSize(), 0.0f);
+        assertEquals(10.0f, trackKern.getMaxKern(), 0.0f);
+    }
+}

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