예제 #1
0
        virtual public String DecodeSequence(CMapSequence seq)
        {
            StringBuilder sb  = new StringBuilder();
            int           cid = 0;

            while ((cid = DecodeSingle(seq)) >= 0)
            {
                sb.Append((char)cid);
            }
            return(sb.ToString());
        }
예제 #2
0
        /**
         *
         * @param seq
         * @return the cid code or -1 for end
         */
        virtual public int DecodeSingle(CMapSequence seq)
        {
            int end          = seq.off + seq.len;
            int currentPlane = 0;

            while (seq.off < end)
            {
                int one = seq.seq[seq.off++] & 0xff;
                --seq.len;
                char[] plane = planes[currentPlane];
                int    cid   = plane[one];
                if ((cid & 0x8000) == 0)
                {
                    return(cid);
                }
                else
                {
                    currentPlane = cid & 0x7fff;
                }
            }
            return(-1);
        }
예제 #3
0
 /**
  * Decodes a string of bytes (encoded in the font's encoding) into a unicode string
  * This will use the ToUnicode map of the font, if available, otherwise it uses
  * the font's encoding
  * @param cidbytes    the bytes that need to be decoded
  * @return  the unicode String that results from decoding
  * @since 2.1.7
  */
 public String Decode(byte[] cidbytes, int offset, int len){
     StringBuilder sb = new StringBuilder();
     if (toUnicodeCmap == null && byteCid != null) {
         CMapSequence seq = new CMapSequence(cidbytes, offset, len);
         String cid = byteCid.DecodeSequence(seq);
         foreach (char ca in cid) {
             int c = cidUni.Lookup(ca);
             if (c > 0)
                 sb.Append(Utilities.ConvertFromUtf32(c));
         }
     }
     else {
         for (int i = offset; i < offset + len; i++){
             String rslt = DecodeSingleCID(cidbytes, i, 1);
             if (rslt == null && i < offset + len - 1){
                 rslt = DecodeSingleCID(cidbytes, i, 2);
                 i++;
             }
             if (rslt != null)
                 sb.Append(rslt);
         }
     }
     return sb.ToString();
 }
예제 #4
0
 /**
  * 
  * @param seq
  * @return the cid code or -1 for end
  */
 virtual public int DecodeSingle(CMapSequence seq) {
     int end = seq.off + seq.len;
     int currentPlane = 0;
     while (seq.off < end) {
         int one = seq.seq[seq.off++] & 0xff;
         --seq.len;
         char[] plane = planes[currentPlane];
         int cid = plane[one];
         if ((cid & 0x8000) == 0) {
             return cid;
         }
         else
             currentPlane = cid & 0x7fff;
     }
     return -1;
 }
예제 #5
0
 virtual public String DecodeSequence(CMapSequence seq) {
     StringBuilder sb = new StringBuilder();
     int cid = 0;
     while ((cid = DecodeSingle(seq)) >= 0) {
         sb.Append((char)cid);
     }
     return sb.ToString();
 }
 /**
  * ! .NET SPECIFIC; this method is used to avoid unecessary using of StringBuilder because it is slow in .NET !
  * Decodes a single character string of bytes (encoded in the font's encoding) into a unicode string
  * This will use the ToUnicode map of the font, if available, otherwise it uses
  * the font's encoding
  * @param cidbytes    the bytes that need to be decoded
  * @return  the unicode String that results from decoding
  */
 virtual public String DecodeSingleCharacter(byte[] cidbytes, int offset, int len) {
     string s = "";
     if (toUnicodeCmap == null && byteCid != null) {
         CMapSequence seq = new CMapSequence(cidbytes, offset, len);
         int ca = byteCid.DecodeSingle(seq);
         if (ca >= 0) {
             int c = cidUni.Lookup(ca);
             if (c > 0)
                 s = Utilities.ConvertFromUtf32(c);
         }
     } else {
         String rslt = DecodeSingleCID(cidbytes, offset, 1);
         if (rslt == null && len > 1) {
             rslt = DecodeSingleCID(cidbytes, offset, 2);
         }
         if (rslt != null)
             s = rslt;
     }
     return s;
 }