Пример #1
0
        public void Get_ReturnsValueFromCollidingKey(Object keyOne, Object keyTwo)
        {
            Hashmap map = new Hashmap(1024);

            map.Add(keyOne, 1);
            map.Add(keyTwo, 2);
            Assert.Equal(2, map.Get(keyTwo));
        }
Пример #2
0
        public void Add_AddsCollidingPairs(Object keyOne, Object keyTwo, Object value)
        {
            Hashmap map = new Hashmap(1024);

            map.Add(keyOne, value);
            map.Add(keyTwo, value);
            Assert.Equal(map.Buckets[(int)value].Find(keyOne), map.Buckets[(int)value].Find(keyTwo));
        }
Пример #3
0
        public void Get_ReturnsNullWhenNotPresent()
        {
            Hashmap map = new Hashmap(1024);

            map.Add("key", 1);
            map.Add("other key", 2);
            Assert.Null(map.Get("not there"));
        }
Пример #4
0
        public void CanHandleEmptyRight()
        {
            Hashmap mapA = new Hashmap(1024);

            mapA.Add("cats", "blue");
            mapA.Add("dogs", "green");
            mapA.Add("llamas", "red");
            mapA.Add("cows", "purple");
            Hashmap mapB = new Hashmap(1024);

            Assert.Equal(4, Program.LeftJoin(mapA, mapB).Count);
        }
Пример #5
0
        public void CanHandleEmptyLeft()
        {
            Hashmap mapA = new Hashmap(1024);

            mapA.Add("cats", "blue");
            mapA.Add("dogs", "green");
            mapA.Add("llamas", "red");
            mapA.Add("cows", "purple");
            Hashmap mapB = new Hashmap(1024);

            Assert.Empty(Program.LeftJoin(mapB, mapA));
        }
Пример #6
0
        public void CanReturnAllLeftRecords()
        {
            Hashmap mapA = new Hashmap(1024);

            mapA.Add("cats", "blue");
            mapA.Add("dogs", "green");
            mapA.Add("llamas", "red");
            mapA.Add("cows", "purple");
            Hashmap mapB = new Hashmap(1024);

            mapB.Add("ants", "223");

            Assert.Equal(4, Program.LeftJoin(mapA, mapB).Count);
        }
Пример #7
0
        public void Add_AddsPairToCorrectIndex(Object key, Object value)
        {
            Hashmap map = new Hashmap(1024);

            map.Add(key, value);
            Assert.Equal(value, map.Buckets[(int)value].Find(key));
        }
Пример #8
0
 /// <summary>
 /// This method gets called when an end tag is encountered.
 /// </summary>
 /// <param name="tag">the name of the tag that ends</param>
 /// <param name="lname"></param>
 /// <param name="name"></param>
 public override void endElement(String tag, String lname, String name)
 {
     if (TAG.Equals(lname))
     {
         tagMap.Add(currentPeer.Alias, currentPeer);
     }
 }
Пример #9
0
        public void CanReturnMatchedRecordOfMany()
        {
            Hashmap mapA = new Hashmap(1024);

            mapA.Add("cats", "blue");
            mapA.Add("dogs", "green");
            mapA.Add("llamas", "red");
            mapA.Add("cows", "purple");
            Hashmap mapB = new Hashmap(1024);

            mapB.Add("llamas", "14");
            mapB.Add("cats", "73");
            mapB.Add("pigeons", "5");

            Assert.Contains("llamas, red, 14", Program.LeftJoin(mapA, mapB));
        }
Пример #10
0
        /**
         * Adds fieldTemplates.
         */

        internal void addFieldTemplates(Hashmap ft)
        {
            foreach (object key in ft.Keys)
            {
                fieldTemplates.Add(key, ft[key]);
            }
        }
Пример #11
0
        public void Get_ReturnsValueFromKey(Object key, Object value)
        {
            Hashmap map = new Hashmap(1024);

            map.Add(key, value);
            Assert.Equal(value, map.Get(key));
        }
Пример #12
0
        static void Main(string[] args)
        {
            Hashmap mapA = new Hashmap(1024);

            mapA.Add("cats", "blue");
            mapA.Add("dogs", "green");
            mapA.Add("llamas", "red");
            mapA.Add("cows", "purple");
            Hashmap mapB = new Hashmap(1024);

            mapB.Add("cats", "14");
            mapB.Add("cows", "22");
            mapB.Add("whales", "10");
            mapB.Add("ants", "223");
            PrintList(LeftJoin(mapA, mapB));
            Console.ReadLine();
        }
Пример #13
0
 /// <summary>
 /// Sets an arbitrary attribute.
 /// </summary>
 /// <param name="name">the key for the attribute</param>
 /// <param name="obj">the value of the attribute</param>
 /// <returns>this Chunk</returns>
 private Chunk setAttribute(string name, Object obj)
 {
     if (attributes == null)
     {
         attributes = new Hashmap();
     }
     attributes.Add(name, obj);
     return(this);
 }
Пример #14
0
 static PdfChunk()
 {
     keysAttributes.Add(Chunk.ACTION, null);
     keysAttributes.Add(Chunk.STRIKETHRU, null);
     keysAttributes.Add(Chunk.UNDERLINE, null);
     keysAttributes.Add(Chunk.REMOTEGOTO, null);
     keysAttributes.Add(Chunk.LOCALGOTO, null);
     keysAttributes.Add(Chunk.LOCALDESTINATION, null);
     keysAttributes.Add(Chunk.GENERICTAG, null);
     keysAttributes.Add(Chunk.NEWPAGE, null);
     keysAttributes.Add(Chunk.IMAGE, null);
     keysAttributes.Add(Chunk.BACKGROUND, null);
     keysAttributes.Add(Chunk.PDFANNOTATION, null);
     keysAttributes.Add(Chunk.SKEW, null);
     keysNoStroke.Add(Chunk.SUBSUPSCRIPT, null);
     keysNoStroke.Add(Chunk.SPLITCHARACTER, null);
     keysNoStroke.Add(Chunk.HYPHENATION, null);
     keysNoStroke.Add(Chunk.TEXTRENDERMODE, null);
 }
Пример #15
0
        public void CanReturnSingleUnmatchedRecord()
        {
            Hashmap mapA = new Hashmap(1024);

            mapA.Add("cats", "blue");
            Hashmap mapB = new Hashmap(1024);

            mapB.Add("ants", "223");

            Assert.Contains("cats, blue, no antonym", Program.LeftJoin(mapA, mapB));
        }
Пример #16
0
        public void setAppearance(PdfName ap, PdfAppearance template)
        {
            PdfDictionary dic = (PdfDictionary)get(PdfName.AP);

            if (dic == null)
            {
                dic = new PdfDictionary();
            }
            dic.put(ap, template.IndirectReference);
            put(PdfName.AP, dic);
            if (!form)
            {
                return;
            }
            if (templates == null)
            {
                templates = new Hashmap();
            }
            templates.Add(template, null);
        }
Пример #17
0
 static GlyphList()
 {
     for (int k = 0; k < unicode.Length; ++k)
     {
         int num = unicode[k];
         unicode2names.Add(num, names[k]);
         int[] code = (int[])names2unicode[names[k]];
         if (code == null)
         {
             names2unicode.Add(names[k], new int[] { unicode[k] });
         }
         else
         {
             int[] code2 = new int[code.Length + 1];
             Array.Copy(code, 0, code2, 0, code.Length);
             code2[code.Length] = unicode[k];
             names2unicode.Add(names[k], code2);
         }
     }
 }
Пример #18
0
        protected void flatGlyphs()
        {
            int[] tableLocation;
            tableLocation = (int[])tableDirectory["glyf"];
            if (tableLocation == null)
            {
                throw new DocumentException("Table 'glyf' does not exist in " + fileName);
            }
            int glyph0 = 0;

            if (!glyphsUsed.ContainsKey(glyph0))
            {
                glyphsUsed.Add(glyph0, null);
                glyphsInList.Add(glyph0);
            }
            tableGlyphOffset = tableLocation[TABLE_OFFSET];
            for (int k = 0; k < glyphsInList.Count; ++k)
            {
                int glyph = (int)glyphsInList[k];
                checkGlyphComposite(glyph);
            }
        }
Пример #19
0
        public static List <Object> TreeIntersection(BinaryTree treeA, BinaryTree treeB)
        {
            // build structures
            List <object> list  = new List <object>();
            Queue         queue = new Queue();
            Hashmap       map   = new Hashmap(1024);
            Object        temp  = null;

            // traverse treeA
            queue.Enqueue(treeA.Root);
            while (queue.Front != null)
            {
                if (queue.Front.Left != null)
                {
                    queue.Enqueue(queue.Front.Left);
                }
                if (queue.Front.Right != null)
                {
                    queue.Enqueue(queue.Front.Right);
                }
                temp = queue.Front.Value.ToString();
                if (!map.Contains(temp, temp))
                {
                    map.Add(temp, temp);
                }
                queue.Dequeue();
            }

            // traverse treeB
            queue.Enqueue(treeB.Root);
            while (queue.Front != null)
            {
                if (queue.Front.Left != null)
                {
                    queue.Enqueue(queue.Front.Left);
                }
                if (queue.Front.Right != null)
                {
                    queue.Enqueue(queue.Front.Right);
                }
                temp = queue.Front.Value.ToString();
                if (map.Contains(temp, temp))
                {
                    //map.Remove(temp, temp);
                    list.Add(temp);
                }
                queue.Dequeue();
            }
            return(list);
        }
Пример #20
0
        internal PdfImportedPage getImportedPage(int pageNumber)
        {
            if (pageNumber < 1 || pageNumber > pages.Length)
            {
                throw new IllegalArgumentException("Invalid page number");
            }
            int             i     = pageNumber;
            PdfImportedPage pageT = (PdfImportedPage)importedPages[i];

            if (pageT == null)
            {
                pageT = new PdfImportedPage(this, writer, pageNumber);
                importedPages.Add(i, pageT);
            }
            return(pageT);
        }
Пример #21
0
        internal void findNames()
        {
            tables = new Hashmap();

            try {
                String mainTag = readStandardstring(4);
                if (!mainTag.Equals("ttcf"))
                {
                    throw new DocumentException(fileName + " is not a valid TTC file.");
                }
                rf.skipBytes(4);
                int dirCount = rf.readInt();
                names = new String[dirCount];
                int dirPos = rf.FilePointer;
                for (int dirIdx = 0; dirIdx < dirCount; ++dirIdx)
                {
                    tables.Clear();
                    rf.seek(dirPos);
                    rf.skipBytes(dirIdx * 4);
                    directoryOffset = rf.readInt();
                    rf.seek(directoryOffset);
                    if (rf.readInt() != 0x00010000)
                    {
                        throw new DocumentException(fileName + " is not a valid TTF file.");
                    }
                    int num_tables = rf.readUnsignedShort();
                    rf.skipBytes(6);
                    for (int k = 0; k < num_tables; ++k)
                    {
                        String tag = readStandardstring(4);
                        rf.skipBytes(4);
                        int[] table_location = new int[2];
                        table_location[0] = rf.readInt();
                        table_location[1] = rf.readInt();
                        tables.Add(tag, table_location);
                    }
                    names[dirIdx] = this.BaseFont;
                }
            }
            finally {
                if (rf != null)
                {
                    rf.close();
                }
            }
        }
Пример #22
0
 internal void writeAllVisited()
 {
     while (nextRound.Count > 0)
     {
         ArrayList vec = nextRound;
         nextRound = new ArrayList();
         for (int k = 0; k < vec.Count; ++k)
         {
             int i = (int)vec[k];
             if (!visited.ContainsKey(i))
             {
                 visited.Add(i, null);
                 int n = i;
                 writer.addToBody(xrefObj[n], myXref[n]);
             }
         }
     }
 }
Пример #23
0
        public void TestHashmapForInts()
        {
            var map = new Hashmap <int, int>(numValues);

            for (int i = 0; i < numValues; i++)
            {
                map.Add(i, i);
            }

            for (int i = 0; i < numValues; i++)
            {
                Assert.AreEqual(i, map.Get(i));
            }

            for (int i = 0; i < numValues; i++)
            {
                map.Remove(i);
            }

            Assert.AreEqual(0, map.Count);
        }
Пример #24
0
        protected void createTableDirectory()
        {
            tableDirectory = new Hashmap();
            rf.seek(directoryOffset);
            int id = rf.readInt();

            if (id != 0x00010000)
            {
                throw new DocumentException(fileName + " is not a true type file.");
            }
            int num_tables = rf.readUnsignedShort();

            rf.skipBytes(6);
            for (int k = 0; k < num_tables; ++k)
            {
                string tag           = readStandardstring(4);
                int[]  tableLocation = new int[3];
                tableLocation[TABLE_CHECKSUM] = rf.readInt();
                tableLocation[TABLE_OFFSET]   = rf.readInt();
                tableLocation[TABLE_LENGTH]   = rf.readInt();
                tableDirectory.Add(tag, tableLocation);
            }
        }
Пример #25
0
        /// <summary>
        /// adds each word to hashmap if not already present; returns first duplicate
        /// </summary>
        /// <param name="line"> string to search for duplicate </param>
        /// <returns> first duplicate found, or 'no repeats found' if none </returns>
        public static string RepeatedWord(string line)
        {
            string[] words = line.Split(new char[] { ' ', ',', '.', ':', ';', '?', '!', '*', '<', '>', '(', ')', '{', '}', '[', ']' });
            int      idx   = 0;
            Hashmap  map   = new Hashmap(1024);

            foreach (var word in words)
            {
                if (word != "")
                {
                    string wordLower = word.ToLower();
                    idx = map.Hash(wordLower);
                    if (map.Contains(wordLower, 0))
                    {
                        return(wordLower);
                    }
                    else
                    {
                        map.Add(wordLower, 0);
                    }
                }
            }
            return("no repeats found");
        }
Пример #26
0
        public void TestHashmapForStrings()
        {
            var map = new Hashmap <string, string>(numValues);

            for (int i = 0; i < numValues; i++)
            {
                var tmp = i + string.Empty;
                map.Add(tmp, tmp);
            }

            for (int i = 0; i < numValues; i++)
            {
                var tmp = i + string.Empty;
                Assert.AreEqual(tmp, map.Get(tmp));
            }

            for (int i = 0; i < numValues; i++)
            {
                var tmp = i + string.Empty;
                map.Remove(tmp);
            }

            Assert.AreEqual(0, map.Count);
        }
Пример #27
0
		/// <summary>
		/// Orders this graphic to draw a horizontal line.
		/// </summary>
		/// <param name="linewidth">the width</param>
		/// <param name="percentage">the percentage</param>
		public void setHorizontalLine(float linewidth, float percentage) {
			if (attributes == null) attributes = new Hashmap();
			attributes.Add(HORIZONTAL_LINE, new Object[]{linewidth, percentage, new Color(0, 0, 0)});
		}
Пример #28
0
        // methods concerning the Hashtable member value

        /**
         * Adds a <CODE>PdfObject</CODE> and its key to the <CODE>PdfDictionary</CODE>.
         *
         * @param		key		key of the entry (a <CODE>PdfName</CODE>)
         * @param		value	value of the entry (a <CODE>PdfObject</CODE>)
         * @return		the previous </CODE>PdfObject</CODE> corresponding with the <VAR>key</VAR>
         */

        public PdfObject put(PdfName key, PdfObject value)
        {
            hashMap.Add(key, value);
            return(value);
        }
Пример #29
0
 /// <summary>
 /// Static Constructor
 /// </summary>
 static Entities()
 {
     map = new Hashmap();
     map.Add("169", 227);
     map.Add("172", 216);
     map.Add("174", 210);
     map.Add("177", 177);
     map.Add("215", 180);
     map.Add("247", 184);
     map.Add("8230", 188);
     map.Add("8242", 162);
     map.Add("8243", 178);
     map.Add("8260", 164);
     map.Add("8364", 240);
     map.Add("8465", 193);
     map.Add("8472", 195);
     map.Add("8476", 194);
     map.Add("8482", 212);
     map.Add("8501", 192);
     map.Add("8592", 172);
     map.Add("8593", 173);
     map.Add("8594", 174);
     map.Add("8595", 175);
     map.Add("8596", 171);
     map.Add("8629", 191);
     map.Add("8656", 220);
     map.Add("8657", 221);
     map.Add("8658", 222);
     map.Add("8659", 223);
     map.Add("8660", 219);
     map.Add("8704", 34);
     map.Add("8706", 182);
     map.Add("8707", 36);
     map.Add("8709", 198);
     map.Add("8711", 209);
     map.Add("8712", 206);
     map.Add("8713", 207);
     map.Add("8717", 39);
     map.Add("8719", 213);
     map.Add("8721", 229);
     map.Add("8722", 45);
     map.Add("8727", 42);
     map.Add("8729", 183);
     map.Add("8730", 214);
     map.Add("8733", 181);
     map.Add("8734", 165);
     map.Add("8736", 208);
     map.Add("8743", 217);
     map.Add("8744", 218);
     map.Add("8745", 199);
     map.Add("8746", 200);
     map.Add("8747", 242);
     map.Add("8756", 92);
     map.Add("8764", 126);
     map.Add("8773", 64);
     map.Add("8776", 187);
     map.Add("8800", 185);
     map.Add("8801", 186);
     map.Add("8804", 163);
     map.Add("8805", 179);
     map.Add("8834", 204);
     map.Add("8835", 201);
     map.Add("8836", 203);
     map.Add("8838", 205);
     map.Add("8839", 202);
     map.Add("8853", 197);
     map.Add("8855", 196);
     map.Add("8869", 94);
     map.Add("8901", 215);
     map.Add("8992", 243);
     map.Add("8993", 245);
     map.Add("9001", 225);
     map.Add("9002", 241);
     map.Add("913", 65);
     map.Add("914", 66);
     map.Add("915", 71);
     map.Add("916", 68);
     map.Add("917", 69);
     map.Add("918", 90);
     map.Add("919", 72);
     map.Add("920", 81);
     map.Add("921", 73);
     map.Add("922", 75);
     map.Add("923", 76);
     map.Add("924", 77);
     map.Add("925", 78);
     map.Add("926", 88);
     map.Add("927", 79);
     map.Add("928", 80);
     map.Add("929", 82);
     map.Add("931", 83);
     map.Add("932", 84);
     map.Add("933", 85);
     map.Add("934", 70);
     map.Add("935", 67);
     map.Add("936", 89);
     map.Add("937", 87);
     map.Add("945", 97);
     map.Add("946", 98);
     map.Add("947", 103);
     map.Add("948", 100);
     map.Add("949", 101);
     map.Add("950", 122);
     map.Add("951", 104);
     map.Add("952", 113);
     map.Add("953", 105);
     map.Add("954", 107);
     map.Add("955", 108);
     map.Add("956", 109);
     map.Add("957", 110);
     map.Add("958", 120);
     map.Add("959", 111);
     map.Add("960", 112);
     map.Add("961", 114);
     map.Add("962", 86);
     map.Add("963", 115);
     map.Add("964", 116);
     map.Add("965", 117);
     map.Add("966", 102);
     map.Add("967", 99);
     map.Add("9674", 224);
     map.Add("968", 121);
     map.Add("969", 119);
     map.Add("977", 74);
     map.Add("978", 161);
     map.Add("981", 106);
     map.Add("982", 118);
     map.Add("9824", 170);
     map.Add("9827", 167);
     map.Add("9829", 169);
     map.Add("9830", 168);
     map.Add("Alpha", 65);
     map.Add("Beta", 66);
     map.Add("Chi", 67);
     map.Add("Delta", 68);
     map.Add("Epsilon", 69);
     map.Add("Eta", 72);
     map.Add("Gamma", 71);
     map.Add("Iota", 73);
     map.Add("Kappa", 75);
     map.Add("Lambda", 76);
     map.Add("Mu", 77);
     map.Add("Nu", 78);
     map.Add("Omega", 87);
     map.Add("Omicron", 79);
     map.Add("Phi", 70);
     map.Add("Pi", 80);
     map.Add("Prime", 178);
     map.Add("Psi", 89);
     map.Add("Rho", 82);
     map.Add("Sigma", 83);
     map.Add("Tau", 84);
     map.Add("Theta", 81);
     map.Add("Upsilon", 85);
     map.Add("Xi", 88);
     map.Add("Zeta", 90);
     map.Add("alefsym", 192);
     map.Add("alpha", 97);
     map.Add("and", 217);
     map.Add("ang", 208);
     map.Add("asymp", 187);
     map.Add("beta", 98);
     map.Add("cap", 199);
     map.Add("chi", 99);
     map.Add("clubs", 167);
     map.Add("cong", 64);
     map.Add("copy", 211);
     map.Add("crarr", 191);
     map.Add("cup", 200);
     map.Add("dArr", 223);
     map.Add("darr", 175);
     map.Add("delta", 100);
     map.Add("diams", 168);
     map.Add("divide", 184);
     map.Add("empty", 198);
     map.Add("epsilon", 101);
     map.Add("equiv", 186);
     map.Add("eta", 104);
     map.Add("euro", 240);
     map.Add("exist", 36);
     map.Add("forall", 34);
     map.Add("frasl", 164);
     map.Add("gamma", 103);
     map.Add("ge", 179);
     map.Add("hArr", 219);
     map.Add("harr", 171);
     map.Add("hearts", 169);
     map.Add("hellip", 188);
     map.Add("horizontal arrow extender", 190);
     map.Add("image", 193);
     map.Add("infin", 165);
     map.Add("int", 242);
     map.Add("iota", 105);
     map.Add("isin", 206);
     map.Add("kappa", 107);
     map.Add("lArr", 220);
     map.Add("lambda", 108);
     map.Add("lang", 225);
     map.Add("large brace extender", 239);
     map.Add("large integral extender", 244);
     map.Add("large left brace (bottom)", 238);
     map.Add("large left brace (middle)", 237);
     map.Add("large left brace (top)", 236);
     map.Add("large left bracket (bottom)", 235);
     map.Add("large left bracket (extender)", 234);
     map.Add("large left bracket (top)", 233);
     map.Add("large left parenthesis (bottom)", 232);
     map.Add("large left parenthesis (extender)", 231);
     map.Add("large left parenthesis (top)", 230);
     map.Add("large right brace (bottom)", 254);
     map.Add("large right brace (middle)", 253);
     map.Add("large right brace (top)", 252);
     map.Add("large right bracket (bottom)", 251);
     map.Add("large right bracket (extender)", 250);
     map.Add("large right bracket (top)", 249);
     map.Add("large right parenthesis (bottom)", 248);
     map.Add("large right parenthesis (extender)", 247);
     map.Add("large right parenthesis (top)", 246);
     map.Add("larr", 172);
     map.Add("le", 163);
     map.Add("lowast", 42);
     map.Add("loz", 224);
     map.Add("minus", 45);
     map.Add("mu", 109);
     map.Add("nabla", 209);
     map.Add("ne", 185);
     map.Add("not", 216);
     map.Add("notin", 207);
     map.Add("nsub", 203);
     map.Add("nu", 110);
     map.Add("omega", 119);
     map.Add("omicron", 111);
     map.Add("oplus", 197);
     map.Add("or", 218);
     map.Add("otimes", 196);
     map.Add("part", 182);
     map.Add("perp", 94);
     map.Add("phi", 102);
     map.Add("pi", 112);
     map.Add("piv", 118);
     map.Add("plusmn", 177);
     map.Add("prime", 162);
     map.Add("prod", 213);
     map.Add("prop", 181);
     map.Add("psi", 121);
     map.Add("rArr", 222);
     map.Add("radic", 214);
     map.Add("radical extender", 96);
     map.Add("rang", 241);
     map.Add("rarr", 174);
     map.Add("real", 194);
     map.Add("reg", 210);
     map.Add("rho", 114);
     map.Add("sdot", 215);
     map.Add("sigma", 115);
     map.Add("sigmaf", 86);
     map.Add("sim", 126);
     map.Add("spades", 170);
     map.Add("sub", 204);
     map.Add("sube", 205);
     map.Add("sum", 229);
     map.Add("sup", 201);
     map.Add("supe", 202);
     map.Add("tau", 116);
     map.Add("there4", 92);
     map.Add("theta", 113);
     map.Add("thetasym", 74);
     map.Add("times", 180);
     map.Add("trade", 212);
     map.Add("uArr", 221);
     map.Add("uarr", 173);
     map.Add("upsih", 161);
     map.Add("upsilon", 117);
     map.Add("vertical arrow extender", 189);
     map.Add("weierp", 195);
     map.Add("xi", 120);
     map.Add("zeta", 122);
 }
Пример #30
0
        /**
         * Constructs a <CODE>PdfChunk</CODE>-object.
         *
         * @param chunk the original <CODE>Chunk</CODE>-object
         * @param action the <CODE>PdfAction</CODE> if the <CODE>Chunk</CODE> comes from an <CODE>Anchor</CODE>
         */

        internal PdfChunk(Chunk chunk, PdfAction action)
        {
            value = chunk.Content;

            iTextSharp.text.Font f = chunk.Font;
            float size             = f.Size;

            if (size == iTextSharp.text.Font.UNDEFINED)
            {
                size = 12;
            }
            BaseFont bf = f.BaseFont;
            int      family;
            int      style = f.Style;

            if (bf == null)
            {
                // translation of the font-family to a PDF font-family
                if (style == iTextSharp.text.Font.UNDEFINED)
                {
                    style = iTextSharp.text.Font.NORMAL;
                }
                switch (f.Family)
                {
                case iTextSharp.text.Font.COURIER:
                    switch (style & iTextSharp.text.Font.BOLDITALIC)
                    {
                    case iTextSharp.text.Font.BOLD:
                        family = PdfFont.COURIER_BOLD;
                        break;

                    case iTextSharp.text.Font.ITALIC:
                        family = PdfFont.COURIER_OBLIQUE;
                        break;

                    case iTextSharp.text.Font.BOLDITALIC:
                        family = PdfFont.COURIER_BOLDOBLIQUE;
                        break;

                    default:
                    case iTextSharp.text.Font.NORMAL:
                        family = PdfFont.COURIER;
                        break;
                    }
                    break;

                case iTextSharp.text.Font.TIMES_NEW_ROMAN:
                    switch (style & iTextSharp.text.Font.BOLDITALIC)
                    {
                    case iTextSharp.text.Font.BOLD:
                        family = PdfFont.TIMES_BOLD;
                        break;

                    case iTextSharp.text.Font.ITALIC:
                        family = PdfFont.TIMES_ITALIC;
                        break;

                    case iTextSharp.text.Font.BOLDITALIC:
                        family = PdfFont.TIMES_BOLDITALIC;
                        break;

                    default:
                    case iTextSharp.text.Font.NORMAL:
                        family = PdfFont.TIMES_ROMAN;
                        break;
                    }
                    break;

                case iTextSharp.text.Font.SYMBOL:
                    family = PdfFont.SYMBOL;
                    break;

                case iTextSharp.text.Font.ZAPFDINGBATS:
                    family = PdfFont.ZAPFDINGBATS;
                    break;

                default:
                case iTextSharp.text.Font.HELVETICA:
                    switch (style & iTextSharp.text.Font.BOLDITALIC)
                    {
                    case iTextSharp.text.Font.BOLD:
                        family = PdfFont.HELVETICA_BOLD;
                        break;

                    case iTextSharp.text.Font.ITALIC:
                        family = PdfFont.HELVETICA_OBLIQUE;
                        break;

                    case iTextSharp.text.Font.BOLDITALIC:
                        family = PdfFont.HELVETICA_BOLDOBLIQUE;
                        break;

                    default:
                    case iTextSharp.text.Font.NORMAL:
                        family = PdfFont.HELVETICA;
                        break;
                    }
                    break;
                }
                // creation of the PdfFont with the right size
                font = new PdfFont(family, size);
            }
            else
            {
                // bold simulation
                if ((style & iTextSharp.text.Font.BOLD) != 0)
                {
                    attributes.Add(Chunk.TEXTRENDERMODE, new Object[] { PdfContentByte.TEXT_RENDER_MODE_FILL_STROKE, size / 30f, null });
                }
                // italic simulation
                if ((style & iTextSharp.text.Font.ITALIC) != 0)
                {
                    attributes.Add(Chunk.SKEW, new float[] { 0, ITALIC_ANGLE });
                }

                font = new PdfFont(bf, size);
            }



            // other style possibilities
            Hashmap attr = chunk.Attributes;

            if (attr != null)
            {
                foreach (string name in attr.Keys)
                {
                    if (keysAttributes.ContainsKey(name))
                    {
                        attributes.Add(name, attr[name]);
                    }
                    else if (keysNoStroke.ContainsKey(name))
                    {
                        noStroke.Add(name, attr[name]);
                    }
                }
                if ("".Equals(attr[Chunk.GENERICTAG]))
                {
                    attributes.Add(Chunk.GENERICTAG, chunk.Content);
                }
            }
            if (f.isUnderlined())
            {
                attributes.Add(Chunk.UNDERLINE, null);
            }
            if (f.isStrikethru())
            {
                attributes.Add(Chunk.STRIKETHRU, null);
            }
            if (action != null)
            {
                attributes.Add(Chunk.ACTION, action);
            }
            // the color can't be stored in a PdfFont
            noStroke.Add(Chunk.COLOR, f.Color);
            noStroke.Add(Chunk.ENCODING, font.Font.Encoding);
            Object[] obj = (Object[])attributes[Chunk.IMAGE];
            if (obj == null)
            {
                image = null;
            }
            else
            {
                image         = (Image)obj[0];
                offsetX       = ((float)obj[1]);
                offsetY       = ((float)obj[2]);
                changeLeading = bool.Parse(obj[3].ToString());
            }
            font.Image     = image;
            encoding       = font.Font.Encoding;
            splitCharacter = (ISplitCharacter)noStroke[Chunk.SPLITCHARACTER];
            if (splitCharacter == null)
            {
                splitCharacter = this;
            }
        }