pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1709294 - /pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeCollection.java
Date Sun, 18 Oct 2015 17:05:56 GMT
Author: tilman
Date: Sun Oct 18 17:05:56 2015
New Revision: 1709294

URL: http://svn.apache.org/viewvc?rev=1709294&view=rev
Log:
PDFBOX-3035: add convenience method to get a TT font by name

Modified:
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeCollection.java

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeCollection.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeCollection.java?rev=1709294&r1=1709293&r2=1709294&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeCollection.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeCollection.java Sun
Oct 18 17:05:56 2015
@@ -119,6 +119,25 @@ public class TrueTypeCollection implemen
         return fonts;
     }
 
+    /**
+     * Return a TrueType font by name.
+     *
+     * @param fontName the font name to search for.
+     * @return the found font or null if no font for that name was found.
+     * @throws IOException if there was an error reading the naming table of a font.
+     */
+    public TrueTypeFont getFontByName(String fontName) throws IOException
+    {
+        for (TrueTypeFont ttf : fonts)
+        {
+            if (ttf.getName().equals(fontName))
+            {
+                return ttf;
+            }
+        }
+        return null;
+    }
+
     @Override
     public void close() throws IOException
     {



Mime
View raw message