📄 fontodlg.cpp
字号:
pDC->SetPixel(xy,pix_col);
}
}
}
}
return 1;
}
HBRUSH CFontoDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
// TODO: Change any attributes of the DC here
switch(nCtlColor)
{
case CTLCOLOR_STATIC:
pDC->SetBkMode(TRANSPARENT);
return (HBRUSH) mHollowBrush.m_hObject;
break;
default:
break;
}
// TODO: Return a different brush if the default is not desired
return hbr;
}
void CFontoDlg::OnChangeEditHz()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(m_sHZCode.GetLength()>0)
{
Invalidate(TRUE);
}
}
void CFontoDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
int data_valid_change=0;
if(m_nWidth<8)
{
m_nWidth=8;
data_valid_change=1;
}
if(m_nWidth>80)
{
m_nWidth=80;
data_valid_change=1;
}
if(m_nHeight<8)
{
m_nHeight=8;
data_valid_change=1;
}
if(m_nHeight>80)
{
m_nHeight=80;
data_valid_change=1;
}
if(data_valid_change)
UpdateData(FALSE);
if(m_sHZCode.GetLength()>0)
{
Invalidate(TRUE);
}
// CDialog::OnOK();
}
void CFontoDlg::OnButtonSelfont()
{
// TODO: Add your control notification handler code here
CFontDialog dlgFont(&m_lfFont);
if(dlgFont.DoModal())
{
Invalidate(TRUE);
}
}
void CFontoDlg::OnChangeEDITWidth()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
// UpdateData(TRUE);
// Invalidate(TRUE);
}
void CFontoDlg::OnChangeEDITHeight()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
// UpdateData(TRUE);
// Invalidate(TRUE);
}
void CFontoDlg::OnButtonGenall()
{
// TODO: Add your control notification handler code here
int x,y;
CFile of;
char fn[120];
wsprintf(fn,"HzFont_%s_%dx%d.c",m_lfFont.lfFaceName,m_nWidth,m_nHeight);
if(!of.Open(fn,CFile::modeCreate|CFile::modeWrite))
return;
CWnd *pWndFontView=GetDlgItem(IDC_STATIC_FONTVIEW);
if(!pWndFontView)
return;
CDC *pDC= pWndFontView->GetDC();
for(x=160+16;x<160+87;x++)
for(y=160+1;y<160+94;y++)
{
unsigned char HzCode[3];
int m,n;
HzCode[0]=x;
HzCode[1]=y;
HzCode[2]=0x0;
m_sHZCode=HzCode;
DrawFontView(pDC);
// UpdateData(TRUE);
// Invalidate(TRUE);
{
int i,j,line_output_bytes_count;
char out_buf[120];
CString output;
wsprintf(out_buf,"{ /* GBCode %02x %02x, // %s */ \r\n",x,y,HzCode);
output = out_buf;
for(j=0;j<m_nHeight;j++)
{
int line_dot_count=0;
line_output_bytes_count=0;
for(i=0;i<m_nBytesPerLine;i++)
{
unsigned char bitmap_8_dot=0;
unsigned char mask_8_dot=0x80;
while(mask_8_dot && line_dot_count<m_nActualWidth)
{
if(CharBitmap[j][line_dot_count])
bitmap_8_dot|=mask_8_dot;
mask_8_dot>>=1;
line_dot_count++;
}
wsprintf(out_buf,"0x%02x,",bitmap_8_dot);
output += out_buf;
if(++line_output_bytes_count==20)
{
line_output_bytes_count=0;
output += "\r\n";
}
}
output += "\r\n";
}
output += "},\r\n";
of.Write(output.LockBuffer(),output.GetLength());
}
}
}
void CFontoDlg::OnButton_32x24_all()
{
// TODO: Add your control notification handler code here
int x,y;
CFile of;
char fn[120];
wsprintf(fn,"HzFont_%s_%dx%d.bin",m_lfFont.lfFaceName,m_nWidth,m_nHeight);
if(!of.Open(fn,CFile::modeCreate|CFile::modeWrite))
return;
CWnd *pWndFontView=GetDlgItem(IDC_STATIC_FONTVIEW);
if(!pWndFontView)
return;
CDC *pDC= pWndFontView->GetDC();
char out_buf[32*24/8];
for(x=160+16;x<=160+87;x++)
for(y=160+1;y<=160+94;y++)
{
unsigned char HzCode[3];
int m,n;
HzCode[0]=x;
HzCode[1]=y;
HzCode[2]=0x0;
m_sHZCode=HzCode;
DrawFontView(pDC);
// UpdateData(TRUE);
// Invalidate(TRUE);
{
int i,j,output_bytes_count;
output_bytes_count=0;
for(j=0;j<24;j++)
{
int line_dot_count=0;
for(i=0;i<32/8;i++)
{
unsigned char bitmap_8_dot=0;
unsigned char mask_8_dot=0x80;
while(mask_8_dot && line_dot_count<m_nActualWidth)
{
if(CharBitmap[j+6][line_dot_count])
bitmap_8_dot|=mask_8_dot;
mask_8_dot>>=1;
line_dot_count++;
}
out_buf[output_bytes_count++]=bitmap_8_dot;
}
}
of.Write(out_buf,32*24/8);
}
}
}
void CFontoDlg::OnButton_ASC_16x24_all()
{
// TODO: Add your control notification handler code here
int x,y;
CFile of;
char fn[120];
wsprintf(fn,"ASCFont_%s_%dx%d.bin",m_lfFont.lfFaceName,m_nWidth,m_nHeight);
if(!of.Open(fn,CFile::modeCreate|CFile::modeWrite))
return;
CWnd *pWndFontView=GetDlgItem(IDC_STATIC_FONTVIEW);
if(!pWndFontView)
return;
CDC *pDC= pWndFontView->GetDC();
char out_buf[32*24/8];
m_nActualWidth=16;
for(x=0x18;x<128;x++)
{
unsigned char HzCode[3];
int m,n;
HzCode[0]=x;
HzCode[1]=0x0;
m_sHZCode=HzCode;
DrawFontView(pDC);
{
int i,j,output_bytes_count;
output_bytes_count=0;
for(j=0;j<24;j++)
{
int line_dot_count=0;
for(i=0;i<16/8;i++)
{
unsigned char bitmap_8_dot=0;
unsigned char mask_8_dot=0x80;
while(mask_8_dot && line_dot_count<m_nActualWidth)
{
if(CharBitmap[j+6][line_dot_count])
bitmap_8_dot|=mask_8_dot;
mask_8_dot>>=1;
line_dot_count++;
}
out_buf[output_bytes_count++]=bitmap_8_dot;
}
}
of.Write(out_buf,16*24/8);
}
}
}
void CFontoDlg::OnButton_ASC_16x16_All_CCode()
{
// TODO: Add your control notification handler code here
int x,y;
CFile of;
char fn[120];
wsprintf(fn,"ASCFont_%s_%dx%d.c",m_lfFont.lfFaceName,m_nWidth,m_nHeight);
if(!of.Open(fn,CFile::modeCreate|CFile::modeWrite))
return;
CWnd *pWndFontView=GetDlgItem(IDC_STATIC_FONTVIEW);
if(!pWndFontView)
return;
CDC *pDC= pWndFontView->GetDC();
char out_buf[32*24/8];
for(x=0x18;x<128;x++)
{
unsigned char HzCode[3];
int m,n;
HzCode[0]=x;
HzCode[1]=0x0;
m_sHZCode=HzCode;
DrawFontView(pDC);
// UpdateData(TRUE);
// Invalidate(TRUE);
{
int i,j,line_output_bytes_count;
char out_buf[120];
CString output;
wsprintf(out_buf," /* ASC Code %02x %02x, %s */ \r\n",x,y,HzCode);
output = out_buf;
for(j=0;j<m_nHeight;j++)
{
int line_dot_count=0;
line_output_bytes_count=0;
for(i=0;i<m_nBytesPerLine;i++)
{
unsigned char bitmap_8_dot=0;
unsigned char mask_8_dot=0x80;
while(mask_8_dot && line_dot_count<m_nActualWidth)
{
if(CharBitmap[j][line_dot_count])
bitmap_8_dot|=mask_8_dot;
mask_8_dot>>=1;
line_dot_count++;
}
wsprintf(out_buf,"0x%02x,",bitmap_8_dot);
output += out_buf;
if(++line_output_bytes_count==20)
{
line_output_bytes_count=0;
output += "\r\n";
}
}
output += "\r\n";
}
output += "\r\n";
of.Write(output.LockBuffer(),output.GetLength());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -