-
大小: 9KB文件類型: .7z金幣: 1下載: 0 次發(fā)布日期: 2021-05-10
- 語(yǔ)言: C#
- 標(biāo)簽: 點(diǎn)陣字體??
資源簡(jiǎn)介
MCU開發(fā)中,顯示字體使用了UCDOS中的HZK16,這是查看這類點(diǎn)陣字庫(kù)的工具
詳見:http://blog.csdn.net/mostone/article/details/10415069
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
namespace?HZK
{
????public?partial?class?Form1?:?Form
????{
????????System.IO.Stream?pFontReadStream;
????????string?pFontFileName;
????????int?pPageNo?=?0;
????????Size?pFontSize;
????????Bitmap?pBitmap;
????????Graphics?pGraphics;
????????FormOpenFontDialog?pDialog?=?null;
????????static?string[]?FONT_SIZE_LIST?=?new?string[]?{?“12x6“?“12x8“?“12x12“?“16x8“?“16x16“?“24x24“?“40x20“?“40x40“?“48x24“?“48x48“?};
????????public?Form1()
????????{
????????????InitializeComponent();
????????????this.pBitmap?=?new?Bitmap(930?910);
????????????this.pGraphics?=?Graphics.FromImage(pBitmap);
????????????this.toolStripStatusLabel1.Visible?=?false;
????????????this.toolStripProgressBar1.Visible?=?false;
????????????this.comboBox1.Items.AddRange(FONT_SIZE_LIST.ToArray());
????????}
????????public?static?string[]?getFontSizeList()
????????{
????????????return?FONT_SIZE_LIST;
????????}
????????private?Size?getSize(string?value)
????????{
????????????return?new?Size(Int16.Parse(value.Substring(3))?Int16.Parse(value.Substring(0?2)));
????????}
????????private?void?btnPickFont_Click(object?sender?EventArgs?e)
????????{
????????????if?(pDialog?==?null)?pDialog?=?new?FormOpenFontDialog();
????????????if?(pDialog.ShowDialog()?!=?DialogResult.OK)?return;
????????????pFontReadStream?=?pDialog.getFontFileStream();
????????????pFontSize?=?this.getSize(pDialog.getFontSize());
????????????pFontFileName?=?pDialog.getFontFileName();
????????????this.comboBox1.SelectedIndexChanged?-=?new?EventHandler(this.comboBox1_SelectedIndexChanged);
????????????this.comboBox1.SelectedItem?=?pDialog.getFontSize();
????????????this.comboBox1.SelectedIndexChanged?+=?new?EventHandler(this.comboBox1_SelectedIndexChanged);
????????????redraw();
????????}
????????private?void?redraw()
????????{
????????????pPageNo?=?0;
????????????drawPage(pPageNo);
????????????this.toolStripStatusLabel1.Text?=?String.Format(“{0}???Font?size:{1}x{2}“?pFontFileName?pFontSize.Height?pFontSize.Width);
????????}
????????private?void?drawPage(int?pageNo)
????????{
????????????if?(pFontReadStream?==?null)?return;
????????????const?int?space?=?5;
????????????const?int?ox?=?50;
????????????const?int?oy?=?20;
????????????Point?pt?=?new?Point(ox?oy);
????????????pFontReadStream.Position?=?pageNo?*?16?*?16?*?(pFontSize.Width?==?12???16?:?pFontSize.Width)?*?pFontSize.Height?/?8;
????????????pGraphics.Clear(this.pictureBox1.BackColor);
????????????this.toolStripStatusLabel1.Visible?=?false;
????????????this.toolStripProgressBar1.Visible?=?true;
????????????List?list?=?new?List();
????????????bool?eof?=?false;
????????????int?tmp;
????????????for?(int?row?=?0;?row?16;?row++)
???
評(píng)論
共有 條評(píng)論