示例#1
0
        public static GlyphSet CreateEmpty()
        {
            GlyphSet set = new GlyphSet();

            for (int i = 0; i < 256; i++)
            {
                set.Glyphs.Add(new Glyph(i));
            }

            return(set);
        }
示例#2
0
        public static GlyphSet OpenHFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return(null);
            }

            using (StreamReader sr = new StreamReader(filePath))
            {
                if (sr.ReadLine() != "PROGMEM const byte fontdata[16384] = {")
                {
                    return(null);
                }

                GlyphSet set = new GlyphSet();

                byte[] gdata = new byte[256];
                string line  = "";
                for (int g = 0; g < 256; g++)
                {
                    gdata = new byte[256];

                    line = sr.ReadLine().Trim() + sr.ReadLine().Trim().TrimEnd(',');
                    string[] values = line.Split(',');

                    for (int i = 0; i < values.Length; i++)
                    {
                        int hx = Int32.Parse(values[i].Substring(2, 2), System.Globalization.NumberStyles.HexNumber);

                        gdata[(i * 4)]     = (byte)(hx >> 6 & 3);
                        gdata[(i * 4) + 1] = (byte)(hx >> 4 & 3);
                        gdata[(i * 4) + 2] = (byte)(hx >> 2 & 3);
                        gdata[(i * 4) + 3] = (byte)(hx & 3);
                    }

                    set.Glyphs.Add(new Glyph(g, gdata));
                }

                sr.Close();

                return(set);
            }
        }
示例#3
0
        public static GlyphSet OpenMcmFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                return(null);
            }

            using (StreamReader sr = new StreamReader(filePath))
            {
                if (sr.ReadLine() != "MAX7456")
                {
                    return(null);
                }

                GlyphSet set = new GlyphSet();

                byte[] gdata = new byte[256];
                string line  = "";
                for (int g = 0; g < 256; g++)
                {
                    gdata = new byte[256];

                    for (int i = 0; i < 64; i++)
                    {
                        line = sr.ReadLine();

                        for (int c = 0; c < 4; c++)
                        {
                            gdata[(i * 4) + c] |= (byte)((line[c * 2] == '1' ? 1 : 0) << 1);
                            gdata[(i * 4) + c] |= (byte)((line[(c * 2) + 1] == '1' ? 1 : 0));
                        }
                    }

                    set.Glyphs.Add(new Glyph(g, gdata));
                }

                sr.Close();

                return(set);
            }
        }