Beispiel #1
0
        /** Gets the kerning between two Unicode characters. The characters
         * are converted to names and this names are used to find the kerning
         * pairs in the <CODE>Hashtable</CODE> <CODE>KernPairs</CODE>.
         * @param char1 the first char
         * @param char2 the second char
         * @return the kerning to be applied
         */
        public override int getKerning(char char1, char char2)
        {
            string first = GlyphList.unicodeToName((int)char1);

            if (first == null)
            {
                return(0);
            }
            string second = GlyphList.unicodeToName((int)char2);

            if (second == null)
            {
                return(0);
            }
            Object[] obj = (Object[])KernPairs[first];
            if (obj == null)
            {
                return(0);
            }
            for (int k = 0; k < obj.Length; k += 2)
            {
                if (second.Equals(obj[k]))
                {
                    return((int)obj[k + 1]);
                }
            }
            return(0);
        }
Beispiel #2
0
 /**
  * Creates the <CODE>widths</CODE> and the <CODE>differences</CODE> arrays
  * @throws UnsupportedEncodingException the encoding is not supported
  */
 protected void createEncoding()
 {
     if (fontSpecific)
     {
         for (int k = 0; k < 256; ++k)
         {
             widths[k] = getRawWidth(k, null);
         }
     }
     else
     {
         string s;
         string name;
         char   c;
         byte[] b = new byte[1];
         for (int k = 0; k < 256; ++k)
         {
             b[0] = (byte)k;
             s    = System.Text.Encoding.GetEncoding(encoding).GetString(b);
             if (s.Length > 0)
             {
                 c = s[0];
             }
             else
             {
                 c = '?';
             }
             name = GlyphList.unicodeToName((int)c);
             if (name == null)
             {
                 name = notdef;
             }
             differences[k]             = name;
             this.UnicodeDifferences[k] = c;
             widths[k] = getRawWidth((int)c, name);
         }
     }
 }