public static IZiCharacter FromString(IZiFont parent, uint codepoint, Font font, PointF location, String txt)
        {
            switch (parent.Version)
            {
            //    case 3:
            //        return new ZiCharacterV3();
            case 5:
                return(new ZiCharacterV5(parent, codepoint, font, location, txt));

            default:
                return(null);
            }
        }
        public static IZiCharacter FromBytes(IZiFont parent, uint codepoint, byte[] bytes, byte width, byte kerningL, byte kerningR)
        {
            switch (parent.Version)
            {
            //    case 3:
            //        return new ZiCharacterV3();
            case 5:
                return(new ZiCharacterV5(parent, codepoint, bytes, width, kerningL, kerningR));

            default:
                return(null);
            }
        }
        public static IZiCharacter FromBitmap(IZiFont parent, uint codepoint, Bitmap bmp, byte kerningL, byte kerningR)
        {
            switch (parent.Version)
            {
            //    case 3:
            //        return new ZiCharacterV3();
            case 5:
                return(new ZiCharacterV5(parent, codepoint, bmp, kerningL, kerningR));

            default:
                return(null);
            }
        }
Пример #4
0
 public ZiCharacterV3(IZiFont parent, uint codepoint, byte[] bytes, byte width = 0, byte kerningL = 0, byte kerningR = 0)
 {
     Parent    = parent;
     CodePoint = codepoint;
     if (_Bitmap != null && _Bitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Undefined)
     {
         _Bitmap.Dispose();
     }
     _CharacterData  = bytes;
     KerningRight    = KerningLeft = 0; // Kerning is not supported in V3
     DataState       = ValidData.CHARDATA;
     OriginalFormat  = DataState;
     Width           = Parent.CharacterWidth; // Fixed Width set by Parent Font
     ForegroundColor = Color.Aqua;
 }
Пример #5
0
 public ZiCharacterV3(IZiFont parent, uint codepoint, Font font, PointF location, String txt = null)
 {
     Parent    = parent;
     CodePoint = codepoint;
     SetString(font, location, txt);
     if (_Bitmap != null && _Bitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Undefined)
     {
         _Bitmap.Dispose();
     }
     if (_CharacterData != null)
     {
         _CharacterData = null;
     }
     ForegroundColor = Color.Chocolate;
 }
 /* Constructors */
 public ZiCharacterV5(IZiFont parent, uint codepoint, Bitmap bmp, byte kerningL = 0, byte kerningR = 0)
 {
     Parent    = parent;
     CodePoint = codepoint;
     _Bitmap   = new Bitmap(bmp.Width, bmp.Height);
     using (var graphics = Graphics.FromImage(_Bitmap))
     {
         graphics.DrawImage(bmp, 0, 0);
     }
     _CharacterData = new byte[0];
     KerningLeft    = kerningL;
     KerningRight   = kerningR;
     Width          = (byte)(bmp.Width - kerningL - kerningR);
     DataState      = ValidData.BITMAP;
 }
Пример #7
0
 public ZiCharacterV5(IZiFont parent, uint codepoint, byte[] bytes, byte width, byte kerningL = 0, byte kerningR = 0)
 {
     Parent    = parent;
     CodePoint = codepoint;
     if (_Bitmap != null && _Bitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Undefined)
     {
         _Bitmap.Dispose();
     }
     _CharacterData  = bytes;
     KerningLeft     = kerningL;
     KerningRight    = kerningR;
     DataState       = ValidData.CHARDATA;
     OriginalFormat  = DataState;
     Width           = width;
     ForegroundColor = Color.Blue;
 }
Пример #8
0
        private void CreateCharacterPreview2(IZiFont font)
        {
            flowPanel.Controls.Clear();
            this.SuspendLayout();

            var preview = new Bitmap(flowPanel.Width - 15, flowPanel.Height - 15);
            var x       = 0;
            var y       = 0;

            using (var graphics = Graphics.FromImage(preview)) {
                graphics.FillRectangle(Brushes.Transparent, 0, 0, preview.Width, preview.Height);

                foreach (var ch in font.Characters)
                {
                    var b = ch.ToBitmap();

                    if ((x + b.Width) > preview.Width)
                    {
                        x  = 0;
                        y += b.Height;
                    }

                    if (y >= preview.Height)
                    {
                        break;
                    }

                    graphics.DrawImage(b, x, y);
                    x += b.Width;
                }
            }

            var p = new PictureBox()
            {
                Width       = preview.Width,
                Height      = preview.Height,
                Image       = preview,
                BorderStyle = BorderStyle.FixedSingle,
                BackColor   = Color.Black
            };

            flowPanel.Controls.Add(p);

            this.ResumeLayout();
        }
Пример #9
0
 /* Constructors */
 public ZiCharacterV3(IZiFont parent, uint codepoint, Bitmap bmp, byte kerningL = 0, byte kerningR = 0)
 {
     Parent    = parent;
     CodePoint = codepoint;
     _Bitmap   = new Bitmap(Parent.CharacterWidth, Parent.CharacterHeight);
     using (var graphics = Graphics.FromImage(_Bitmap)) {
         graphics.DrawImage(bmp, 0, 0);
     }
     if (_CharacterData != null)
     {
         _CharacterData = null;
     }
     KerningRight    = KerningLeft = 0;       // Kerning is not supported in V3
     Width           = Parent.CharacterWidth; // Fixed Width set by Parent Font
     DataState       = ValidData.BITMAP;
     OriginalFormat  = DataState;
     ForegroundColor = Color.Green;
 }
Пример #10
0
 /* Constructors */
 public ZiCharacterV5(IZiFont parent, uint codepoint, Bitmap bmp, byte kerningL = 0, byte kerningR = 0)
 {
     Parent    = parent;
     CodePoint = codepoint;
     _Bitmap   = new Bitmap(bmp.Width, bmp.Height);
     using (var graphics = Graphics.FromImage(_Bitmap))
     {
         graphics.DrawImage(bmp, 0, 0);
     }
     if (_CharacterData != null)
     {
         _CharacterData = null;
     }
     KerningLeft     = kerningL;
     KerningRight    = kerningR;
     Width           = (byte)(bmp.Width - kerningL - kerningR);
     DataState       = ValidData.BITMAP;
     OriginalFormat  = DataState;
     ForegroundColor = Color.Green;
 }
Пример #11
0
        private void CreateCharacterPreview(IZiFont font)
        {
            flowPanel.Controls.Clear();
            this.SuspendLayout();

            for (int i = 0; i < font.Characters.Count; i++)
            {
                var b = font.Characters[i].ToBitmap();
                if (b != null && b.PixelFormat != System.Drawing.Imaging.PixelFormat.Undefined)
                {
                    var p = new PictureBox()
                    {
                        Width       = b.Width + 2,
                        Height      = font.CharacterHeight + 2,
                        Image       = b,
                        BorderStyle = BorderStyle.FixedSingle,
                        BackColor   = Color.White
                    };
                    flowPanel.Controls.Add(p);
                }
                else
                {
                    var img = new Bitmap(font.CharacterHeight + 2, 2);
                    var p   = new PictureBox()
                    {
                        Width       = 2,
                        Height      = font.CharacterHeight + 2,
                        Image       = img,
                        BorderStyle = BorderStyle.FixedSingle,
                        BackColor   = Color.White
                    };

                    flowPanel.Controls.Add(p);
                }
                if (i >= 124)
                {
                    break;
                }
            }
            this.ResumeLayout();
        }
 public ZiCharacterV5(IZiFont parent, uint codepoint, byte[] bytes, byte width, byte kerningL = 0, byte kerningR = 0)
 {
     Parent    = parent;
     CodePoint = codepoint;
     if ((width + kerningL + kerningR) > 0 && Parent.CharacterHeight > 0)
     {
         // _Bitmap = new Bitmap(width, height);
     }
     else
     {
         if (_Bitmap != null && _Bitmap.PixelFormat != System.Drawing.Imaging.PixelFormat.Undefined)
         {
             _Bitmap.Dispose();
         }
     }
     _CharacterData = bytes;
     KerningLeft    = kerningL;
     KerningRight   = kerningR;
     DataState      = ValidData.CHARDATA;
     Width          = width;
     // Decode only when needed;
 }
 public ZiCharacterV5(IZiFont parent, uint codepoint, Font font, PointF location, String txt = null)
 {
     Parent    = parent;
     CodePoint = codepoint;
     SetString(font, location, txt);
 }