예제 #1
0
        public BitFont(int numChars, int width, int height, int codePage)
        {
            CodePage    = codePage;
            chars       = new FontCharacter[numChars];
            Width       = width;
            Height      = height;
            LegacyRatio = GetLegacyRatio(height);

            for (int i = 0; i < numChars; i++)
            {
                chars[i] = new FontCharacter(this);
            }
        }
예제 #2
0
        public BitFont(Stream stream, int codePage)
        {
            CodePage = codePage;
            var br = new BinaryReader(stream);

            Width       = br.ReadInt16();
            Height      = br.ReadInt16();
            LegacyRatio = GetLegacyRatio(Height);
            int nc = br.ReadInt16();

            chars = new FontCharacter[nc];
            for (int i = 0; i < nc; i++)
            {
                chars[i] = new FontCharacter(this);
            }
            Load(br);
        }
예제 #3
0
        public BitFont(BitFont source)
        {
            if (source.chars == null)
            {
                source.EnsureLoaded();
            }
            ID             = source.ID;
            Name           = source.Name;
            FontSet        = source.FontSet;
            CodePage       = source.CodePage;
            chars          = new FontCharacter[source.chars.Length];
            Width          = source.Width;
            Height         = source.Height;
            LegacyRatio    = source.LegacyRatio;
            Is9xFont       = source.Is9xFont;
            SauceID        = source.SauceID;
            IsStandardFont = source.IsStandardFont;
            IsSystemFont   = source.IsSystemFont;

            for (int i = 0; i < chars.Length; i++)
            {
                chars[i] = new FontCharacter(source.chars[i], this);
            }
        }
예제 #4
0
 public bool Equals(FontCharacter character)
 {
     return(data.Equals(character.data));
 }
예제 #5
0
 internal FontCharacter(FontCharacter fc, BitFont font)
 {
     data      = (int[])fc.data.Clone();
     this.font = font;
 }
예제 #6
0
        public float DrawCharacter(BGICanvas bgi, float x, float y, BGICanvas.Direction dir, int size, byte character, IList <Rectangle> updates)
        {
            byte          foreCol = bgi.GetColor();
            FontCharacter fc      = this[character];

            if (dir == BGICanvas.Direction.Horizontal)
            {
                int starty = (int)y;
                for (int cy = 0; cy < Height; cy++)
                {
                    int startx = (int)x;
                    for (int cx = 0; cx < Width; cx++)
                    {
                        if (fc[cx, cy])
                        {
                            if (size == 1)
                            {
                                bgi.PutPixelInternal(startx, starty, foreCol);
                            }
                            else
                            {
                                for (int ccy = 0; ccy < size; ccy++)
                                {
                                    for (int ccx = 0; ccx < size; ccx++)
                                    {
                                        bgi.PutPixelInternal(startx + ccx, starty + ccy, foreCol);
                                    }
                                }
                            }
                        }
                        startx += size;
                    }
                    starty += size;
                }
                var updateRect = new Rectangle((int)x, (int)y, Width * size, Height * size);
                if (updates != null)
                {
                    updates.Add(updateRect);
                }
                else
                {
                    bgi.UpdateRegion(updateRect);
                }
            }
            else
            {
                int startx = (int)x;
                for (int cy = 0; cy < Height; cy++)
                {
                    int starty = (int)y;
                    for (int cx = 0; cx < Width; cx++)
                    {
                        if (fc[cx, cy])
                        {
                            if (size == 1)
                            {
                                bgi.PutPixelInternal(startx, starty, foreCol);
                            }
                            else
                            {
                                for (int ccy = 0; ccy < size; ccy++)
                                {
                                    for (int ccx = 0; ccx < size; ccx++)
                                    {
                                        bgi.PutPixelInternal(startx + ccx, starty - ccy, foreCol);
                                    }
                                }
                            }
                        }
                        starty -= size;
                    }
                    startx += size;
                }
                var updateRect = new Rectangle((int)x, (int)y, Height * size, Width * size);
                if (updates != null)
                {
                    updates.Add(updateRect);
                }
                else
                {
                    bgi.UpdateRegion(updateRect);
                }
            }
            return(Width * size);
        }