private void btnAuto_Click(object sender, EventArgs e) { _data[0x41].Width = 0x0E; _data[0x4F].Width = 0x0E; _data[0x55].Width = 0x0E; _data[0x4E].Width = 0x0E; var replacements = new List <Tuple <char, char, char> > { new Tuple <char, char, char>('É', '\u0026', 'E'), //& new Tuple <char, char, char>('Í', '\u0027', 'I'), //' new Tuple <char, char, char>('á', '\u003B', 'a'), //; new Tuple <char, char, char>('é', '\u005C', 'e'), //\ new Tuple <char, char, char>('í', '\u005E', 'i'), //^ new Tuple <char, char, char>('ó', '\u005F', 'o'), //_ new Tuple <char, char, char>('ú', '\u0060', 'u'), //` new Tuple <char, char, char>('ü', '\u007B', 'u'), //{ new Tuple <char, char, char>('ñ', '\u007D', 'n'), //} new Tuple <char, char, char>('¡', '\u007E', 'i'), //~ new Tuple <char, char, char>('¿', '\u007F', '?'), //DEL }; foreach (var(_, item2, item3) in replacements) { _data[item2].Width = _data[item3].Width; } FontCharsGridView.Invalidate(); }
private void btnAutoAdjust_Click(object sender, EventArgs e) { const int pixelsSpace = 2; if (_newFontImage != null) { var result = MessageBox.Show("Esta opción eliminará los ajustes actuales. ¿Quieres continuar?", "Ajuste automático", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) { return; } for (var i = 0x00; i < 0x20; i++) { _data[i][0] = 0f; _data[i][1] = 0f; _data[i][2] = 0f; _data[i][3] = 0f; _data[i][4] = 0f; _data[i][5] = 0f; } _data[0x20][0] = 0.5f; _data[0x20][1] = 0.5f; _data[0x20][2] = 0.5f; _data[0x20][3] = 0.5f; _data[0x20][4] = 0.5f; _data[0x20][5] = 0.5f; for (var i = 0x21; i < 0x80; i++) { var bitmap = GetCharImage(_newFontImage, (byte)i); var tlPixel = Math.Min(bitmap.Width / 2, GetMinPixel(bitmap, new Rectangle(0, 0, bitmap.Width / 2, bitmap.Height / 3))); var mlPixel = Math.Min(bitmap.Width / 2, GetMinPixel(bitmap, new Rectangle(0, bitmap.Height / 3, bitmap.Width / 2, bitmap.Height / 3))); var blPixel = Math.Min(bitmap.Width / 2, GetMinPixel(bitmap, new Rectangle(0, 2 * bitmap.Height / 3, bitmap.Width / 2, bitmap.Height / 3))); var trPixel = Math.Max(bitmap.Width / 2, GetMaxPixel(bitmap, new Rectangle(bitmap.Width / 2, 0, bitmap.Width / 2, bitmap.Height / 3))); var mrPixel = Math.Max(bitmap.Width / 2, GetMaxPixel(bitmap, new Rectangle(bitmap.Width / 2, bitmap.Height / 3, bitmap.Width / 2, bitmap.Height / 3))); var brPixel = Math.Max(bitmap.Width / 2, GetMaxPixel(bitmap, new Rectangle(bitmap.Width / 2, 2 * bitmap.Height / 3, bitmap.Width / 2, bitmap.Height / 3))); _data[i][0] = (tlPixel - pixelsSpace) / (bitmap.Width / 2f); _data[i][1] = (bitmap.Width - (trPixel + pixelsSpace)) / (bitmap.Width / 2f); _data[i][2] = (mlPixel - pixelsSpace) / (bitmap.Width / 2f); _data[i][3] = (bitmap.Width - (mrPixel + pixelsSpace)) / (bitmap.Width / 2f); _data[i][4] = (blPixel - pixelsSpace) / (bitmap.Width / 2f); _data[i][5] = (bitmap.Width - (brPixel + pixelsSpace)) / (bitmap.Width / 2f); } for (var i = 0x80; i < 0xA1; i++) { _data[i][0] = 0f; _data[i][1] = 0f; _data[i][2] = 0f; _data[i][3] = 0f; _data[i][4] = 0f; _data[i][5] = 0f; } for (var i = 0xA1; i < 0x100; i++) { var bitmap = GetCharImage(_newFontImage, (byte)i); var tlPixel = Math.Min(bitmap.Width / 2, GetMinPixel(bitmap, new Rectangle(0, 0, bitmap.Width / 2, bitmap.Height / 3))); var mlPixel = Math.Min(bitmap.Width / 2, GetMinPixel(bitmap, new Rectangle(0, bitmap.Height / 3, bitmap.Width / 2, bitmap.Height / 3))); var blPixel = Math.Min(bitmap.Width / 2, GetMinPixel(bitmap, new Rectangle(0, 2 * bitmap.Height / 3, bitmap.Width / 2, bitmap.Height / 3))); var trPixel = Math.Max(bitmap.Width / 2, GetMaxPixel(bitmap, new Rectangle(bitmap.Width / 2, 0, bitmap.Width / 2, bitmap.Height / 3))); var mrPixel = Math.Max(bitmap.Width / 2, GetMaxPixel(bitmap, new Rectangle(bitmap.Width / 2, bitmap.Height / 3, bitmap.Width / 2, bitmap.Height / 3))); var brPixel = Math.Max(bitmap.Width / 2, GetMaxPixel(bitmap, new Rectangle(bitmap.Width / 2, 2 * bitmap.Height / 3, bitmap.Width / 2, bitmap.Height / 3))); _data[i][0] = (tlPixel - pixelsSpace) / (bitmap.Width / 2f); _data[i][1] = (bitmap.Width - (trPixel + pixelsSpace)) / (bitmap.Width / 2f); _data[i][2] = (mlPixel - pixelsSpace) / (bitmap.Width / 2f); _data[i][3] = (bitmap.Width - (mrPixel + pixelsSpace)) / (bitmap.Width / 2f); _data[i][4] = (blPixel - pixelsSpace) / (bitmap.Width / 2f); _data[i][5] = (bitmap.Width - (brPixel + pixelsSpace)) / (bitmap.Width / 2f); } FontCharsGridView.Invalidate(); imgBoxNewChar.Invalidate(); DrawText(); } }