pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From msahy...@apache.org
Subject svn commit: r1704411 - /pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/WinAnsiEncoding.java
Date Mon, 21 Sep 2015 19:56:12 GMT
Author: msahyoun
Date: Mon Sep 21 19:56:11 2015
New Revision: 1704411

URL: http://svn.apache.org/viewvc?rev=1704411&view=rev
Log:
PDFBOX-2852: declare encoding in static table

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/WinAnsiEncoding.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/WinAnsiEncoding.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/WinAnsiEncoding.java?rev=1704411&r1=1704410&r2=1704411&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/WinAnsiEncoding.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/font/encoding/WinAnsiEncoding.java
Mon Sep 21 19:56:11 2015
@@ -27,6 +27,234 @@ import org.apache.pdfbox.cos.COSName;
 public class WinAnsiEncoding extends Encoding
 {
 
+    private static final int CHAR_CODE = 0;
+    private static final int CHAR_NAME = 1;
+    
+    /**
+     * Table of octal character codes and their corresponding names.
+     */
+    public static final Object[][] WIN_ANSI_ENCODING_TABLE = {
+            {0101, "A"},
+            {0306, "AE"},
+            {0301, "Aacute"},
+            {0302, "Acircumflex"},
+            {0304, "Adieresis"},
+            {0300, "Agrave"},
+            {0305, "Aring"},
+            {0303, "Atilde"},
+            {0102, "B"},
+            {0103, "C"},
+            {0307, "Ccedilla"},
+            {0104, "D"},
+            {0105, "E"},
+            {0311, "Eacute"},
+            {0312, "Ecircumflex"},
+            {0313, "Edieresis"},
+            {0310, "Egrave"},
+            {0320, "Eth"},
+            {0200, "Euro"},
+            {0106, "F"},
+            {0107, "G"},
+            {0110, "H"},
+            {0111, "I"},
+            {0315, "Iacute"},
+            {0316, "Icircumflex"},
+            {0317, "Idieresis"},
+            {0314, "Igrave"},
+            {0112, "J"},
+            {0113, "K"},
+            {0114, "L"},
+            {0115, "M"},
+            {0116, "N"},
+            {0321, "Ntilde"},
+            {0117, "O"},
+            {0214, "OE"},
+            {0323, "Oacute"},
+            {0324, "Ocircumflex"},
+            {0326, "Odieresis"},
+            {0322, "Ograve"},
+            {0330, "Oslash"},
+            {0325, "Otilde"},
+            {0120, "P"},
+            {0121, "Q"},
+            {0122, "R"},
+            {0123, "S"},
+            {0212, "Scaron"},
+            {0124, "T"},
+            {0336, "Thorn"},
+            {0125, "U"},
+            {0332, "Uacute"},
+            {0333, "Ucircumflex"},
+            {0334, "Udieresis"},
+            {0331, "Ugrave"},
+            {0126, "V"},
+            {0127, "W"},
+            {0130, "X"},
+            {0131, "Y"},
+            {0335, "Yacute"},
+            {0237, "Ydieresis"},
+            {0132, "Z"},
+            {0216, "Zcaron"},
+            {0141, "a"},
+            {0341, "aacute"},
+            {0342, "acircumflex"},
+            {0264, "acute"},
+            {0344, "adieresis"},
+            {0346, "ae"},
+            {0340, "agrave"},
+            {046, "ampersand"},
+            {0345, "aring"},
+            {0136, "asciicircum"},
+            {0176, "asciitilde"},
+            {052, "asterisk"},
+            {0100, "at"},
+            {0343, "atilde"},
+            {0142, "b"},
+            {0134, "backslash"},
+            {0174, "bar"},
+            {0173, "braceleft"},
+            {0175, "braceright"},
+            {0133, "bracketleft"},
+            {0135, "bracketright"},
+            {0246, "brokenbar"},
+            {0225, "bullet"},
+            {0143, "c"},
+            {0347, "ccedilla"},
+            {0270, "cedilla"},
+            {0242, "cent"},
+            {0210, "circumflex"},
+            {072, "colon"},
+            {054, "comma"},
+            {0251, "copyright"},
+            {0244, "currency"},
+            {0144, "d"},
+            {0206, "dagger"},
+            {0207, "daggerdbl"},
+            {0260, "degree"},
+            {0250, "dieresis"},
+            {0367, "divide"},
+            {044, "dollar"},
+            {0145, "e"},
+            {0351, "eacute"},
+            {0352, "ecircumflex"},
+            {0353, "edieresis"},
+            {0350, "egrave"},
+            {070, "eight"},
+            {0205, "ellipsis"},
+            {0227, "emdash"},
+            {0226, "endash"},
+            {075, "equal"},
+            {0360, "eth"},
+            {041, "exclam"},
+            {0241, "exclamdown"},
+            {0146, "f"},
+            {065, "five"},
+            {0203, "florin"},
+            {064, "four"},
+            {0147, "g"},
+            {0337, "germandbls"},
+            {0140, "grave"},
+            {076, "greater"},
+            {0253, "guillemotleft"},
+            {0273, "guillemotright"},
+            {0213, "guilsinglleft"},
+            {0233, "guilsinglright"},
+            {0150, "h"},
+            {055, "hyphen"},
+            {0151, "i"},
+            {0355, "iacute"},
+            {0356, "icircumflex"},
+            {0357, "idieresis"},
+            {0354, "igrave"},
+            {0152, "j"},
+            {0153, "k"},
+            {0154, "l"},
+            {074, "less"},
+            {0254, "logicalnot"},
+            {0155, "m"},
+            {0257, "macron"},
+            {0265, "mu"},
+            {0327, "multiply"},
+            {0156, "n"},
+            {071, "nine"},
+            {0361, "ntilde"},
+            {043, "numbersign"},
+            {0157, "o"},
+            {0363, "oacute"},
+            {0364, "ocircumflex"},
+            {0366, "odieresis"},
+            {0234, "oe"},
+            {0362, "ograve"},
+            {061, "one"},
+            {0275, "onehalf"},
+            {0274, "onequarter"},
+            {0271, "onesuperior"},
+            {0252, "ordfeminine"},
+            {0272, "ordmasculine"},
+            {0370, "oslash"},
+            {0365, "otilde"},
+            {0160, "p"},
+            {0266, "paragraph"},
+            {050, "parenleft"},
+            {051, "parenright"},
+            {045, "percent"},
+            {056, "period"},
+            {0267, "periodcentered"},
+            {0211, "perthousand"},
+            {053, "plus"},
+            {0261, "plusminus"},
+            {0161, "q"},
+            {077, "question"},
+            {0277, "questiondown"},
+            {042, "quotedbl"},
+            {0204, "quotedblbase"},
+            {0223, "quotedblleft"},
+            {0224, "quotedblright"},
+            {0221, "quoteleft"},
+            {0222, "quoteright"},
+            {0202, "quotesinglbase"},
+            {047, "quotesingle"},
+            {0162, "r"},
+            {0256, "registered"},
+            {0163, "s"},
+            {0232, "scaron"},
+            {0247, "section"},
+            {073, "semicolon"},
+            {067, "seven"},
+            {066, "six"},
+            {057, "slash"},
+            {040, "space"},
+            {0243, "sterling"},
+            {0164, "t"},
+            {0376, "thorn"},
+            {063, "three"},
+            {0276, "threequarters"},
+            {0263, "threesuperior"},
+            {0230, "tilde"},
+            {0231, "trademark"},
+            {062, "two"},
+            {0262, "twosuperior"},
+            {0165, "u"},
+            {0372, "uacute"},
+            {0373, "ucircumflex"},
+            {0374, "udieresis"},
+            {0371, "ugrave"},
+            {0137, "underscore"},
+            {0166, "v"},
+            {0167, "w"},
+            {0170, "x"},
+            {0171, "y"},
+            {0375, "yacute"},
+            {0377, "ydieresis"},
+            {0245, "yen"},
+            {0172, "z"},
+            {0236, "zcaron"},
+            {060, "zero"},
+            // adding some additional mappings as defined in Appendix D of the pdf spec
+            {0240, "space"},
+            {0255, "hyphen"}
+    };
+
     /**
      * Singleton instance of this class.
      * 
@@ -39,225 +267,11 @@ public class WinAnsiEncoding extends Enc
      */
     public WinAnsiEncoding()
     {
-        add(0101, "A");
-        add(0306, "AE");
-        add(0301, "Aacute");
-        add(0302, "Acircumflex");
-        add(0304, "Adieresis");
-        add(0300, "Agrave");
-        add(0305, "Aring");
-        add(0303, "Atilde");
-        add(0102, "B");
-        add(0103, "C");
-        add(0307, "Ccedilla");
-        add(0104, "D");
-        add(0105, "E");
-        add(0311, "Eacute");
-        add(0312, "Ecircumflex");
-        add(0313, "Edieresis");
-        add(0310, "Egrave");
-        add(0320, "Eth");
-        add(0200, "Euro");
-        add(0106, "F");
-        add(0107, "G");
-        add(0110, "H");
-        add(0111, "I");
-        add(0315, "Iacute");
-        add(0316, "Icircumflex");
-        add(0317, "Idieresis");
-        add(0314, "Igrave");
-        add(0112, "J");
-        add(0113, "K");
-        add(0114, "L");
-        add(0115, "M");
-        add(0116, "N");
-        add(0321, "Ntilde");
-        add(0117, "O");
-        add(0214, "OE");
-        add(0323, "Oacute");
-        add(0324, "Ocircumflex");
-        add(0326, "Odieresis");
-        add(0322, "Ograve");
-        add(0330, "Oslash");
-        add(0325, "Otilde");
-        add(0120, "P");
-        add(0121, "Q");
-        add(0122, "R");
-        add(0123, "S");
-        add(0212, "Scaron");
-        add(0124, "T");
-        add(0336, "Thorn");
-        add(0125, "U");
-        add(0332, "Uacute");
-        add(0333, "Ucircumflex");
-        add(0334, "Udieresis");
-        add(0331, "Ugrave");
-        add(0126, "V");
-        add(0127, "W");
-        add(0130, "X");
-        add(0131, "Y");
-        add(0335, "Yacute");
-        add(0237, "Ydieresis");
-        add(0132, "Z");
-        add(0216, "Zcaron");
-        add(0141, "a");
-        add(0341, "aacute");
-        add(0342, "acircumflex");
-        add(0264, "acute");
-        add(0344, "adieresis");
-        add(0346, "ae");
-        add(0340, "agrave");
-        add(046, "ampersand");
-        add(0345, "aring");
-        add(0136, "asciicircum");
-        add(0176, "asciitilde");
-        add(052, "asterisk");
-        add(0100, "at");
-        add(0343, "atilde");
-        add(0142, "b");
-        add(0134, "backslash");
-        add(0174, "bar");
-        add(0173, "braceleft");
-        add(0175, "braceright");
-        add(0133, "bracketleft");
-        add(0135, "bracketright");
-        add(0246, "brokenbar");
-        add(0225, "bullet");
-        add(0143, "c");
-        add(0347, "ccedilla");
-        add(0270, "cedilla");
-        add(0242, "cent");
-        add(0210, "circumflex");
-        add(072, "colon");
-        add(054, "comma");
-        add(0251, "copyright");
-        add(0244, "currency");
-        add(0144, "d");
-        add(0206, "dagger");
-        add(0207, "daggerdbl");
-        add(0260, "degree");
-        add(0250, "dieresis");
-        add(0367, "divide");
-        add(044, "dollar");
-        add(0145, "e");
-        add(0351, "eacute");
-        add(0352, "ecircumflex");
-        add(0353, "edieresis");
-        add(0350, "egrave");
-        add(070, "eight");
-        add(0205, "ellipsis");
-        add(0227, "emdash");
-        add(0226, "endash");
-        add(075, "equal");
-        add(0360, "eth");
-        add(041, "exclam");
-        add(0241, "exclamdown");
-        add(0146, "f");
-        add(065, "five");
-        add(0203, "florin");
-        add(064, "four");
-        add(0147, "g");
-        add(0337, "germandbls");
-        add(0140, "grave");
-        add(076, "greater");
-        add(0253, "guillemotleft");
-        add(0273, "guillemotright");
-        add(0213, "guilsinglleft");
-        add(0233, "guilsinglright");
-        add(0150, "h");
-        add(055, "hyphen");
-        add(0151, "i");
-        add(0355, "iacute");
-        add(0356, "icircumflex");
-        add(0357, "idieresis");
-        add(0354, "igrave");
-        add(0152, "j");
-        add(0153, "k");
-        add(0154, "l");
-        add(074, "less");
-        add(0254, "logicalnot");
-        add(0155, "m");
-        add(0257, "macron");
-        add(0265, "mu");
-        add(0327, "multiply");
-        add(0156, "n");
-        add(071, "nine");
-        add(0361, "ntilde");
-        add(043, "numbersign");
-        add(0157, "o");
-        add(0363, "oacute");
-        add(0364, "ocircumflex");
-        add(0366, "odieresis");
-        add(0234, "oe");
-        add(0362, "ograve");
-        add(061, "one");
-        add(0275, "onehalf");
-        add(0274, "onequarter");
-        add(0271, "onesuperior");
-        add(0252, "ordfeminine");
-        add(0272, "ordmasculine");
-        add(0370, "oslash");
-        add(0365, "otilde");
-        add(0160, "p");
-        add(0266, "paragraph");
-        add(050, "parenleft");
-        add(051, "parenright");
-        add(045, "percent");
-        add(056, "period");
-        add(0267, "periodcentered");
-        add(0211, "perthousand");
-        add(053, "plus");
-        add(0261, "plusminus");
-        add(0161, "q");
-        add(077, "question");
-        add(0277, "questiondown");
-        add(042, "quotedbl");
-        add(0204, "quotedblbase");
-        add(0223, "quotedblleft");
-        add(0224, "quotedblright");
-        add(0221, "quoteleft");
-        add(0222, "quoteright");
-        add(0202, "quotesinglbase");
-        add(047, "quotesingle");
-        add(0162, "r");
-        add(0256, "registered");
-        add(0163, "s");
-        add(0232, "scaron");
-        add(0247, "section");
-        add(073, "semicolon");
-        add(067, "seven");
-        add(066, "six");
-        add(057, "slash");
-        add(040, "space");
-        add(0243, "sterling");
-        add(0164, "t");
-        add(0376, "thorn");
-        add(063, "three");
-        add(0276, "threequarters");
-        add(0263, "threesuperior");
-        add(0230, "tilde");
-        add(0231, "trademark");
-        add(062, "two");
-        add(0262, "twosuperior");
-        add(0165, "u");
-        add(0372, "uacute");
-        add(0373, "ucircumflex");
-        add(0374, "udieresis");
-        add(0371, "ugrave");
-        add(0137, "underscore");
-        add(0166, "v");
-        add(0167, "w");
-        add(0170, "x");
-        add(0171, "y");
-        add(0375, "yacute");
-        add(0377, "ydieresis");
-        add(0245, "yen");
-        add(0172, "z");
-        add(0236, "zcaron");
-        add(060, "zero");
-        // adding some additional mappings as defined in Appendix D of the pdf spec
-        add(0240, "space");
-        add(0255, "hyphen");
+        for (Object[] encodingEntry : WIN_ANSI_ENCODING_TABLE)
+        {
+            add((Integer) encodingEntry[CHAR_CODE], encodingEntry[CHAR_NAME].toString());
+        }
+
         for (int i = 041; i <= 255; i++)
         {
             if (!codeToName.containsKey(i))



Mime
View raw message