You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ja...@apache.org on 2014/08/17 22:02:20 UTC

svn commit: r1618516 [3/6] - in /pdfbox/no-awt: examples/src/main/java/org/apache/pdfbox/examples/pdmodel/ fontbox/src/main/java/org/apache/fontbox/afm/ fontbox/src/main/java/org/apache/fontbox/cff/ fontbox/src/main/java/org/apache/fontbox/cff/charset/...

Copied: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFStandardEncoding.java (from r1615712, pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/encoding/CFFStandardEncoding.java)
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFStandardEncoding.java?p2=pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFStandardEncoding.java&p1=pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/encoding/CFFStandardEncoding.java&r1=1615712&r2=1618516&rev=1618516&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/encoding/CFFStandardEncoding.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFStandardEncoding.java Sun Aug 17 20:02:18 2014
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.fontbox.cff.encoding;
+package org.apache.fontbox.cff;
 
 /**
  * This is specialized CFFEncoding. It's used if the EncodingId of a font is set to 0.
@@ -42,261 +42,261 @@ public class CFFStandardEncoding extends
 
     static
     {
-        INSTANCE.register(0, 0);
-        INSTANCE.register(1, 0);
-        INSTANCE.register(2, 0);
-        INSTANCE.register(3, 0);
-        INSTANCE.register(4, 0);
-        INSTANCE.register(5, 0);
-        INSTANCE.register(6, 0);
-        INSTANCE.register(7, 0);
-        INSTANCE.register(8, 0);
-        INSTANCE.register(9, 0);
-        INSTANCE.register(10, 0);
-        INSTANCE.register(11, 0);
-        INSTANCE.register(12, 0);
-        INSTANCE.register(13, 0);
-        INSTANCE.register(14, 0);
-        INSTANCE.register(15, 0);
-        INSTANCE.register(16, 0);
-        INSTANCE.register(17, 0);
-        INSTANCE.register(18, 0);
-        INSTANCE.register(19, 0);
-        INSTANCE.register(20, 0);
-        INSTANCE.register(21, 0);
-        INSTANCE.register(22, 0);
-        INSTANCE.register(23, 0);
-        INSTANCE.register(24, 0);
-        INSTANCE.register(25, 0);
-        INSTANCE.register(26, 0);
-        INSTANCE.register(27, 0);
-        INSTANCE.register(28, 0);
-        INSTANCE.register(29, 0);
-        INSTANCE.register(30, 0);
-        INSTANCE.register(31, 0);
-        INSTANCE.register(32, 1);
-        INSTANCE.register(33, 2);
-        INSTANCE.register(34, 3);
-        INSTANCE.register(35, 4);
-        INSTANCE.register(36, 5);
-        INSTANCE.register(37, 6);
-        INSTANCE.register(38, 7);
-        INSTANCE.register(39, 8);
-        INSTANCE.register(40, 9);
-        INSTANCE.register(41, 10);
-        INSTANCE.register(42, 11);
-        INSTANCE.register(43, 12);
-        INSTANCE.register(44, 13);
-        INSTANCE.register(45, 14);
-        INSTANCE.register(46, 15);
-        INSTANCE.register(47, 16);
-        INSTANCE.register(48, 17);
-        INSTANCE.register(49, 18);
-        INSTANCE.register(50, 19);
-        INSTANCE.register(51, 20);
-        INSTANCE.register(52, 21);
-        INSTANCE.register(53, 22);
-        INSTANCE.register(54, 23);
-        INSTANCE.register(55, 24);
-        INSTANCE.register(56, 25);
-        INSTANCE.register(57, 26);
-        INSTANCE.register(58, 27);
-        INSTANCE.register(59, 28);
-        INSTANCE.register(60, 29);
-        INSTANCE.register(61, 30);
-        INSTANCE.register(62, 31);
-        INSTANCE.register(63, 32);
-        INSTANCE.register(64, 33);
-        INSTANCE.register(65, 34);
-        INSTANCE.register(66, 35);
-        INSTANCE.register(67, 36);
-        INSTANCE.register(68, 37);
-        INSTANCE.register(69, 38);
-        INSTANCE.register(70, 39);
-        INSTANCE.register(71, 40);
-        INSTANCE.register(72, 41);
-        INSTANCE.register(73, 42);
-        INSTANCE.register(74, 43);
-        INSTANCE.register(75, 44);
-        INSTANCE.register(76, 45);
-        INSTANCE.register(77, 46);
-        INSTANCE.register(78, 47);
-        INSTANCE.register(79, 48);
-        INSTANCE.register(80, 49);
-        INSTANCE.register(81, 50);
-        INSTANCE.register(82, 51);
-        INSTANCE.register(83, 52);
-        INSTANCE.register(84, 53);
-        INSTANCE.register(85, 54);
-        INSTANCE.register(86, 55);
-        INSTANCE.register(87, 56);
-        INSTANCE.register(88, 57);
-        INSTANCE.register(89, 58);
-        INSTANCE.register(90, 59);
-        INSTANCE.register(91, 60);
-        INSTANCE.register(92, 61);
-        INSTANCE.register(93, 62);
-        INSTANCE.register(94, 63);
-        INSTANCE.register(95, 64);
-        INSTANCE.register(96, 65);
-        INSTANCE.register(97, 66);
-        INSTANCE.register(98, 67);
-        INSTANCE.register(99, 68);
-        INSTANCE.register(100, 69);
-        INSTANCE.register(101, 70);
-        INSTANCE.register(102, 71);
-        INSTANCE.register(103, 72);
-        INSTANCE.register(104, 73);
-        INSTANCE.register(105, 74);
-        INSTANCE.register(106, 75);
-        INSTANCE.register(107, 76);
-        INSTANCE.register(108, 77);
-        INSTANCE.register(109, 78);
-        INSTANCE.register(110, 79);
-        INSTANCE.register(111, 80);
-        INSTANCE.register(112, 81);
-        INSTANCE.register(113, 82);
-        INSTANCE.register(114, 83);
-        INSTANCE.register(115, 84);
-        INSTANCE.register(116, 85);
-        INSTANCE.register(117, 86);
-        INSTANCE.register(118, 87);
-        INSTANCE.register(119, 88);
-        INSTANCE.register(120, 89);
-        INSTANCE.register(121, 90);
-        INSTANCE.register(122, 91);
-        INSTANCE.register(123, 92);
-        INSTANCE.register(124, 93);
-        INSTANCE.register(125, 94);
-        INSTANCE.register(126, 95);
-        INSTANCE.register(127, 0);
-        INSTANCE.register(128, 0);
-        INSTANCE.register(129, 0);
-        INSTANCE.register(130, 0);
-        INSTANCE.register(131, 0);
-        INSTANCE.register(132, 0);
-        INSTANCE.register(133, 0);
-        INSTANCE.register(134, 0);
-        INSTANCE.register(135, 0);
-        INSTANCE.register(136, 0);
-        INSTANCE.register(137, 0);
-        INSTANCE.register(138, 0);
-        INSTANCE.register(139, 0);
-        INSTANCE.register(140, 0);
-        INSTANCE.register(141, 0);
-        INSTANCE.register(142, 0);
-        INSTANCE.register(143, 0);
-        INSTANCE.register(144, 0);
-        INSTANCE.register(145, 0);
-        INSTANCE.register(146, 0);
-        INSTANCE.register(147, 0);
-        INSTANCE.register(148, 0);
-        INSTANCE.register(149, 0);
-        INSTANCE.register(150, 0);
-        INSTANCE.register(151, 0);
-        INSTANCE.register(152, 0);
-        INSTANCE.register(153, 0);
-        INSTANCE.register(154, 0);
-        INSTANCE.register(155, 0);
-        INSTANCE.register(156, 0);
-        INSTANCE.register(157, 0);
-        INSTANCE.register(158, 0);
-        INSTANCE.register(159, 0);
-        INSTANCE.register(160, 0);
-        INSTANCE.register(161, 96);
-        INSTANCE.register(162, 97);
-        INSTANCE.register(163, 98);
-        INSTANCE.register(164, 99);
-        INSTANCE.register(165, 100);
-        INSTANCE.register(166, 101);
-        INSTANCE.register(167, 102);
-        INSTANCE.register(168, 103);
-        INSTANCE.register(169, 104);
-        INSTANCE.register(170, 105);
-        INSTANCE.register(171, 106);
-        INSTANCE.register(172, 107);
-        INSTANCE.register(173, 108);
-        INSTANCE.register(174, 109);
-        INSTANCE.register(175, 110);
-        INSTANCE.register(176, 0);
-        INSTANCE.register(177, 111);
-        INSTANCE.register(178, 112);
-        INSTANCE.register(179, 113);
-        INSTANCE.register(180, 114);
-        INSTANCE.register(181, 0);
-        INSTANCE.register(182, 115);
-        INSTANCE.register(183, 116);
-        INSTANCE.register(184, 117);
-        INSTANCE.register(185, 118);
-        INSTANCE.register(186, 119);
-        INSTANCE.register(187, 120);
-        INSTANCE.register(188, 121);
-        INSTANCE.register(189, 122);
-        INSTANCE.register(190, 0);
-        INSTANCE.register(191, 123);
-        INSTANCE.register(192, 0);
-        INSTANCE.register(193, 124);
-        INSTANCE.register(194, 125);
-        INSTANCE.register(195, 126);
-        INSTANCE.register(196, 127);
-        INSTANCE.register(197, 128);
-        INSTANCE.register(198, 129);
-        INSTANCE.register(199, 130);
-        INSTANCE.register(200, 131);
-        INSTANCE.register(201, 0);
-        INSTANCE.register(202, 132);
-        INSTANCE.register(203, 133);
-        INSTANCE.register(204, 0);
-        INSTANCE.register(205, 134);
-        INSTANCE.register(206, 135);
-        INSTANCE.register(207, 136);
-        INSTANCE.register(208, 137);
-        INSTANCE.register(209, 0);
-        INSTANCE.register(210, 0);
-        INSTANCE.register(211, 0);
-        INSTANCE.register(212, 0);
-        INSTANCE.register(213, 0);
-        INSTANCE.register(214, 0);
-        INSTANCE.register(215, 0);
-        INSTANCE.register(216, 0);
-        INSTANCE.register(217, 0);
-        INSTANCE.register(218, 0);
-        INSTANCE.register(219, 0);
-        INSTANCE.register(220, 0);
-        INSTANCE.register(221, 0);
-        INSTANCE.register(222, 0);
-        INSTANCE.register(223, 0);
-        INSTANCE.register(224, 0);
-        INSTANCE.register(225, 138);
-        INSTANCE.register(226, 0);
-        INSTANCE.register(227, 139);
-        INSTANCE.register(228, 0);
-        INSTANCE.register(229, 0);
-        INSTANCE.register(230, 0);
-        INSTANCE.register(231, 0);
-        INSTANCE.register(232, 140);
-        INSTANCE.register(233, 141);
-        INSTANCE.register(234, 142);
-        INSTANCE.register(235, 143);
-        INSTANCE.register(236, 0);
-        INSTANCE.register(237, 0);
-        INSTANCE.register(238, 0);
-        INSTANCE.register(239, 0);
-        INSTANCE.register(240, 0);
-        INSTANCE.register(241, 144);
-        INSTANCE.register(242, 0);
-        INSTANCE.register(243, 0);
-        INSTANCE.register(244, 0);
-        INSTANCE.register(245, 145);
-        INSTANCE.register(246, 0);
-        INSTANCE.register(247, 0);
-        INSTANCE.register(248, 146);
-        INSTANCE.register(249, 147);
-        INSTANCE.register(250, 148);
-        INSTANCE.register(251, 149);
-        INSTANCE.register(252, 0);
-        INSTANCE.register(253, 0);
-        INSTANCE.register(254, 0);
-        INSTANCE.register(255, 0);
+        INSTANCE.add(0, 0);
+        INSTANCE.add(1, 0);
+        INSTANCE.add(2, 0);
+        INSTANCE.add(3, 0);
+        INSTANCE.add(4, 0);
+        INSTANCE.add(5, 0);
+        INSTANCE.add(6, 0);
+        INSTANCE.add(7, 0);
+        INSTANCE.add(8, 0);
+        INSTANCE.add(9, 0);
+        INSTANCE.add(10, 0);
+        INSTANCE.add(11, 0);
+        INSTANCE.add(12, 0);
+        INSTANCE.add(13, 0);
+        INSTANCE.add(14, 0);
+        INSTANCE.add(15, 0);
+        INSTANCE.add(16, 0);
+        INSTANCE.add(17, 0);
+        INSTANCE.add(18, 0);
+        INSTANCE.add(19, 0);
+        INSTANCE.add(20, 0);
+        INSTANCE.add(21, 0);
+        INSTANCE.add(22, 0);
+        INSTANCE.add(23, 0);
+        INSTANCE.add(24, 0);
+        INSTANCE.add(25, 0);
+        INSTANCE.add(26, 0);
+        INSTANCE.add(27, 0);
+        INSTANCE.add(28, 0);
+        INSTANCE.add(29, 0);
+        INSTANCE.add(30, 0);
+        INSTANCE.add(31, 0);
+        INSTANCE.add(32, 1);
+        INSTANCE.add(33, 2);
+        INSTANCE.add(34, 3);
+        INSTANCE.add(35, 4);
+        INSTANCE.add(36, 5);
+        INSTANCE.add(37, 6);
+        INSTANCE.add(38, 7);
+        INSTANCE.add(39, 8);
+        INSTANCE.add(40, 9);
+        INSTANCE.add(41, 10);
+        INSTANCE.add(42, 11);
+        INSTANCE.add(43, 12);
+        INSTANCE.add(44, 13);
+        INSTANCE.add(45, 14);
+        INSTANCE.add(46, 15);
+        INSTANCE.add(47, 16);
+        INSTANCE.add(48, 17);
+        INSTANCE.add(49, 18);
+        INSTANCE.add(50, 19);
+        INSTANCE.add(51, 20);
+        INSTANCE.add(52, 21);
+        INSTANCE.add(53, 22);
+        INSTANCE.add(54, 23);
+        INSTANCE.add(55, 24);
+        INSTANCE.add(56, 25);
+        INSTANCE.add(57, 26);
+        INSTANCE.add(58, 27);
+        INSTANCE.add(59, 28);
+        INSTANCE.add(60, 29);
+        INSTANCE.add(61, 30);
+        INSTANCE.add(62, 31);
+        INSTANCE.add(63, 32);
+        INSTANCE.add(64, 33);
+        INSTANCE.add(65, 34);
+        INSTANCE.add(66, 35);
+        INSTANCE.add(67, 36);
+        INSTANCE.add(68, 37);
+        INSTANCE.add(69, 38);
+        INSTANCE.add(70, 39);
+        INSTANCE.add(71, 40);
+        INSTANCE.add(72, 41);
+        INSTANCE.add(73, 42);
+        INSTANCE.add(74, 43);
+        INSTANCE.add(75, 44);
+        INSTANCE.add(76, 45);
+        INSTANCE.add(77, 46);
+        INSTANCE.add(78, 47);
+        INSTANCE.add(79, 48);
+        INSTANCE.add(80, 49);
+        INSTANCE.add(81, 50);
+        INSTANCE.add(82, 51);
+        INSTANCE.add(83, 52);
+        INSTANCE.add(84, 53);
+        INSTANCE.add(85, 54);
+        INSTANCE.add(86, 55);
+        INSTANCE.add(87, 56);
+        INSTANCE.add(88, 57);
+        INSTANCE.add(89, 58);
+        INSTANCE.add(90, 59);
+        INSTANCE.add(91, 60);
+        INSTANCE.add(92, 61);
+        INSTANCE.add(93, 62);
+        INSTANCE.add(94, 63);
+        INSTANCE.add(95, 64);
+        INSTANCE.add(96, 65);
+        INSTANCE.add(97, 66);
+        INSTANCE.add(98, 67);
+        INSTANCE.add(99, 68);
+        INSTANCE.add(100, 69);
+        INSTANCE.add(101, 70);
+        INSTANCE.add(102, 71);
+        INSTANCE.add(103, 72);
+        INSTANCE.add(104, 73);
+        INSTANCE.add(105, 74);
+        INSTANCE.add(106, 75);
+        INSTANCE.add(107, 76);
+        INSTANCE.add(108, 77);
+        INSTANCE.add(109, 78);
+        INSTANCE.add(110, 79);
+        INSTANCE.add(111, 80);
+        INSTANCE.add(112, 81);
+        INSTANCE.add(113, 82);
+        INSTANCE.add(114, 83);
+        INSTANCE.add(115, 84);
+        INSTANCE.add(116, 85);
+        INSTANCE.add(117, 86);
+        INSTANCE.add(118, 87);
+        INSTANCE.add(119, 88);
+        INSTANCE.add(120, 89);
+        INSTANCE.add(121, 90);
+        INSTANCE.add(122, 91);
+        INSTANCE.add(123, 92);
+        INSTANCE.add(124, 93);
+        INSTANCE.add(125, 94);
+        INSTANCE.add(126, 95);
+        INSTANCE.add(127, 0);
+        INSTANCE.add(128, 0);
+        INSTANCE.add(129, 0);
+        INSTANCE.add(130, 0);
+        INSTANCE.add(131, 0);
+        INSTANCE.add(132, 0);
+        INSTANCE.add(133, 0);
+        INSTANCE.add(134, 0);
+        INSTANCE.add(135, 0);
+        INSTANCE.add(136, 0);
+        INSTANCE.add(137, 0);
+        INSTANCE.add(138, 0);
+        INSTANCE.add(139, 0);
+        INSTANCE.add(140, 0);
+        INSTANCE.add(141, 0);
+        INSTANCE.add(142, 0);
+        INSTANCE.add(143, 0);
+        INSTANCE.add(144, 0);
+        INSTANCE.add(145, 0);
+        INSTANCE.add(146, 0);
+        INSTANCE.add(147, 0);
+        INSTANCE.add(148, 0);
+        INSTANCE.add(149, 0);
+        INSTANCE.add(150, 0);
+        INSTANCE.add(151, 0);
+        INSTANCE.add(152, 0);
+        INSTANCE.add(153, 0);
+        INSTANCE.add(154, 0);
+        INSTANCE.add(155, 0);
+        INSTANCE.add(156, 0);
+        INSTANCE.add(157, 0);
+        INSTANCE.add(158, 0);
+        INSTANCE.add(159, 0);
+        INSTANCE.add(160, 0);
+        INSTANCE.add(161, 96);
+        INSTANCE.add(162, 97);
+        INSTANCE.add(163, 98);
+        INSTANCE.add(164, 99);
+        INSTANCE.add(165, 100);
+        INSTANCE.add(166, 101);
+        INSTANCE.add(167, 102);
+        INSTANCE.add(168, 103);
+        INSTANCE.add(169, 104);
+        INSTANCE.add(170, 105);
+        INSTANCE.add(171, 106);
+        INSTANCE.add(172, 107);
+        INSTANCE.add(173, 108);
+        INSTANCE.add(174, 109);
+        INSTANCE.add(175, 110);
+        INSTANCE.add(176, 0);
+        INSTANCE.add(177, 111);
+        INSTANCE.add(178, 112);
+        INSTANCE.add(179, 113);
+        INSTANCE.add(180, 114);
+        INSTANCE.add(181, 0);
+        INSTANCE.add(182, 115);
+        INSTANCE.add(183, 116);
+        INSTANCE.add(184, 117);
+        INSTANCE.add(185, 118);
+        INSTANCE.add(186, 119);
+        INSTANCE.add(187, 120);
+        INSTANCE.add(188, 121);
+        INSTANCE.add(189, 122);
+        INSTANCE.add(190, 0);
+        INSTANCE.add(191, 123);
+        INSTANCE.add(192, 0);
+        INSTANCE.add(193, 124);
+        INSTANCE.add(194, 125);
+        INSTANCE.add(195, 126);
+        INSTANCE.add(196, 127);
+        INSTANCE.add(197, 128);
+        INSTANCE.add(198, 129);
+        INSTANCE.add(199, 130);
+        INSTANCE.add(200, 131);
+        INSTANCE.add(201, 0);
+        INSTANCE.add(202, 132);
+        INSTANCE.add(203, 133);
+        INSTANCE.add(204, 0);
+        INSTANCE.add(205, 134);
+        INSTANCE.add(206, 135);
+        INSTANCE.add(207, 136);
+        INSTANCE.add(208, 137);
+        INSTANCE.add(209, 0);
+        INSTANCE.add(210, 0);
+        INSTANCE.add(211, 0);
+        INSTANCE.add(212, 0);
+        INSTANCE.add(213, 0);
+        INSTANCE.add(214, 0);
+        INSTANCE.add(215, 0);
+        INSTANCE.add(216, 0);
+        INSTANCE.add(217, 0);
+        INSTANCE.add(218, 0);
+        INSTANCE.add(219, 0);
+        INSTANCE.add(220, 0);
+        INSTANCE.add(221, 0);
+        INSTANCE.add(222, 0);
+        INSTANCE.add(223, 0);
+        INSTANCE.add(224, 0);
+        INSTANCE.add(225, 138);
+        INSTANCE.add(226, 0);
+        INSTANCE.add(227, 139);
+        INSTANCE.add(228, 0);
+        INSTANCE.add(229, 0);
+        INSTANCE.add(230, 0);
+        INSTANCE.add(231, 0);
+        INSTANCE.add(232, 140);
+        INSTANCE.add(233, 141);
+        INSTANCE.add(234, 142);
+        INSTANCE.add(235, 143);
+        INSTANCE.add(236, 0);
+        INSTANCE.add(237, 0);
+        INSTANCE.add(238, 0);
+        INSTANCE.add(239, 0);
+        INSTANCE.add(240, 0);
+        INSTANCE.add(241, 144);
+        INSTANCE.add(242, 0);
+        INSTANCE.add(243, 0);
+        INSTANCE.add(244, 0);
+        INSTANCE.add(245, 145);
+        INSTANCE.add(246, 0);
+        INSTANCE.add(247, 0);
+        INSTANCE.add(248, 146);
+        INSTANCE.add(249, 147);
+        INSTANCE.add(250, 148);
+        INSTANCE.add(251, 149);
+        INSTANCE.add(252, 0);
+        INSTANCE.add(253, 0);
+        INSTANCE.add(254, 0);
+        INSTANCE.add(255, 0);
     }
 }
\ No newline at end of file

Added: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFType1Font.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFType1Font.java?rev=1618516&view=auto
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFType1Font.java (added)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CFFType1Font.java Sun Aug 17 20:02:18 2014
@@ -0,0 +1,189 @@
+/*
+ * 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.cff;
+
+import org.apache.fontbox.ttf.Type1Equivalent;
+import org.apache.fontbox.type1.Type1CharStringReader;
+
+import java.awt.geom.GeneralPath;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A Type 1-equivalent font program represented in a CFF file.
+ *
+ * @author Villu Ruusmann
+ * @author John Hewson
+ */
+public class CFFType1Font extends CFFFont implements Type1Equivalent
+{
+    private final Map<String, Object> privateDict = new LinkedHashMap<String, Object>();
+    private CFFEncoding encoding;
+
+    private final Map<Integer, Type2CharString> charStringCache = new HashMap<Integer, Type2CharString>();
+    private final PrivateType1CharStringReader reader = new PrivateType1CharStringReader();
+
+    /**
+     * Private implementation of Type1CharStringReader, because only CFFType1Font can
+     * expose this publicly, as CIDFonts only support this for legacy 'seac' commands.
+     */
+    private class PrivateType1CharStringReader implements Type1CharStringReader
+    {
+        @Override
+        public Type1CharString getType1CharString(String name) throws IOException
+        {
+            return CFFType1Font.this.getType1CharString(name);
+        }
+    }
+
+    @Override
+    public String getFullName()
+    {
+        return fontName;
+    }
+
+    public GeneralPath getPath(String name) throws IOException
+    {
+        return getType1CharString(name).getPath();
+    }
+
+    @Override
+    public boolean hasGlyph(String name)
+    {
+        int sid = charset.getSID(name);
+        int gid = charset.getGIDForSID(sid);
+        return gid != 0;
+    }
+
+    /**
+     * Returns the Type 1 charstring for the given PostScript glyph name.
+     *
+     * @param name PostScript glyph name
+     * @throws IOException if the charstring could not be read
+     */
+    public Type1CharString getType1CharString(String name) throws IOException
+    {
+        // some fonts have glyphs beyond their encoding, so we look up by charset SID
+        int sid = charset.getSID(name);
+        int gid = charset.getGIDForSID(sid);
+
+        Type2CharString type2 = charStringCache.get(gid);
+        if (type2 == null)
+        {
+            byte[] bytes = charStrings.get(gid);
+            if (bytes == null)
+            {
+                bytes = charStrings.get(0); // .notdef
+            }
+            Type2CharStringParser parser = new Type2CharStringParser(fontName, name);
+            List<Object> type2seq = parser.parse(bytes, globalSubrIndex, getLocalSubrIndex());
+            type2 = new Type2CharString(reader, fontName, name, gid, type2seq, getDefaultWidthX(),
+                                        getNominalWidthX());
+            charStringCache.put(gid, type2);
+        }
+        return type2;
+    }
+
+    /**
+     * Returns the private dictionary.
+     *
+     * @return the dictionary
+     */
+    public Map<String, Object> getPrivateDict()
+    {
+        return privateDict;
+    }
+
+    /**
+     * Adds the given key/value pair to the private dictionary.
+     *
+     * @param name the given key
+     * @param value the given value
+     */
+    // todo: can't we just accept a Map?
+    void addToPrivateDict(String name, Object value)
+    {
+        if (value != null)
+        {
+            privateDict.put(name, value);
+        }
+    }
+
+    /**
+     * Returns the CFFEncoding of the font.
+     *
+     * @return the encoding
+     */
+    public CFFEncoding getEncoding()
+    {
+        return encoding;
+    }
+
+    /**
+     * Sets the CFFEncoding of the font.
+     *
+     * @param encoding the given CFFEncoding
+     */
+    void setEncoding(CFFEncoding encoding)
+    {
+        this.encoding = encoding;
+    }
+
+    private IndexData getLocalSubrIndex()
+    {
+        return (IndexData)privateDict.get("Subrs");
+    }
+
+    // helper for looking up keys/values
+    private Object getProperty(String name)
+    {
+        Object topDictValue = topDict.get(name);
+        if (topDictValue != null)
+        {
+            return topDictValue;
+        }
+        Object privateDictValue = privateDict.get(name);
+        if (privateDictValue != null)
+        {
+            return privateDictValue;
+        }
+        return null;
+    }
+
+    private int getDefaultWidthX()
+    {
+        Number num = (Number)getProperty("defaultWidthX");
+        if (num == null)
+        {
+            return 1000;
+        }
+        return num.intValue();
+    }
+
+    private int getNominalWidthX()
+    {
+        Number num = (Number)getProperty("nominalWidthX");
+        if (num == null)
+        {
+            return 0;
+        }
+        return num.intValue();
+    }
+}

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CIDKeyedFDSelect.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CIDKeyedFDSelect.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CIDKeyedFDSelect.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CIDKeyedFDSelect.java Sun Aug 17 20:02:18 2014
@@ -19,14 +19,14 @@ package org.apache.fontbox.cff;
 
 public abstract class CIDKeyedFDSelect {
 	
-	protected CFFFontROS owner = null;
+	protected CFFCIDFont owner = null;
 	
 	/**
 	 * Constructor.
-	 * @param _owner the owner of the FDSelect data.
+	 * @param owner the owner of the FDSelect data.
 	 */
-	public CIDKeyedFDSelect(CFFFontROS _owner) {
-		this.owner = _owner;
+	public CIDKeyedFDSelect(CFFCIDFont owner) {
+		this.owner = owner;
 	}
 	/**
 	 * Returns the Font DICT index for the given glyph identifier

Added: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CIDKeyedType2CharString.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CIDKeyedType2CharString.java?rev=1618516&view=auto
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CIDKeyedType2CharString.java (added)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/CIDKeyedType2CharString.java Sun Aug 17 20:02:18 2014
@@ -0,0 +1,41 @@
+package org.apache.fontbox.cff;
+
+import org.apache.fontbox.type1.Type1CharStringReader;
+
+import java.util.List;
+
+/**
+ * A CID-Keyed Type 2 CharString.
+ *
+ * @author John Hewson
+ */
+public class CIDKeyedType2CharString extends Type2CharString
+{
+    private final int cid;
+
+    /**
+     * Constructor.
+     *
+     * @param font Parent CFF font
+     * @param fontName font name
+     * @param cid CID
+     * @param gid GID
+     * @param sequence Type 2 char string sequence
+     * @param defaultWidthX default width
+     * @param nomWidthX nominal width
+     */
+    public CIDKeyedType2CharString(Type1CharStringReader font, String fontName, int cid, int gid, List<Object> sequence, int defaultWidthX, int nomWidthX)
+    {
+        // glyph name is for debugging only
+        super(font, fontName, String.format("%04x", cid), gid, sequence, defaultWidthX, nomWidthX);
+        this.cid = cid;
+    }
+
+    /**
+     * Returns the CID (character id) of this charstring.
+     */
+    public int getCID()
+    {
+        return cid;
+    }
+}

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type1CharString.java Sun Aug 17 20:02:18 2014
@@ -40,7 +40,7 @@ public class Type1CharString
 {
     private static final Log LOG = LogFactory.getLog(Type1CharString.class);
 
-    private Type1CharStringReader reader;
+    private Type1CharStringReader font;
     private String fontName, glyphName;
     private GeneralPath path = null;
     private int width = 0;
@@ -53,28 +53,34 @@ public class Type1CharString
 
     /**
      * Constructs a new Type1CharString object.
-     * @param reader Parent Type 1 CharString reader
+     * @param font Parent Type 1 CharString font
      * @param sequence Type 1 char string sequence
      */
-    public Type1CharString(Type1CharStringReader reader, String fontName, String glyphName,
+    public Type1CharString(Type1CharStringReader font, String fontName, String glyphName,
                            List<Object> sequence)
     {
-        this(reader, fontName, glyphName);
+        this(font, fontName, glyphName);
         type1Sequence = sequence;
     }
 
     /**
      * Constructor for use in subclasses.
-     * @param reader Parent Type 1 CharString reader
+     * @param font Parent Type 1 CharString font
      */
-    protected Type1CharString(Type1CharStringReader reader, String fontName, String glyphName)
+    protected Type1CharString(Type1CharStringReader font, String fontName, String glyphName)
     {
-        this.reader = reader;
+        this.font = font;
         this.fontName = fontName;
         this.glyphName = glyphName;
         this.current = new Point2D.Float(0, 0);
     }
 
+    // todo: NEW name (or CID as hex)
+    public String getName()
+    {
+        return glyphName;
+    }
+
     /**
      * Returns the bounds of the renderer path.
      * @return the bounds as Rectangle2D
@@ -414,7 +420,7 @@ public class Type1CharString
         {
             try
             {
-                Type1CharString base = reader.getType1CharString(baseName);
+                Type1CharString base = font.getType1CharString(baseName);
                 path.append(base.getPath().getPathIterator(null), false);
             }
             catch (IOException e)
@@ -428,7 +434,7 @@ public class Type1CharString
         {
             try
             {
-                Type1CharString accent = reader.getType1CharString(accentName);
+                Type1CharString accent = font.getType1CharString(accentName);
                 AffineTransform at = AffineTransform.getTranslateInstance(
                     leftSideBearing.getX() + adx.floatValue(),
                     leftSideBearing.getY() + ady.floatValue());

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java Sun Aug 17 20:02:18 2014
@@ -34,21 +34,24 @@ public class Type2CharString extends Typ
     private int defWidthX = 0;
     private int nominalWidthX = 0;
     private int pathCount = 0;
-    private List<Object> type2sequence;
+    private final List<Object> type2sequence;
+    private final int gid;
 
     /**
      * Constructor.
-     * @param reader Parent CFF font
+     * @param font Parent CFF font
      * @param fontName font name
-     * @param glyphName glyph name
+     * @param glyphName glyph name (or CID as hex string)
+     * @param gid GID
      * @param sequence Type 2 char string sequence
      * @param defaultWidthX default width
      * @param nomWidthX nominal width
      */
-    public Type2CharString(Type1CharStringReader reader, String fontName, String glyphName, List<Object> sequence,
+    public Type2CharString(Type1CharStringReader font, String fontName, String glyphName, int gid, List<Object> sequence,
                            int defaultWidthX, int nomWidthX)
     {
-        super(reader, fontName, glyphName);
+        super(font, fontName, glyphName);
+        this.gid = gid;
         type2sequence = sequence;
         defWidthX = defaultWidthX;
         nominalWidthX = nomWidthX;
@@ -56,8 +59,15 @@ public class Type2CharString extends Typ
     }
 
     /**
-     * Returns the advance width of the glyph.
-     * @return the width
+     * Return the GID (glyph id) of this charstring.
+     */
+    public int getGID()
+    {
+        return gid;
+    }
+
+    /**
+     * Returns the advance width of this glyph.
      */
     public int getWidth()
     {
@@ -73,8 +83,7 @@ public class Type2CharString extends Typ
     }
 
     /**
-     * Returns the Type 2 char string sequence.
-     * @return the Type 2 sequence
+     * Returns the Type 2 charstring sequence.
      */
     public List<Object> getType2Sequence()
     {
@@ -138,7 +147,7 @@ public class Type2CharString extends Typ
         }
         else if ("endchar".equals(name))
         {
-            numbers = clearStack(numbers, numbers.size() == 5);
+            numbers = clearStack(numbers, numbers.size() == 5 || numbers.size() == 1);
             closePath();
             if (numbers.size() == 4)
             {

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharStringParser.java Sun Aug 17 20:02:18 2014
@@ -32,7 +32,7 @@ public class Type2CharStringParser
     private final String fontName, glyphName;
 
     /**
-     * Constructs a new Type1CharStringParser object.
+     * Constructs a new Type1CharStringParser object for a Type 1-equivalent font.
      *
      * @param fontName font name
      * @param glyphName glyph name
@@ -44,6 +44,18 @@ public class Type2CharStringParser
     }
 
     /**
+     * Constructs a new Type1CharStringParser object for a CID-Keyed font.
+     *
+     * @param fontName font name
+     * @param cid CID
+     */
+    public Type2CharStringParser(String fontName, int cid)
+    {
+        this.fontName = fontName;
+        this.glyphName = String.format("%04x", cid); // for debugging only
+    }
+
+    /**
      * The given byte array will be parsed and converted to a Type2 sequence.
      * @param bytes the given mapping as byte array
      * @param globalSubrIndex index containing all global subroutines

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/cmap/CMapParser.java Sun Aug 17 20:02:18 2014
@@ -703,24 +703,4 @@ public class CMapParser
             op = theOp;
         }
     }
-
-    /**
-     * A simple class to test parsing of cmap files.
-     * 
-     * @param args Some command line arguments.
-     * 
-     * @throws Exception If there is an error parsing the file.
-     */
-    public static void main(String[] args) throws Exception
-    {
-        if (args.length != 1)
-        {
-            System.err.println("usage: java org.apache.fontbox.cmap.CMapParser <CMAP File>");
-            System.exit(-1);
-        }
-        CMapParser parser = new CMapParser();
-        File cmapFile = new File(args[0]);
-        CMap result = parser.parse(cmapFile);
-        System.out.println("Result:" + result);
-    }
 }

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/encoding/Encoding.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/encoding/Encoding.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/encoding/Encoding.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/encoding/Encoding.java Sun Aug 17 20:02:18 2014
@@ -22,98 +22,26 @@ import java.util.HashMap;
 import java.util.Map;
 
 /**
- * This is an interface to a text encoder.
+ * A PostScript Encoding vector.
  *
  * @author Ben Litchfield
- * 
  */
 public abstract class Encoding
 {
-    /**
-     * The number of standard mac glyph names.
-     */
-    public static final int NUMBER_OF_MAC_GLYPHS = 258;
-    
-    /**
-     * The 258 standard mac glyph names a used in 'post' format 1 and 2.
-     */
-    public static final String[] MAC_GLYPH_NAMES = new String[] 
-    { 
-        ".notdef",".null", "nonmarkingreturn", "space", "exclam", "quotedbl",
-            "numbersign", "dollar", "percent", "ampersand", "quotesingle",
-            "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen",
-            "period", "slash", "zero", "one", "two", "three", "four", "five",
-            "six", "seven", "eight", "nine", "colon", "semicolon", "less",
-            "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F",
-            "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S",
-            "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash",
-            "bracketright", "asciicircum", "underscore", "grave", "a", "b",
-            "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
-            "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft",
-            "bar", "braceright", "asciitilde", "Adieresis", "Aring",
-            "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute",
-            "agrave", "acircumflex", "adieresis", "atilde", "aring",
-            "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis",
-            "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute",
-            "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave",
-            "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling",
-            "section", "bullet", "paragraph", "germandbls", "registered",
-            "copyright", "trademark", "acute", "dieresis", "notequal", "AE",
-            "Oslash", "infinity", "plusminus", "lessequal", "greaterequal",
-            "yen", "mu", "partialdiff", "summation", "product", "pi",
-            "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash",
-            "questiondown", "exclamdown", "logicalnot", "radical", "florin",
-            "approxequal", "Delta", "guillemotleft", "guillemotright",
-            "ellipsis", "nonbreakingspace", "Agrave", "Atilde", "Otilde", "OE",
-            "oe", "endash", "emdash", "quotedblleft", "quotedblright",
-            "quoteleft", "quoteright", "divide", "lozenge", "ydieresis",
-            "Ydieresis", "fraction", "currency", "guilsinglleft",
-            "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered",
-            "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex",
-            "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute",
-            "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex",
-            "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi",
-            "circumflex", "tilde", "macron", "breve", "dotaccent", "ring",
-            "cedilla", "hungarumlaut", "ogonek", "caron", "Lslash", "lslash",
-            "Scaron", "scaron", "Zcaron", "zcaron", "brokenbar", "Eth", "eth",
-            "Yacute", "yacute", "Thorn", "thorn", "minus", "multiply",
-            "onesuperior", "twosuperior", "threesuperior", "onehalf",
-            "onequarter", "threequarters", "franc", "Gbreve", "gbreve",
-            "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron",
-            "ccaron", "dcroat" 
-    };
-
-    /**
-     * The indices of the standard mac glyph names.
-     */
-    public static Map<String,Integer> MAC_GLYPH_NAMES_INDICES;
-    
-    static 
-    {
-        MAC_GLYPH_NAMES_INDICES = new HashMap<String,Integer>();
-        for (int i=0;i<Encoding.NUMBER_OF_MAC_GLYPHS;++i) 
-        {
-            MAC_GLYPH_NAMES_INDICES.put(Encoding.MAC_GLYPH_NAMES[i],i);
-        }
-    }
-
-    /**
-     * Identifies a non-mapped character. 
-     */
     private static final String NOTDEF = ".notdef";
+    private static final Map<String,String> NAME_TO_CHARACTER = new HashMap<String,String>();
+    private static final Map<String,String> CHARACTER_TO_NAME = new HashMap<String,String>();
 
     /**
      * This is a mapping from a character code to a character name.
      */
     protected Map<Integer,String> codeToName = new HashMap<Integer,String>();
+
     /**
      * This is a mapping from a character name to a character code.
      */
     protected Map<String,Integer> nameToCode = new HashMap<String,Integer>();
 
-    private static final Map<String,String> NAME_TO_CHARACTER = new HashMap<String,String>();
-    private static final Map<String,String> CHARACTER_TO_NAME = new HashMap<String,String>();
-
     /**
      * This will add a character encoding.
      *
@@ -130,7 +58,6 @@ public abstract class Encoding
      * This will get the character code for the name.
      *
      * @param name The name of the character.
-     *
      * @return The code for the character or null if it is not in the encoding.
      */
     public Integer getCode( String name )
@@ -142,7 +69,6 @@ public abstract class Encoding
      * This will take a character code and get the name from the code.
      *
      * @param code The character code.
-     *
      * @return The name of the character.
      */
     public String getName( int code )
@@ -159,9 +85,7 @@ public abstract class Encoding
      * This will take a character code and get the name from the code.
      *
      * @param c The character.
-     *
      * @return The name of the character.
-     *
      * @throws IOException If there is no name for the character.
      */
     public String getNameFromCharacter( char c ) throws IOException
@@ -178,9 +102,7 @@ public abstract class Encoding
      * This will get the character from the code.
      *
      * @param code The character code.
-     *
      * @return The printable character for the code.
-     *
      * @throws IOException If there is not name for the character.
      */
     public String getCharacter( int code ) throws IOException
@@ -192,7 +114,6 @@ public abstract class Encoding
      * This will get the character from the name.
      *
      * @param name The name of the character.
-     *
      * @return The printable character for the code.
      */
     public static String getCharacter( String name )
@@ -206,7 +127,7 @@ public abstract class Encoding
     }
     
     /**
-     * Returns an unmodifiable view of the Code2Name mapping.
+     * Returns an unmodifiable view of the code to name mapping.
      * 
      * @return the Code2Name map
      */
@@ -214,5 +135,4 @@ public abstract class Encoding
     {
         return Collections.unmodifiableMap(codeToName);
     }
-
-}
\ No newline at end of file
+}

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/NameRecord.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/NameRecord.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/NameRecord.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/NameRecord.java Sun Aug 17 20:02:18 2014
@@ -21,72 +21,49 @@ import java.io.IOException;
 /**
  * A name record in the name table.
  * 
- * @author Ben Litchfield (ben@benlitchfield.com)
- * @version $Revision: 1.1 $
+ * @author Ben Litchfield
  */
 public class NameRecord
 {
-    /**
-     * A constant for the platform.
-     */
-    public static final int PLATFORM_APPLE_UNICODE = 0;
-    /**
-     * A constant for the platform.
-     */
+    // platform ids
+    public static final int PLATFORM_UNICODE = 0;
     public static final int PLATFORM_MACINTOSH = 1;
-    /**
-     * A constant for the platform.
-     */
     public static final int PLATFORM_ISO = 2;
-    /**
-     * A constant for the platform.
-     */
     public static final int PLATFORM_WINDOWS = 3;
-    
-    /**
-     * Platform specific encoding.
-     */
-    public static final int PLATFORM_ENCODING_WINDOWS_UNDEFINED = 0;
-    /**
-     * Platform specific encoding.
-     */
-    public static final int PLATFORM_ENCODING_WINDOWS_UNICODE = 1;
-    
-    /**
-     * A name id.
-     */
+
+    // Unicode encoding ids
+    public static final int ENCODING_UNICODE_1_0 = 0;
+    public static final int ENCODING_UNICODE_1_1 = 1;
+    public static final int ENCODING_UNICODE_2_0_BMP = 3;
+    public static final int ENCODING_UNICODE_2_0_FULL = 4;
+
+    // Unicode encoding ids
+    public static final int LANGUGAE_UNICODE = 0;
+
+    // Windows encoding ids
+    public static final int ENCODING_WINDOWS_SYMBOL = 0;
+    public static final int ENCODING_WINDOWS_UNICODE_BMP = 1;
+    public static final int ENCODING_WINDOWS_UNICODE_UCS4 = 10;
+
+    // Windows language ids
+    public static final int LANGUGAE_WINDOWS_EN_US = 0x0409;
+
+    // Macintosh encoding ids
+    public static final int ENCODING_MACINTOSH_ROMAN = 0;
+
+    // Macintosh language ids
+    public static final int LANGUGAE_MACINTOSH_ENGLISH = 0;
+
+    // name ids
     public static final int NAME_COPYRIGHT = 0;
-    /**
-     * A name id.
-     */
     public static final int NAME_FONT_FAMILY_NAME = 1;
-    /**
-     * A name id.
-     */
     public static final int NAME_FONT_SUB_FAMILY_NAME = 2;
-    /**
-     * A name id.
-     */
     public static final int NAME_UNIQUE_FONT_ID = 3;
-    /**
-     * A name id.
-     */
     public static final int NAME_FULL_FONT_NAME = 4;
-    /**
-     * A name id.
-     */
     public static final int NAME_VERSION = 5;
-    /**
-     * A name id.
-     */
     public static final int NAME_POSTSCRIPT_NAME = 6;
-    /**
-     * A name id.
-     */
     public static final int NAME_TRADEMARK = 7;
     
-    
-    
     private int platformId;
     private int platformEncodingId;
     private int languageId;

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/NamingTable.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/NamingTable.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/NamingTable.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/NamingTable.java Sun Aug 17 20:02:18 2014
@@ -19,13 +19,14 @@ package org.apache.fontbox.ttf;
 import java.io.IOException;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * A table in a true type font.
  * 
- * @author Ben Litchfield (ben@benlitchfield.com)
- * 
+ * @author Ben Litchfield
  */
 public class NamingTable extends TTFTable
 {
@@ -35,12 +36,14 @@ public class NamingTable extends TTFTabl
     public static final String TAG = "name";
     
     private List<NameRecord> nameRecords = new ArrayList<NameRecord>();
-    
+
+    private Map<Integer, Map<Integer, Map<Integer, Map<Integer, String>>>> lookupTable =
+            new HashMap<Integer, Map<Integer, Map<Integer, Map<Integer, String>>>>();
+
     private String fontFamily = null;
     private String fontSubFamily = null;
     private String psName = null;
-    
-    
+
     /**
      * This will read the required data from the stream.
      * 
@@ -53,80 +56,173 @@ public class NamingTable extends TTFTabl
         int formatSelector = data.readUnsignedShort();
         int numberOfNameRecords = data.readUnsignedShort();
         int offsetToStartOfStringStorage = data.readUnsignedShort();
-        for( int i=0; i< numberOfNameRecords; i++ )
+        for (int i=0; i< numberOfNameRecords; i++)
         {
             NameRecord nr = new NameRecord();
-            nr.initData( ttf, data );
-            nameRecords.add( nr );
+            nr.initData(ttf, data);
+            nameRecords.add(nr);
         }
-        for( int i=0; i<numberOfNameRecords; i++ )
+
+        for (int i=0; i<numberOfNameRecords; i++)
         {
-            NameRecord nr = nameRecords.get( i );
-            data.seek( getOffset() + (2*3)+numberOfNameRecords*2*6+nr.getStringOffset() );
+            NameRecord nr = nameRecords.get(i);
+            data.seek(getOffset() + (2*3)+numberOfNameRecords*2*6+nr.getStringOffset());
             int platform = nr.getPlatformId();
             int encoding = nr.getPlatformEncodingId();
             String charset = "ISO-8859-1";
-            boolean isPlatform310 = false;
-            boolean isPlatform10 = false;
-            if( platform == 3 && (encoding == 1 || encoding == 0) )
+            if (platform == 3 && (encoding == 1 || encoding == 0))
             {
                 charset = "UTF-16";
-                isPlatform310 = true;
             }
-            else if( platform == 2 )
+            else if (platform == 2)
             {
-                if( encoding == 0 )
+                if (encoding == 0)
                 {
                     charset = "US-ASCII";
                 }
-                else if( encoding == 1 )
+                else if (encoding == 1)
                 {
                     //not sure is this is correct??
                     charset = "ISO-10646-1";
                 }
-                else if( encoding == 2 )
+                else if (encoding == 2)
                 {
                     charset = "ISO-8859-1";
                 }
             }
-            else if ( platform == 1 && encoding == 0)
+            String string = data.readString(nr.getStringLength(), charset);
+            nr.setString(string);
+        }
+
+        // build multi-dimensional lookup table
+        for (NameRecord nr : nameRecords)
+        {
+            // name id
+            if (!lookupTable.containsKey(nr.getNameId()))
             {
-                isPlatform10 = true;
+                lookupTable.put(nr.getNameId(),
+                        new HashMap<Integer, Map<Integer, Map<Integer, String>>>());
             }
-            String string = data.readString( nr.getStringLength(), charset );
-            nr.setString( string );
-            int nameID = nr.getNameId();
-            if (nameID == NameRecord.NAME_FONT_FAMILY_NAME)
-            {
-                // prefer 3,1 or 3,0 platform/encoding use 1,0 as fallback
-                if (isPlatform310 || (isPlatform10 && fontFamily == null))
-                {
-                    fontFamily = string;
-                }
-            }            
-            else if (nameID == NameRecord.NAME_FONT_SUB_FAMILY_NAME)
+            Map<Integer, Map<Integer, Map<Integer, String>>> platformLookup =
+                    lookupTable.get(nr.getNameId());
+
+            // platform id
+            if (!platformLookup.containsKey(nr.getPlatformId()))
             {
-                // prefer 3,1 or 3,0 platform/encoding use 1,0 as fallback
-                if (isPlatform310 || (isPlatform10 && fontSubFamily == null))
-                {
-                    fontSubFamily = string;
-                }
-            }            
-            else if (nameID == NameRecord.NAME_POSTSCRIPT_NAME)
+                platformLookup.put(nr.getPlatformId(),
+                                   new HashMap<Integer, Map<Integer, String>>());
+            }
+            Map<Integer, Map<Integer, String>> encodingLookup =
+                    platformLookup.get(nr.getPlatformId());
+
+            // encoding id
+            if (!encodingLookup.containsKey(nr.getPlatformEncodingId()))
             {
-                // prefer 3,1 or 3,0 platform/encoding use 1,0 as fallback
-                if (isPlatform310 || (isPlatform10 && psName == null))
-                {
-                    psName = string;
-                }
-            }            
+               encodingLookup.put(nr.getPlatformEncodingId(),
+                                  new HashMap<Integer, String>());
+            }
+            Map<Integer, String> languageLookup = encodingLookup.get(nr.getPlatformEncodingId());
+
+            // language id / string
+            languageLookup.put(nr.getLanguageId(), nr.getString());
         }
+
+        // extract strings of interest
+        fontFamily = getEnglishName(NameRecord.NAME_FONT_FAMILY_NAME);
+        fontSubFamily = getEnglishName(NameRecord.NAME_FONT_SUB_FAMILY_NAME);
+
+        // extract PostScript name, only these two formats are valid
+        psName = getName(NameRecord.NAME_POSTSCRIPT_NAME,
+                         NameRecord.PLATFORM_MACINTOSH,
+                         NameRecord.ENCODING_MACINTOSH_ROMAN,
+                         NameRecord.LANGUGAE_MACINTOSH_ENGLISH);
+        if (psName == null)
+        {
+            psName = getName(NameRecord.NAME_POSTSCRIPT_NAME,
+                             NameRecord.PLATFORM_WINDOWS,
+                             NameRecord.ENCODING_WINDOWS_UNICODE_BMP,
+                             NameRecord.LANGUGAE_WINDOWS_EN_US);
+        }
+
         initialized = true;
     }
-    
+
+    /**
+     * Helper to get English names by best effort.
+     */
+    private String getEnglishName(int nameId)
+    {
+        // Unicode, Full, BMP, 1.1, 1.0
+        for (int i = 4; i <= 0; i--)
+        {
+            String nameUni =
+                    getName(nameId,
+                            NameRecord.PLATFORM_UNICODE,
+                            i,
+                            NameRecord.LANGUGAE_UNICODE);
+            if (nameUni != null)
+            {
+                return nameUni;
+            }
+        }
+
+        // Windows, Unicode BMP, EN-US
+        String nameWin =
+                getName(nameId,
+                        NameRecord.PLATFORM_WINDOWS,
+                        NameRecord.ENCODING_WINDOWS_UNICODE_BMP,
+                        NameRecord.LANGUGAE_WINDOWS_EN_US);
+        if (nameWin != null)
+        {
+            return nameWin;
+        }
+
+        // Macintosh, Roman, English
+        String nameMac =
+                getName(nameId,
+                        NameRecord.PLATFORM_MACINTOSH,
+                        NameRecord.ENCODING_MACINTOSH_ROMAN,
+                        NameRecord.LANGUGAE_MACINTOSH_ENGLISH);
+        if (nameMac != null)
+        {
+            return nameMac;
+        }
+
+        return null;
+    }
+
+    /**
+     * Returns a name from the table, or null it it does not exist.
+     *
+     * @param nameId Name ID from NameRecord constants.
+     * @param platformId Platform ID from NameRecord constants.
+     * @param encodingId Platform Encoding ID from NameRecord constants.
+     * @param languageId Language ID from NameRecord constants.
+     * @return name, or null
+     */
+    public String getName(int nameId, int platformId, int encodingId, int languageId)
+    {
+        Map<Integer, Map<Integer, Map<Integer, String>>> platforms = lookupTable.get(nameId);
+        if (platforms == null)
+        {
+            return null;
+        }
+        Map<Integer, Map<Integer, String>> encodings = platforms.get(platformId);
+        if (encodings == null)
+        {
+            return null;
+        }
+        Map<Integer, String> languages = encodings.get(encodingId);
+        if (languages == null)
+        {
+            return null;
+        }
+        return languages.get(languageId);
+    }
+
     /**
      * This will get the name records for this naming table.
-     * 
+     *
      * @return A list of NameRecord objects.
      */
     public List<NameRecord> getNameRecords()
@@ -135,9 +231,9 @@ public class NamingTable extends TTFTabl
     }
     
     /**
-     * Returns the font family name.
-     * 
-     * @return the font family name
+     * Returns the font family name, in English.
+     *
+     * @return the font family name, in English
      */
     public String getFontFamily()
     {
@@ -145,9 +241,9 @@ public class NamingTable extends TTFTabl
     }
 
     /**
-     * Returns the font sub family name.
-     * 
-     * @return the font sub family name
+     * Returns the font sub family name, in English.
+     *
+     * @return the font sub family name, in English
      */
     public String getFontSubFamily()
     {
@@ -155,13 +251,12 @@ public class NamingTable extends TTFTabl
     }
 
     /**
-     * Returns the postscript name.
-     * 
-     * @return the postscript name
+     * Returns the PostScript name.
+     *
+     * @return the PostScript name
      */
-    public String getPSName()
+    public String getPostScriptName()
     {
         return psName;
     }
-
 }

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/PostScriptTable.java Sun Aug 17 20:02:18 2014
@@ -24,7 +24,6 @@ import org.apache.fontbox.encoding.Encod
  * A table in a true type font.
  * 
  * @author Ben Litchfield (ben@benlitchfield.com)
- * 
  */
 public class PostScriptTable extends TTFTable
 {
@@ -68,8 +67,8 @@ public class PostScriptTable extends TTF
             /*
              * This TrueType font file contains exactly the 258 glyphs in the standard Macintosh TrueType.
              */
-            glyphNames = new String[Encoding.NUMBER_OF_MAC_GLYPHS];
-            System.arraycopy(Encoding.MAC_GLYPH_NAMES, 0, glyphNames, 0, Encoding.NUMBER_OF_MAC_GLYPHS);
+            glyphNames = new String[WGL4Names.NUMBER_OF_MAC_GLYPHS];
+            System.arraycopy(WGL4Names.MAC_GLYPH_NAMES, 0, glyphNames, 0, WGL4Names.NUMBER_OF_MAC_GLYPHS);
         }
         else if (formatType == 2.0f)
         {
@@ -89,10 +88,10 @@ public class PostScriptTable extends TTF
                 }
             }
             String[] nameArray = null;
-            if (maxIndex >= Encoding.NUMBER_OF_MAC_GLYPHS)
+            if (maxIndex >= WGL4Names.NUMBER_OF_MAC_GLYPHS)
             {
-                nameArray = new String[maxIndex - Encoding.NUMBER_OF_MAC_GLYPHS + 1];
-                for (int i = 0; i < maxIndex - Encoding.NUMBER_OF_MAC_GLYPHS + 1; i++)
+                nameArray = new String[maxIndex - WGL4Names.NUMBER_OF_MAC_GLYPHS + 1];
+                for (int i = 0; i < maxIndex - WGL4Names.NUMBER_OF_MAC_GLYPHS + 1; i++)
                 {
                     int numberOfChars = data.readUnsignedByte();
                     nameArray[i] = data.readString(numberOfChars);
@@ -101,13 +100,13 @@ public class PostScriptTable extends TTF
             for (int i = 0; i < numGlyphs; i++)
             {
                 int index = glyphNameIndex[i];
-                if (index < Encoding.NUMBER_OF_MAC_GLYPHS)
+                if (index < WGL4Names.NUMBER_OF_MAC_GLYPHS)
                 {
-                    glyphNames[i] = Encoding.MAC_GLYPH_NAMES[index];
+                    glyphNames[i] = WGL4Names.MAC_GLYPH_NAMES[index];
                 }
-                else if (index >= Encoding.NUMBER_OF_MAC_GLYPHS && index <= 32767)
+                else if (index >= WGL4Names.NUMBER_OF_MAC_GLYPHS && index <= 32767)
                 {
-                    glyphNames[i] = nameArray[index - Encoding.NUMBER_OF_MAC_GLYPHS];
+                    glyphNames[i] = nameArray[index - WGL4Names.NUMBER_OF_MAC_GLYPHS];
                 }
                 else
                 {
@@ -128,7 +127,7 @@ public class PostScriptTable extends TTF
             glyphNames = new String[glyphNameIndex.length];
             for (int i = 0; i < glyphNames.length; i++)
             {
-                String name = Encoding.MAC_GLYPH_NAMES[glyphNameIndex[i]];
+                String name = WGL4Names.MAC_GLYPH_NAMES[glyphNameIndex[i]];
                 if (name != null)
                 {
                     glyphNames[i] = name;

Copied: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java (from r1615712, pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubFont.java)
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java?p2=pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java&p1=pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubFont.java&r1=1615712&r2=1618516&rev=1618516&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubFont.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TTFSubsetter.java Sun Aug 17 20:02:18 2014
@@ -48,10 +48,9 @@ import org.apache.commons.logging.LogFac
  * Based on code developed by Wolfgang Glas
  * http://svn.clazzes.org/svn/sketch/trunk/pdf/pdf-entities/src/main/java/org/clazzes/sketch/pdf/entities/impl/TTFSubFont.java
  */
-public class TTFSubFont 
+public class TTFSubsetter
 {
-
-    private static final Log LOG = LogFactory.getLog(TTFSubFont.class);
+    private static final Log LOG = LogFactory.getLog(TTFSubsetter.class);
     private static final byte[] PAD_BUF = new byte[] {0,0,0};
     
     private final TrueTypeFont baseTTF;
@@ -71,7 +70,7 @@ public class TTFSubFont 
      * @param suffix suffix used for the naming
      * 
      */
-    public TTFSubFont(TrueTypeFont baseFont, String suffix) 
+    public TTFSubsetter(TrueTypeFont baseFont, String suffix)
     {
         baseTTF = baseFont;
         nameSuffix = suffix;
@@ -329,7 +328,7 @@ public class TTFSubFont 
     private static boolean replicateNameRecord(NameRecord nr) 
     {
         return nr.getPlatformId() == NameRecord.PLATFORM_WINDOWS 
-                && nr.getPlatformEncodingId() == NameRecord.PLATFORM_ENCODING_WINDOWS_UNICODE 
+                && nr.getPlatformEncodingId() == NameRecord.ENCODING_WINDOWS_UNICODE_BMP
                 && nr.getLanguageId() == 0 
                 && nr.getNameId() >= 0 && nr.getNameId() < 7;
     }
@@ -354,14 +353,14 @@ public class TTFSubFont 
             nameRecords = new ArrayList<NameRecord>();
             NameRecord nr = new NameRecord();
             nr.setPlatformId(NameRecord.PLATFORM_WINDOWS);
-            nr.setPlatformEncodingId(NameRecord.PLATFORM_ENCODING_WINDOWS_UNICODE);
+            nr.setPlatformEncodingId(NameRecord.ENCODING_WINDOWS_UNICODE_BMP);
             nr.setLanguageId(0);
             nr.setNameId(NameRecord.NAME_FONT_FAMILY_NAME);
             nr.setString("PDFBox-Dummy-Familyname");
             nameRecords.add(nr);
             nr = new NameRecord();
             nr.setPlatformId(NameRecord.PLATFORM_WINDOWS);
-            nr.setPlatformEncodingId(NameRecord.PLATFORM_ENCODING_WINDOWS_UNICODE);
+            nr.setPlatformEncodingId(NameRecord.ENCODING_WINDOWS_UNICODE_BMP);
             nr.setLanguageId(0);
             nr.setNameId(NameRecord.NAME_FULL_FONT_NAME);
             nr.setString("PDFBox-Dummy-Fullname");
@@ -983,7 +982,7 @@ public class TTFSubFont 
                 {
                     name = String.format(Locale.ENGLISH,"uni%04X",uc);
                 }
-                Integer macId = Encoding.MAC_GLYPH_NAMES_INDICES.get(name);
+                Integer macId = WGL4Names.MAC_GLYPH_NAMES_INDICES.get(name);
                 if (macId == null) 
                 {
                     Integer idx = additionalNamesIndices.get(name);
@@ -1006,7 +1005,7 @@ public class TTFSubFont 
             for (Integer glyphId : this.glyphIds) 
             {
                 String name = glyphNames[glyphId];
-                Integer macId = Encoding.MAC_GLYPH_NAMES_INDICES.get(name);
+                Integer macId = WGL4Names.MAC_GLYPH_NAMES_INDICES.get(name);
                 if (macId == null) 
                 {
                     Integer idx = additionalNamesIndices.get(name);

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/TrueTypeFont.java Sun Aug 17 20:02:18 2014
@@ -16,6 +16,8 @@
  */
 package org.apache.fontbox.ttf;
 
+import java.awt.geom.AffineTransform;
+import java.awt.geom.GeneralPath;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
@@ -24,13 +26,15 @@ import java.io.InputStream;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.fontbox.encoding.Encoding;
+import org.apache.fontbox.encoding.StandardEncoding;
 
 /**
  * A TrueType font file.
  * 
  * @author Ben Litchfield
  */
-public class TrueTypeFont 
+public class TrueTypeFont implements Type1Equivalent
 {
     private final Log log = LogFactory.getLog(TrueTypeFont.class);
 
@@ -40,6 +44,7 @@ public class TrueTypeFont 
     private int[] advanceWidths = null;
     private Map<String,TTFTable> tables = new HashMap<String,TTFTable>();
     private TTFDataStream data;
+    private Map<String, Integer> postScriptNames;
     
     /**
      * Constructor.  Clients should use the TTFParser to create a new TrueTypeFont object.
@@ -97,6 +102,16 @@ public class TrueTypeFont 
     {
         return tables.values();
     }
+
+    /**
+     * Get all of the tables.
+     *
+     * @return All of the tables.
+     */
+    public Map<String, TTFTable> getTableMap()
+    {
+        return tables;
+    }
     
     /**
      * This will get the naming table for the true type font.
@@ -362,4 +377,84 @@ public class TrueTypeFont 
             return advanceWidths[advanceWidths.length-1];
         }
     }
+
+    @Override
+    public String getFullName()
+    {
+        return getNaming().getPostScriptName();
+    }
+
+    private void readPostScriptNames()
+    {
+        if (postScriptNames == null)
+        {
+            postScriptNames = new HashMap<String, Integer>();
+            if (getPostScript() != null)
+            {
+                String[] names = getPostScript().getGlyphNames();
+                if (names != null)
+                {
+                    for (int i = 0; i < names.length; i++)
+                    {
+                        postScriptNames.put(names[i], i);
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public GeneralPath getPath(String name) throws IOException
+    {
+        readPostScriptNames();
+
+        GlyphData[] glyphs = getGlyph().getGlyphs();
+        Integer gid = postScriptNames.get(name);
+        if (gid == null || gid < 0 || gid >= glyphs.length)
+        {
+            gid = 0;
+        }
+
+        // some glyphs have no outlines (e.g. space, table, newline)
+        if (glyphs[gid] == null)
+        {
+            return new GeneralPath();
+        }
+        else
+        {
+            GeneralPath path = glyphs[gid].getPath();
+
+            // scale to 1000upem, per PostScript convention
+            // todo: we could do this with the PostScript "matrix" entry, later?
+            float scale = 1000f / getUnitsPerEm();
+            AffineTransform atScale = AffineTransform.getScaleInstance(scale, scale);
+            path.transform(atScale);
+
+            return path;
+        }
+    }
+
+    @Override
+    public boolean hasGlyph(String name)
+    {
+        readPostScriptNames();
+
+        Integer gid = postScriptNames.get(name);
+        GlyphData[] glyphs = getGlyph().getGlyphs();
+        return !(gid == null || gid < 0 || gid >= glyphs.length);
+    }
+
+    @Override
+    public Encoding getEncoding()
+    {
+        // todo: what to use? There isn't a built-in encoding really, could use the MacRoman cmap?
+        log.warn("Using StandardEncoding for Type 1-equivalent TTF");
+        return new StandardEncoding();
+    }
+
+    @Override
+    public String toString()
+    {
+        return getNaming().getPostScriptName();
+    }
 }

Added: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/Type1Equivalent.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/Type1Equivalent.java?rev=1618516&view=auto
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/Type1Equivalent.java (added)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/Type1Equivalent.java Sun Aug 17 20:02:18 2014
@@ -0,0 +1,39 @@
+package org.apache.fontbox.ttf;
+
+import org.apache.fontbox.encoding.Encoding;
+
+import java.awt.geom.GeneralPath;
+import java.io.IOException;
+
+/**
+ * A Type 1-equivalent font, i.e. a font which can access glyphs by their PostScript name.
+ * This is currently a minimal interface and could be expanded if needed.
+ *
+ * @author John Hewson
+ */
+public interface Type1Equivalent
+{
+    /**
+     * The PostScript name of the font.
+     */
+    public String getFullName();
+
+    /**
+     * Returns the Type 1 CharString for the character with the given name.
+     *
+     * @return glyph path
+     * @throws IOException if the path could not be read
+     */
+    public GeneralPath getPath(String name) throws IOException;
+
+    /**
+     * Returns true if the font contains the given glyph.
+     * @param name PostScript glyph name
+     */
+    public boolean hasGlyph(String name);
+
+    /**
+     * Returns the PostScript Encoding vector for the font.
+     */
+    public Encoding getEncoding();
+}

Added: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/WGL4Names.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/WGL4Names.java?rev=1618516&view=auto
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/WGL4Names.java (added)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/ttf/WGL4Names.java Sun Aug 17 20:02:18 2014
@@ -0,0 +1,78 @@
+package org.apache.fontbox.ttf;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Windows Glyph List 4 (WGL4) names for Mac glyphs.
+ */
+public class WGL4Names
+{
+    /**
+     * The number of standard mac glyph names.
+     */
+    public static final int NUMBER_OF_MAC_GLYPHS = 258;
+
+    /**
+     * The 258 standard mac glyph names a used in 'post' format 1 and 2.
+     */
+    public static final String[] MAC_GLYPH_NAMES = new String[]
+    {
+        ".notdef",".null", "nonmarkingreturn", "space", "exclam", "quotedbl",
+        "numbersign", "dollar", "percent", "ampersand", "quotesingle",
+        "parenleft", "parenright", "asterisk", "plus", "comma", "hyphen",
+        "period", "slash", "zero", "one", "two", "three", "four", "five",
+        "six", "seven", "eight", "nine", "colon", "semicolon", "less",
+        "equal", "greater", "question", "at", "A", "B", "C", "D", "E", "F",
+        "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S",
+        "T", "U", "V", "W", "X", "Y", "Z", "bracketleft", "backslash",
+        "bracketright", "asciicircum", "underscore", "grave", "a", "b",
+        "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o",
+        "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft",
+        "bar", "braceright", "asciitilde", "Adieresis", "Aring",
+        "Ccedilla", "Eacute", "Ntilde", "Odieresis", "Udieresis", "aacute",
+        "agrave", "acircumflex", "adieresis", "atilde", "aring",
+        "ccedilla", "eacute", "egrave", "ecircumflex", "edieresis",
+        "iacute", "igrave", "icircumflex", "idieresis", "ntilde", "oacute",
+        "ograve", "ocircumflex", "odieresis", "otilde", "uacute", "ugrave",
+        "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling",
+        "section", "bullet", "paragraph", "germandbls", "registered",
+        "copyright", "trademark", "acute", "dieresis", "notequal", "AE",
+        "Oslash", "infinity", "plusminus", "lessequal", "greaterequal",
+        "yen", "mu", "partialdiff", "summation", "product", "pi",
+        "integral", "ordfeminine", "ordmasculine", "Omega", "ae", "oslash",
+        "questiondown", "exclamdown", "logicalnot", "radical", "florin",
+        "approxequal", "Delta", "guillemotleft", "guillemotright",
+        "ellipsis", "nonbreakingspace", "Agrave", "Atilde", "Otilde", "OE",
+        "oe", "endash", "emdash", "quotedblleft", "quotedblright",
+        "quoteleft", "quoteright", "divide", "lozenge", "ydieresis",
+        "Ydieresis", "fraction", "currency", "guilsinglleft",
+        "guilsinglright", "fi", "fl", "daggerdbl", "periodcentered",
+        "quotesinglbase", "quotedblbase", "perthousand", "Acircumflex",
+        "Ecircumflex", "Aacute", "Edieresis", "Egrave", "Iacute",
+        "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex",
+        "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi",
+        "circumflex", "tilde", "macron", "breve", "dotaccent", "ring",
+        "cedilla", "hungarumlaut", "ogonek", "caron", "Lslash", "lslash",
+        "Scaron", "scaron", "Zcaron", "zcaron", "brokenbar", "Eth", "eth",
+        "Yacute", "yacute", "Thorn", "thorn", "minus", "multiply",
+        "onesuperior", "twosuperior", "threesuperior", "onehalf",
+        "onequarter", "threequarters", "franc", "Gbreve", "gbreve",
+        "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron",
+        "ccaron", "dcroat"
+    };
+
+    /**
+     * The indices of the standard mac glyph names.
+     */
+    public static Map<String,Integer> MAC_GLYPH_NAMES_INDICES;
+
+    static
+    {
+        MAC_GLYPH_NAMES_INDICES = new HashMap<String,Integer>();
+        for (int i = 0; i < NUMBER_OF_MAC_GLYPHS; ++i)
+        {
+            MAC_GLYPH_NAMES_INDICES.put(MAC_GLYPH_NAMES[i],i);
+        }
+    }
+}

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/type1/Type1Font.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/type1/Type1Font.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/type1/Type1Font.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/type1/Type1Font.java Sun Aug 17 20:02:18 2014
@@ -21,11 +21,12 @@ import org.apache.fontbox.cff.Type1CharS
 import org.apache.fontbox.cff.Type1CharStringParser;
 import org.apache.fontbox.encoding.Encoding;
 import org.apache.fontbox.pfb.PfbParser;
+import org.apache.fontbox.ttf.Type1Equivalent;
 
+import java.awt.geom.GeneralPath;
 import java.io.IOException;
 import java.io.InputStream;
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
@@ -37,7 +38,7 @@ import java.util.Map;
  *
  * @author John Hewson
  */
-public final class Type1Font implements Type1CharStringReader
+public final class Type1Font implements Type1CharStringReader, Type1Equivalent
 {
     /**
      * Constructs a new Type1Font object from a .pfb stream.
@@ -110,7 +111,6 @@ public final class Type1Font implements 
 
     // private caches
     private final Map<String, Type1CharString> charStringCache = new HashMap<String, Type1CharString>();
-    private Collection<Mapping> mappings;
 
     /**
      * Constructs a new Type1Font, called by Type1Parser.
@@ -139,112 +139,35 @@ public final class Type1Font implements 
         return Collections.unmodifiableMap(charstrings);
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public Type1CharString getType1CharString(String name) throws IOException
+    @Override
+    public GeneralPath getPath(String name) throws IOException
     {
-        Type1CharString type1 = charStringCache.get(name);
-        if (type1 == null)
-        {
-            Type1CharStringParser parser = new Type1CharStringParser(fontName, name);
-            List<Object> sequence = parser.parse(charstrings.get(name), subrs);
-            type1 = new Type1CharString(this, fontName, name, sequence);
-            charStringCache.put(name, type1);
-        }
-        return type1;
+        return getType1CharString(name).getPath();
     }
 
-    /**
-     * Get the mappings for the font as Type1Mapping.
-     *
-     * @return the Type1Mapping
-     */
-    public Collection<? extends Type1Mapping> getType1Mappings()
+    @Override
+    public boolean hasGlyph(String name)
     {
-        return getMappings();
+        return charstrings.get(name) != null;
     }
 
-    /**
-     * Get the mapping (code/charname/bytes) for this font.
-     *
-     * @return mappings for character codes
-     */
-    public Collection<Type1Font.Mapping> getMappings()
+    @Override
+    public Type1CharString getType1CharString(String name) throws IOException
     {
-        if (mappings == null)
+        Type1CharString type1 = charStringCache.get(name);
+        if (type1 == null)
         {
-            mappings = new ArrayList<Mapping>();
-            for (String name : getCharStringsDict().keySet())
+            byte[] bytes = charstrings.get(name);
+            if (bytes == null)
             {
-                Integer code = encoding.getCode(name);
-                if (code == null)
-                {
-                    code = 0; // .notdef
-                }
-                Mapping mapping = new Mapping();
-                mapping.setCode(code);
-                mapping.setName(name);
-                mapping.setBytes(getCharStringsDict().get(name));
-                mappings.add(mapping);
+                bytes = charstrings.get(".notdef");
             }
-            mappings = Collections.unmodifiableCollection(mappings);
-        }
-        return mappings;
-    }
-
-    public class Mapping implements Type1Mapping
-    {
-        private int mappedCode;
-        private String mappedName;
-        private byte[] mappedBytes;
-
-        /**
-         * {@inheritDoc}
-         */
-        public Type1CharString getType1CharString() throws IOException
-        {
-            return Type1Font.this.getType1CharString(mappedName);
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public int getCode()
-        {
-            return mappedCode;
-        }
-
-        private void setCode(int code)
-        {
-            mappedCode = code;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public String getName()
-        {
-            return mappedName;
-        }
-
-        private void setName(String name)
-        {
-            this.mappedName = name;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public byte[] getBytes()
-        {
-            return mappedBytes;
-        }
-
-        private void setBytes(byte[] bytes)
-        {
-            this.mappedBytes = bytes;
+            Type1CharStringParser parser = new Type1CharStringParser(fontName, name);
+            List<Object> sequence = parser.parse(bytes, subrs);
+            type1 = new Type1CharString(this, fontName, name, sequence);
+            charStringCache.put(name, type1);
         }
+        return type1;
     }
 
     // font dictionary
@@ -365,6 +288,7 @@ public final class Type1Font implements 
      * 
      * @return the full name
      */
+    @Override
     public String getFullName()
     {
         return fullName;

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontDirFinder.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontDirFinder.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontDirFinder.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontDirFinder.java Sun Aug 17 20:02:18 2014
@@ -18,24 +18,23 @@
 package org.apache.fontbox.util.autodetect;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
 /**
- * Implementers provide find method for searching native operating system for available fonts. This class is based on a
- * class provided by Apache FOP. see org.apache.fop.fonts.autodetect.FontDirFinder
+ * Implementers provide find method for searching native operating system for available fonts.
+ * This class is based on a class provided by Apache FOP.
+ *
+ * See org.apache.fop.fonts.autodetect.FontDirFinder
  */
 public interface FontDirFinder
 {
-
     /**
      * Finds a list of font files.
      * 
      * @return list of font files.
-     * @throws IOException In case of an I/O problem
      */
-    List<File> find() throws IOException;
+    List<File> find();
 
     /**
      * Provides a list of platform specific ttf name mappings.
@@ -43,5 +42,4 @@ public interface FontDirFinder
      * @return a fontname mapping
      */
     Map<String, String> getCommonTTFMapping();
-
 }

Modified: pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontFileFinder.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontFileFinder.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontFileFinder.java (original)
+++ pdfbox/no-awt/fontbox/src/main/java/org/apache/fontbox/util/autodetect/FontFileFinder.java Sun Aug 17 20:02:18 2014
@@ -63,9 +63,8 @@ public class FontFileFinder
      * Automagically finds a list of font files on local system.
      * 
      * @return List&lt;URI&gt; of font files
-     * @throws IOException thrown if an I/O exception of some sort has occurred
      */
-    public List<URI> find() throws IOException
+    public List<URI> find()
     {
         if (fontDirFinder == null)
         {
@@ -85,9 +84,8 @@ public class FontFileFinder
      * 
      * @param dir directory to search
      * @return list&lt;URI&gt; of font files
-     * @throws IOException thrown if an I/O exception of some sort has occurred
      */
-    public List<URI> find(String dir) throws IOException
+    public List<URI> find(String dir)
     {
         List<URI> results = new java.util.ArrayList<URI>();
         File directory = new File(dir);
@@ -154,7 +152,7 @@ public class FontFileFinder
     /**
      * Check if the given name belongs to a font file.
      * 
-     * @param filename the given filename
+     * @param file the given file
      * @return true if the given filename has a typical font file ending
      */
     private boolean checkFontfile(File file)

Modified: pdfbox/no-awt/pdfbox/src/main/java/org/apache/pdfbox/encoding/DictionaryEncoding.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/pdfbox/src/main/java/org/apache/pdfbox/encoding/DictionaryEncoding.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/pdfbox/src/main/java/org/apache/pdfbox/encoding/DictionaryEncoding.java (original)
+++ pdfbox/no-awt/pdfbox/src/main/java/org/apache/pdfbox/encoding/DictionaryEncoding.java Sun Aug 17 20:02:18 2014
@@ -27,8 +27,7 @@ import org.apache.pdfbox.cos.COSNumber;
 /**
  * This will perform the encoding from a dictionary.
  *
- * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
- * @version $Revision: 1.13 $
+ * @author Ben Litchfield
  */
 public class DictionaryEncoding extends Encoding
 {
@@ -45,15 +44,15 @@ public class DictionaryEncoding extends 
     {
         encoding = fontEncoding;
 
-        //first set up the base encoding
-        //The previious value WinAnsiEncoding() has been changed to StandardEnding
-        //see p 389 of the PDF 1.5 ref�rence table 5.11 entries in a dictionary encoding
-        //"If this entry is absent, the Differences entry describes differences from an implicit
-        //base encoding. For a font program that is embedded in the PDF file, the
-        //implicit base encoding is the font program�s built-in encoding, as described
-        //above and further elaborated in the sections on specific font types below. Otherwise,
-        //for a nonsymbolic font, it is StandardEncoding, and for a symbolic font, it
-        //is the font�s built-in encoding."
+        // first set up the base encoding
+        // The previous value WinAnsiEncoding() has been changed to StandardEnding
+        // see p 389 of the PDF 1.5 reference table 5.11 entries in a dictionary encoding
+        // "If this entry is absent, the Differences entry describes differences from an implicit
+        // base encoding. For a font program that is embedded in the PDF file, the
+        // implicit base encoding is the font program's built-in encoding, as described
+        // above and further elaborated in the sections on specific font types below. Otherwise,
+        // for a nonsymbolic font, it is StandardEncoding, and for a symbolic font, it
+        // is the font's built-in encoding."
 
         // The default base encoding is standardEncoding
         Encoding baseEncoding = StandardEncoding.INSTANCE;

Modified: pdfbox/no-awt/pdfbox/src/main/java/org/apache/pdfbox/encoding/Encoding.java
URL: http://svn.apache.org/viewvc/pdfbox/no-awt/pdfbox/src/main/java/org/apache/pdfbox/encoding/Encoding.java?rev=1618516&r1=1618515&r2=1618516&view=diff
==============================================================================
--- pdfbox/no-awt/pdfbox/src/main/java/org/apache/pdfbox/encoding/Encoding.java (original)
+++ pdfbox/no-awt/pdfbox/src/main/java/org/apache/pdfbox/encoding/Encoding.java Sun Aug 17 20:02:18 2014
@@ -227,9 +227,7 @@ public abstract class Encoding implement
      * This will get the character code for the name.
      * 
      * @param name The name of the character.
-     * 
      * @return The code for the character.
-     * 
      * @throws IOException If there is no character code for the name.
      */
     public int getCode(String name) throws IOException
@@ -237,6 +235,7 @@ public abstract class Encoding implement
         Integer code = nameToCode.get(name);
         if (code == null)
         {
+            // todo: would be much better to return null
             throw new IOException("No character code for character name '" + name + "'");
         }
         return code;
@@ -246,12 +245,9 @@ public abstract class Encoding implement
      * This will take a character code and get the name from the code.
      * 
      * @param code The character code.
-     * 
      * @return The name of the character.
-     * 
-     * @throws IOException If there is no name for the code.
      */
-    public String getName(int code) throws IOException
+    public String getName(int code)
     {
         return codeToName.get(code);
     }
@@ -260,9 +256,7 @@ public abstract class Encoding implement
      * This will take a character code and get the name from the code.
      * 
      * @param c The character.
-     * 
      * @return The name of the character.
-     * 
      * @throws IOException If there is no name for the character.
      */
     public String getNameForCharacter(char c) throws IOException
@@ -279,9 +273,7 @@ public abstract class Encoding implement
      * This will take a name and get the character code for that name.
      * 
      * @param name The name.
-     * 
      * @return The name of the character.
-     * 
      */
     public static String getCharacterForName(String name)
     {
@@ -291,7 +283,7 @@ public abstract class Encoding implement
         }
         if (LOG.isDebugEnabled())
         {
-            LOG.debug("No character for name " + name);
+            LOG.warn("No character for name " + name);
         }
         return null;
     }
@@ -300,9 +292,7 @@ public abstract class Encoding implement
      * This will get the character from the code.
      * 
      * @param code The character code.
-     * 
      * @return The printable character for the code.
-     * 
      * @throws IOException If there is not name for the character.
      */
     public String getCharacter(int code) throws IOException
@@ -319,7 +309,6 @@ public abstract class Encoding implement
      * This will get the character from the name.
      * 
      * @param name The name of the character.
-     * 
      * @return The printable character for the code.
      */
     public String getCharacter(String name)