示例#1
0
        /// <summary>
        /// Return font file
        /// </summary>
        /// <returns></returns>
        public byte[] GetFontData()
        {
            byte[] result = null;

            if (FSourceFont != null)
            {
                TrueTypeCollection font_collection = new TrueTypeCollection(FSourceFont);

                TrueTypeFont.TablesID[] skip_list = new TrueTypeFont.TablesID[]
                {
                    TrueTypeFont.TablesID.HorizontakDeviceMetrix,
                    TrueTypeFont.TablesID.DigitalSignature,
                    TrueTypeFont.TablesID.Postscript,
                    TrueTypeFont.TablesID.GlyphPosition,

                    TrueTypeFont.TablesID.EmbedBitmapLocation,
                    TrueTypeFont.TablesID.EmbededBitmapData
                };

                foreach (TrueTypeFont f in font_collection.FontCollection)
                {
                    f.PrepareFont(skip_list);
                }

                TrueTypeFont font = font_collection[FSourceFont];

                foreach (char ch in FUsedGlyphIndexes)
                {
                    font.AddCharacterToKeepList(ch);
                }


                result = font.PackFont(FontType.TrueTypeFont, true);
            }
            return(result);
        }