Example #1
0
        private void InitializeCidFontProperties(IDictionary <String, Object> fontDesc)
        {
            fontIdentification.SetPanose((String)fontDesc.Get("Panose"));
            fontMetrics.SetItalicAngle(Convert.ToInt32((String)fontDesc.Get("ItalicAngle"), System.Globalization.CultureInfo.InvariantCulture
                                                       ));
            fontMetrics.SetCapHeight(Convert.ToInt32((String)fontDesc.Get("CapHeight"), System.Globalization.CultureInfo.InvariantCulture
                                                     ));
            fontMetrics.SetTypoAscender(Convert.ToInt32((String)fontDesc.Get("Ascent"), System.Globalization.CultureInfo.InvariantCulture
                                                        ));
            fontMetrics.SetTypoDescender(Convert.ToInt32((String)fontDesc.Get("Descent"), System.Globalization.CultureInfo.InvariantCulture
                                                         ));
            fontMetrics.SetStemV(Convert.ToInt32((String)fontDesc.Get("StemV"), System.Globalization.CultureInfo.InvariantCulture
                                                 ));
            pdfFontFlags = Convert.ToInt32((String)fontDesc.Get("Flags"), System.Globalization.CultureInfo.InvariantCulture
                                           );
            String          fontBBox = (String)fontDesc.Get("FontBBox");
            StringTokenizer tk       = new StringTokenizer(fontBBox, " []\r\n\t\f");
            int             llx      = Convert.ToInt32(tk.NextToken(), System.Globalization.CultureInfo.InvariantCulture);
            int             lly      = Convert.ToInt32(tk.NextToken(), System.Globalization.CultureInfo.InvariantCulture);
            int             urx      = Convert.ToInt32(tk.NextToken(), System.Globalization.CultureInfo.InvariantCulture);
            int             ury      = Convert.ToInt32(tk.NextToken(), System.Globalization.CultureInfo.InvariantCulture);

            fontMetrics.UpdateBbox(llx, lly, urx, ury);
            registry = (String)fontDesc.Get("Registry");
            String uniMap = GetCompatibleUniMap(registry);

            if (uniMap != null)
            {
                IntHashtable metrics = (IntHashtable)fontDesc.Get("W");
                CMapCidUni   cid2Uni = FontCache.GetCid2UniCmap(uniMap);
                avgWidth = 0;
                foreach (int cid in cid2Uni.GetCids())
                {
                    int   uni   = cid2Uni.Lookup(cid);
                    int   width = metrics.ContainsKey(cid) ? metrics.Get(cid) : DEFAULT_WIDTH;
                    Glyph glyph = new Glyph(cid, width, uni);
                    avgWidth += glyph.GetWidth();
                    codeToGlyph.Put(cid, glyph);
                    unicodeToGlyph.Put(uni, glyph);
                }
                FixSpaceIssue();
                if (codeToGlyph.Count != 0)
                {
                    avgWidth /= codeToGlyph.Count;
                }
            }
        }