Exemplo n.º 1
0
 public VerticalCut GetVerticalCut(int index)
 {
     if (CutList.ContainsKey(index))
     {
         return(CutList[index]);
     }
     else
     {
         return(new VerticalCut());
     }
 }
Exemplo n.º 2
0
        private void ReadFONT(FNT FNT)
        {
            Height  = FNT.Header.Glyphs.Size1;
            Width   = FNT.Header.Glyphs.Size2;
            Palette = FNT.Palette.Pallete;
            if (FNT.Header.Glyphs.BitsPerPixel == 4)
            {
                PixelFormat = PixelFormats.Indexed4;
            }
            else if (FNT.Header.Glyphs.BitsPerPixel == 8)
            {
                PixelFormat = PixelFormats.Indexed8;
            }
            else
            {
                throw new Exception("ReadFONT Error: unknown PixelFormat");
            }

            var DecList = FNT.Compressed.GetDecompressedData();

            if (FNT.Header.Glyphs.BitsPerPixel == 4)
            {
                ArrayTool.ReverseByteInList(DecList);
            }

            for (int i = 0; i < DecList.Count; i++)
            {
                var Cut = FNT.WidthTable[i] == null ? new VerticalCut(0, (byte)Width) : FNT.WidthTable[i].Value;

                int index = i + 32;
                if (DataList.ContainsKey(index))
                {
                    DataList[index] = DecList[i];
                }
                else
                {
                    DataList.Add(index, DecList[i]);
                }

                if (CutList.ContainsKey(index))
                {
                    CutList[index] = Cut;
                }
                else
                {
                    CutList.Add(index, Cut);
                }
            }
        }
Exemplo n.º 3
0
 private void OpenFont(FNT FNT)
 {
     try
     {
         ReadFONT(FNT);
         if (CutList.ContainsKey(32))
         {
             CutList[32] = new VerticalCut(10, 20);
         }
     }
     catch (Exception e)
     {
         //Logging.Write("PersonaEditorLib", e);
     }
 }
Exemplo n.º 4
0
        public Tuple <byte[], VerticalCut> GetGlyph(int index)
        {
            byte[]      data        = null;
            VerticalCut verticalCut = new VerticalCut();

            if (DataList.ContainsKey(index))
            {
                data = DataList[index];
            }
            if (CutList.ContainsKey(index))
            {
                verticalCut = CutList[index];
            }

            return(new Tuple <byte[], VerticalCut>(data, verticalCut));
        }
Exemplo n.º 5
0
        public Dictionary <char, int> GetCharWidth(PersonaEncoding encoding)
        {
            Dictionary <char, int> returned = new Dictionary <char, int>();

            foreach (var a in encoding.Dictionary)
            {
                if (CutList.ContainsKey(a.Key))
                {
                    if (!returned.ContainsKey(a.Value))
                    {
                        var temp = CutList[a.Key];
                        returned.Add(a.Value, temp.Right - temp.Left);
                    }
                }
            }

            return(returned);
        }