/** 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_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; for (int k = 0; k < len; ++k) { cjkTag[cjkFont.getCidCode(text[k])] = 0; } b = baseFont.convertToBytes(text); break; } case BaseFont.FONT_TYPE_TTUNI: { try { int len = text.Length; int[] metrics = null; char[] glyph = new char[len]; int i = 0; if (symbolic) { b = PdfEncodings.convertToBytes(text, BaseFont.WINANSI); len = b.Length; for (int k = 0; k < len; ++k) { metrics = ttu.getMetricsTT(b[k] & 0xff); if (metrics == null) { continue; } longTag.Add(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) { char c = text[k]; metrics = ttu.getMetricsTT(c); if (metrics == null) { continue; } int m0 = metrics[0]; int gl = m0; if (!longTag.ContainsKey(gl)) { longTag.Add(gl, new int[] { m0, metrics[1], c }); } glyph[i++] = (char)m0; } } string s = new string(glyph, 0, i); b = System.Text.Encoding.GetEncoding(CJKFont.CJK_ENCODING).GetBytes(s); } catch (Exception e) { throw e; } break; } } return(b); }