iTextSharp.text.pdf.TrueTypeFontUnicode.GetMetricsTT C# (CSharp) Метод

GetMetricsTT() публичный Метод

public GetMetricsTT ( int c ) : int[]
c int
Результат int[]
        public override int[] GetMetricsTT(int c) {
            if (cmapExt != null)
                return (int[])cmapExt[c];
            Hashtable map = null;
            if (fontSpecific)
                map = cmap10;
            else
                map = cmap31;
            if (map == null)
                return null;
            if (fontSpecific) {
                if ((c & 0xffffff00) == 0 || (c & 0xffffff00) == 0xf000)
                    return (int[])map[c & 0xff];
                else
                    return null;
            }
            else
                return (int[])map[c];
        }

Usage Example

Пример #1
0
        /** Converts the text into bytes to be placed in the document.
         * The conversion is done according to the font and the encoding and the characters
         * used are stored.
         * @param text the text to convert
         * @return the conversion
         */
        internal byte[] ConvertToBytes(string text)
        {
            byte[] b = null;
            switch (fontType)
            {
            case BaseFont.FONT_TYPE_T3:
                return(baseFont.ConvertToBytes(text));

            case BaseFont.FONT_TYPE_T1:
            case BaseFont.FONT_TYPE_TT: {
                b = baseFont.ConvertToBytes(text);
                int len = b.Length;
                for (int k = 0; k < len; ++k)
                {
                    shortTag[((int)b[k]) & 0xff] = 1;
                }
                break;
            }

            case BaseFont.FONT_TYPE_CJK: {
                int len = text.Length;
                if (cjkFont.IsIdentity())
                {
                    foreach (char c in text)
                    {
                        cjkTag[c] = 0;
                    }
                }
                else
                {
                    for (int k = 0; k < len; ++k)
                    {
                        int val;
                        if (Utilities.IsSurrogatePair(text, k))
                        {
                            val = Utilities.ConvertToUtf32(text, k);
                            k++;
                        }
                        else
                        {
                            val = text[k];
                        }
                        cjkTag[cjkFont.GetCidCode(val)] = 0;
                    }
                }
                b = cjkFont.ConvertToBytes(text);
                break;
            }

            case BaseFont.FONT_TYPE_DOCUMENT: {
                b = baseFont.ConvertToBytes(text);
                break;
            }

            case BaseFont.FONT_TYPE_TTUNI: {
                int    len     = text.Length;
                int[]  metrics = null;
                char[] glyph   = new char[len];
                int    i       = 0;
                if (symbolic)
                {
                    b   = PdfEncodings.ConvertToBytes(text, "symboltt");
                    len = b.Length;
                    for (int k = 0; k < len; ++k)
                    {
                        metrics = ttu.GetMetricsTT(b[k] & 0xff);
                        if (metrics == null)
                        {
                            continue;
                        }
                        longTag[metrics[0]] = new int[] { metrics[0], metrics[1], ttu.GetUnicodeDifferences(b[k] & 0xff) };
                        glyph[i++]          = (char)metrics[0];
                    }
                }
                else
                {
                    for (int k = 0; k < len; ++k)
                    {
                        int val;
                        if (Utilities.IsSurrogatePair(text, k))
                        {
                            val = Utilities.ConvertToUtf32(text, k);
                            k++;
                        }
                        else
                        {
                            val = (int)text[k];
                        }
                        metrics = ttu.GetMetricsTT(val);
                        if (metrics == null)
                        {
                            continue;
                        }
                        int m0 = metrics[0];
                        int gl = m0;
                        if (!longTag.ContainsKey(gl))
                        {
                            longTag[gl] = new int[] { m0, metrics[1], val }
                        }
                        ;
                        glyph[i++] = (char)m0;
                    }
                }
                string s = new String(glyph, 0, i);
                b = PdfEncodings.ConvertToBytes(s, CJKFont.CJK_ENCODING);
                break;
            }
            }
            return(b);
        }
All Usage Examples Of iTextSharp.text.pdf.TrueTypeFontUnicode::GetMetricsTT