Example #1
0
        protected static void DrawBitmapData5(RendererContext context, BitmapSize size, GlyphBitmapData5 data)
        {
            //Console.WriteLine("data5: {0}", data5);
            BigGlyphMetrics    bigMetrics = null;
            IndexSubTableArray subTable   = size.FindSubTableArray(context.GlyphId);

            if (subTable != null)
            {
                //Console.WriteLine("Size 2: {0}", context.GlyphId);
                //Console.WriteLine("Size 3: {0}", subTable);
                bigMetrics = subTable.GetBigGlyphMetrics();
                //Console.WriteLine("Size 4: {0}", metrics);
            }
            if (bigMetrics != null)
            {
                DrawImageData(
                    context,
                    size.bitDepth,
                    bigMetrics,
                    data.imageData
                    );
            }
            else
            {
                DrawImageData(
                    context,
                    size.bitDepth,
                    size.hori.widthMax,
                    context.FontSize,
                    data.imageData
                    );
                context.X += context.FontSize;
            }
        }
Example #2
0
        protected static void DrawImageData256(RendererContext context, BigGlyphMetrics bigMetrics, byte[] data)
        {
            Bitmap bitmap = context.Bitmap;
            Color  color  = Color.Black;
            int    width  = bigMetrics.width;
            int    height = bigMetrics.height;
            int    bx     = (int)context.DX + context.X + bigMetrics.horiBearingX;
            int    by     = (int)context.DY;
            int    dx     = 0;
            int    dy     = 0;
            int    length = data.Length;

            for (int i = 0; i < length; i++)
            {
                if (dx >= width)
                {
                    dx = 0;
                    dy++;
                    if (dy >= height)
                    {
                        break;
                    }
                }
                if (bx + dx > bitmap.Width)
                {
                    dx++;
                    continue;
                }
                byte alpha = data[i];
                bitmap.SetPixel(bx + dx, by + dy, Color.FromArgb(alpha, color));
                dx++;
            }
            //context.NextGlyph();
            context.X += bigMetrics.horiAdvance;
        }
Example #3
0
 public static IndexSubTable2 Read(BinaryReaderFont reader)
 {
     return(new IndexSubTable2 {
         header = IndexSubHeader.Read(reader),
         imageSize = reader.ReadUInt32(),
         bigMetrics = BigGlyphMetrics.Read(reader)
     });
 }
Example #4
0
        public static GlyphBitmapData18 Read(BinaryReaderFont reader)
        {
            GlyphBitmapData18 value = new GlyphBitmapData18 {
                glyphMetrics = BigGlyphMetrics.Read(reader),
                dataLen      = reader.ReadUInt32()
            };

            value.data = reader.ReadBytes((int)value.dataLen);
            return(value);
        }
Example #5
0
        public static GlyphBitmapData6 Read(BinaryReaderFont reader, int byteSize)
        {
            GlyphBitmapData6 value = new GlyphBitmapData6 {
                bigMetrics = BigGlyphMetrics.Read(reader)
            };

            byteSize       -= BigGlyphMetrics.ByteSize;
            value.imageData = reader.ReadBytes(byteSize);
            return(value);
        }
Example #6
0
        public static GlyphBitmapData9 Read(BinaryReaderFont reader)
        {
            GlyphBitmapData9 value = new GlyphBitmapData9 {
                bigMetrics    = BigGlyphMetrics.Read(reader),
                numComponents = reader.ReadUInt16()
            };

            value.components = EbdtComponent.ReadArray(reader, value.numComponents);
            return(value);
        }
Example #7
0
        /// <summary>
        /// One per glyph, sorted by glyph ID.
        /// </summary>
        //public ushort[] glyphIdArray;

        public static IndexSubTable5 Read(BinaryReaderFont reader)
        {
            IndexSubTable5 value = new IndexSubTable5();

            value.header     = IndexSubHeader.Read(reader);
            value.imageSize  = reader.ReadUInt32();
            value.bigMetrics = BigGlyphMetrics.Read(reader);
            value.numGlyphs  = reader.ReadUInt32();
            value.position   = reader.Position;
            //value.glyphIdArray = reader.ReadUInt16Array((int)value.numGlyphs);
            return(value);
        }
Example #8
0
        protected static void DrawImageData(RendererContext context, BitDepth bitDepth, BigGlyphMetrics bigMetrics, byte[] data)
        {
            switch (bitDepth)
            {
            case BitDepth.BlackWhite:
                DrawImageData2(context, bigMetrics, data);
                break;

            case BitDepth.Gray4:
                DrawImageData4(context, bigMetrics, data);
                break;

            case BitDepth.Gray16:
                DrawImageData16(context, bigMetrics, data);
                break;

            case BitDepth.Gray256:
                DrawImageData256(context, bigMetrics, data);
                break;
            }
        }