/// <summary> /// paint it /// </summary> protected override void OnPaint(PaintEventArgs e) { CharacterDefinitions defs; Point pos; e.Graphics.TextRenderingHint=this.RenderingHint; try { // create bitmaps for this string defs=new CharacterDefinitions(); defs.ParseCharacters(this,this.FontDef,this.Text,false); // blit them into the display pos=this.Position; foreach(CharDef cd in defs.Definitions) { if(cd.Character!=' ') e.Graphics.DrawImage(cd.CharacterBitmap,pos); pos.X+=cd.Size.Width+this.FontDef.Spacing; } } catch { using(SolidBrush brush=new SolidBrush(Color.PaleVioletRed)) e.Graphics.FillRectangle(brush,ClientRectangle); } }
/// <summary> /// paint it /// </summary> protected override void OnPaint(PaintEventArgs e) { CharacterDefinitions defs; Point pos; e.Graphics.TextRenderingHint = this.RenderingHint; try { // create bitmaps for this string defs = new CharacterDefinitions(); defs.ParseCharacters(this, this.FontDef, this.Text, false); // blit them into the display pos = this.Position; foreach (CharDef cd in defs.Definitions) { if (cd.Character != ' ') { e.Graphics.DrawImage(cd.CharacterBitmap, pos); } pos.X += cd.Size.Width + this.FontDef.Spacing; } } catch { using (SolidBrush brush = new SolidBrush(Color.PaleVioletRed)) e.Graphics.FillRectangle(brush, ClientRectangle); } }
/// <summary> /// estimate the size /// </summary> public int Estimate(Control refCtrl) { char[] chars; CharacterDefinitions charDefs=new CharacterDefinitions(); int byteTotal; Cursor.Current=Cursors.WaitCursor; try { // the selected characters need to be sorted chars=this.FontDef.Characters.ToCharArray(); Array.Sort(chars); this.FontDef.Characters=new string(chars); // create the char definitions charDefs.ParseCharacters(refCtrl,this.FontDef,this.FontDef.Characters,true); // sum up the bytes byteTotal=0; foreach(CharDef cd in charDefs.Definitions) byteTotal+=cd.CompressedBytes.Length; // add on the fontchar requirements (4 byte struct on the arduino) byteTotal+=this.FontDef.Characters.Length*4; return byteTotal; } finally { Cursor.Current=Cursors.Default; } }
/// <summary> /// write the font data /// </summary> public void Write(Control refCtrl) { SortedSet <char> charset; // get the filenames if (_filenames.GetFilenames() == DialogResult.Cancel) { return; } Cursor.Current = Cursors.WaitCursor; try { // remove duplicate characters and sort while we're at it charset = new SortedSet <char>(); foreach (char c in this.FontDef.Characters) { if (!charset.Contains(c)) { charset.Add(c); } } this.FontDef.Characters = string.Empty; foreach (char c in charset) { this.FontDef.Characters += c; } // create the char definitions _charDefs.ParseCharacters(refCtrl, this.FontDef, this.FontDef.Characters, true); // write the 3 files WriteDefinition(); WriteHeader(); WriteSource(); } finally { Cursor.Current = Cursors.Default; } }
/// <summary> /// estimate the size /// </summary> public int Estimate(Control refCtrl) { char[] chars; CharacterDefinitions charDefs = new CharacterDefinitions(); int byteTotal; Cursor.Current = Cursors.WaitCursor; try { // the selected characters need to be sorted chars = this.FontDef.Characters.ToCharArray(); Array.Sort(chars); this.FontDef.Characters = new string(chars); // create the char definitions charDefs.ParseCharacters(refCtrl, this.FontDef, this.FontDef.Characters, true); // sum up the bytes byteTotal = 0; foreach (CharDef cd in charDefs.Definitions) { byteTotal += cd.CompressedBytes.Length; } // add on the fontchar requirements (4 byte struct on the arduino) byteTotal += this.FontDef.Characters.Length * 4; return(byteTotal); } finally { Cursor.Current = Cursors.Default; } }