예제 #1
0
 internal override void AddChar(String mark, CMapObject code)
 {
     try {
         if (mark.Length == 1)
         {
             char[] dest = CreateCharsFromDoubleBytes((byte[])code.GetValue());
             byteMappings.Put((int)mark[0], dest);
         }
         else
         {
             if (mark.Length == 2)
             {
                 char[] dest = CreateCharsFromDoubleBytes((byte[])code.GetValue());
                 byteMappings.Put((mark[0] << 8) + mark[1], dest);
             }
             else
             {
                 ILog logger = LogManager.GetLogger(typeof(iText.IO.Font.Cmap.CMapToUnicode));
                 logger.Warn(iText.IO.LogMessageConstant.TOUNICODE_CMAP_MORE_THAN_2_BYTES_NOT_SUPPORTED);
             }
         }
     }
     catch (System.IO.IOException) {
         throw new Exception();
     }
 }
예제 #2
0
 public static String DecodeCMapObject(CMapObject cMapObject)
 {
     if (cMapObject.IsHexString())
     {
         return(PdfEncodings.ConvertToString(((String)cMapObject.GetValue()).GetBytes(), PdfEncodings.UNICODE_BIG_UNMARKED
                                             ));
     }
     else
     {
         return((String)cMapObject.GetValue());
     }
 }
예제 #3
0
 internal override void AddChar(String mark, CMapObject code)
 {
     if (code.IsNumber())
     {
         EncodeSequence(DecodeStringToByte(mark), (char)code.GetValue());
     }
 }
예제 #4
0
 internal override void AddChar(String mark, CMapObject code)
 {
     if (code.IsNumber())
     {
         byte[] ser = DecodeStringToByte(mark);
         map.Put((int)code.GetValue(), ser);
     }
 }
예제 #5
0
        internal virtual void AddRange(String from, String to, CMapObject code)
        {
            byte[] a1 = DecodeStringToByte(from);
            byte[] a2 = DecodeStringToByte(to);
            if (a1.Length != a2.Length || a1.Length == 0)
            {
                throw new ArgumentException("Invalid map.");
            }
            byte[] sout = null;
            if (code.IsString())
            {
                sout = DecodeStringToByte(code.ToString());
            }
            int start = ByteArrayToInt(a1);
            int end   = ByteArrayToInt(a2);

            for (int k = start; k <= end; ++k)
            {
                IntToByteArray(k, a1);
                String mark = PdfEncodings.ConvertToString(a1, null);
                if (code.IsArray())
                {
                    IList <CMapObject> codes = (List <CMapObject>)code.GetValue();
                    AddChar(mark, codes[k - start]);
                }
                else
                {
                    if (code.IsNumber())
                    {
                        int nn = (int)code.GetValue() + k - start;
                        AddChar(mark, new CMapObject(CMapObject.NUMBER, nn));
                    }
                    else
                    {
                        if (code.IsString())
                        {
                            CMapObject s1 = new CMapObject(CMapObject.HEX_STRING, sout);
                            AddChar(mark, s1);
                            System.Diagnostics.Debug.Assert(sout != null);
                            IntToByteArray(ByteArrayToInt(sout) + 1, sout);
                        }
                    }
                }
            }
        }
예제 #6
0
 internal override void AddChar(String mark, CMapObject code)
 {
     if (code.IsNumber())
     {
         int    codePoint;
         String s = ToUnicodeString(mark, true);
         if (iText.IO.Util.TextUtil.IsSurrogatePair(s, 0))
         {
             codePoint = iText.IO.Util.TextUtil.ConvertToUtf32(s, 0);
         }
         else
         {
             codePoint = (int)s[0];
         }
         map.Put(codePoint, (int)code.GetValue());
     }
 }