private int Stream2(System.IO.Stream stream) { Hashtable longTag = ttf.glyphsUsed; ArrayList tmp = new ArrayList(); foreach (object o in longTag.Values) { if (o != null) { tmp.Add(o); } } Object[] metrics = tmp.ToArray(); StringBuilder buf = new StringBuilder(); buf.Append(this.HeadObj); buf.Append(String.Format("<</BaseFont/{0}", ttf.Name)); buf.Append("/CIDSystemInfo<</Ordering(Identity)/Registry(Adobe)/Supplement 0>>/CIDToGIDMap/Identity/FontDescriptor " + ttf.GetMainDescriptor().HeadR + "/Subtype/CIDFontType2/DW 1000/W "); StringBuilder sb = new StringBuilder("["); int lastNumber = -10; bool firstTime = true; for (int k = 0; k < metrics.Length; ++k) { int[] metric = (int[])metrics[k]; if (metric[1] == 1000) { continue; } int m = metric[0]; if (m == lastNumber + 1) { sb.Append(" ").Append(metric[1]); } else { if (!firstTime) { sb.Append("]"); } firstTime = false; sb.Append(m).Append("[").Append(metric[1]); } lastNumber = m; } if (sb.Length == 1) { sb.Append("]"); } else if (sb.Length > 1) { sb.Append("]]"); } buf.Append(sb.ToString()); buf.Append("/Type/Font>>"); buf.Append("\nendobj\n"); Byte[] b = ASCIIEncoding.ASCII.GetBytes(buf.ToString()); stream.Write(b, 0, b.Length); return(b.Length); }