static public void printenglisghchar(string ch, System.Drawing.Printing.PrintPageEventArgs e, float x, float y) { float cInter = 5F; //中文间距 float eInter = 2.6F; //英文数字间距 Brush ptBrush = Brushes.Black; Font ptFontCn = new Font("TEC", 18.5F, System.Drawing.FontStyle.Regular); Font ptFontEn = null; if (EagleAPI2.ExistFont("MingLiU")) { ptFontEn = new Font("MingLiU", 11.0F, System.Drawing.FontStyle.Regular); } else if (EagleAPI2.ExistFont("楷体_GB2312")) { ptFontEn = new Font("楷体_GB2312", 12.0F, System.Drawing.FontStyle.Regular); } else if (EagleAPI2.ExistFont("Courier New")) { ptFontEn = new Font("Courier New", 12.0F, System.Drawing.FontStyle.Regular); } else if (EagleAPI2.ExistFont("Courier")) { ptFontEn = new Font("Courier", 12.0F, System.Drawing.FontStyle.Regular); } else { ptFontEn = new Font("System", 12.0F, System.Drawing.FontStyle.Regular); } Font ptFontNo = null; if (EagleAPI2.ExistFont("MingLiU")) { ptFontNo = new Font("MingLiU", 11.0F, System.Drawing.FontStyle.Regular); } ptFontEn = new Font("TEC", 18.0F, System.Drawing.FontStyle.Regular); ptFontNo = new Font("TEC", 18.0F, System.Drawing.FontStyle.Regular); string lkxm = ch; for (int i = 0; i < lkxm.Length; i++) { if (lkxm[i] == '-') { e.Graphics.DrawString(lkxm[i].ToString(), ptFontCn, ptBrush, x + eInter * i - 0.3F, y - 1F); } else if (lkxm[i] > '9') { e.Graphics.DrawString(lkxm[i].ToString(), ptFontEn, ptBrush, x + eInter * i, y - 1F);//-1F为TEC字体 } else { e.Graphics.DrawString(lkxm[i].ToString(), ptFontNo, ptBrush, x + eInter * i, y - 1F);//-1F为TEC字体 } } }
public static void printchinesechar(string ch, System.Drawing.Printing.PrintPageEventArgs e, float x, float y) { float cInter = 5F; float eInter = 2.6F; Brush ptBrush = Brushes.Black; Font ptFontCn = new Font("TEC", 18.5F, System.Drawing.FontStyle.Regular); Font ptFontEn = null; if (EagleAPI2.ExistFont("MingLiU")) { ptFontEn = new Font("MingLiU", 11.0F, System.Drawing.FontStyle.Regular); } else if (EagleAPI2.ExistFont("楷体_GB2312")) { ptFontEn = new Font("楷体_GB2312", 12.0F, System.Drawing.FontStyle.Regular); } else if (EagleAPI2.ExistFont("Courier New")) { ptFontEn = new Font("Courier New", 12.0F, System.Drawing.FontStyle.Regular); } else if (EagleAPI2.ExistFont("Courier")) { ptFontEn = new Font("Courier", 12.0F, System.Drawing.FontStyle.Regular); } else { ptFontEn = new Font("System", 12.0F, System.Drawing.FontStyle.Regular); } Font ptFontNo = null; if (EagleAPI2.ExistFont("MingLiU")) { ptFontNo = new Font("MingLiU", 11.0F, System.Drawing.FontStyle.Regular); } ptFontEn = new Font("TEC", 18.0F, System.Drawing.FontStyle.Regular); ptFontNo = new Font("TEC", 18.0F, System.Drawing.FontStyle.Regular); if (ch.CompareTo("zzzzzzzzzzzzzzz") > 0) { string lkxm = ch; float xpos = x; for (int i = 0; i < lkxm.Length; i++) { if (lkxm[i] > 'z') { e.Graphics.DrawString(lkxm[i].ToString(), ptFontCn, ptBrush, xpos, y);//Z文 xpos += cInter; } else { e.Graphics.DrawString(lkxm[i].ToString(), ptFontEn, ptBrush, xpos, y + 2.5F - 1F);//E文 -1F为TEC字体 xpos += eInter; } } } else { e.Graphics.DrawString(ch, ptFontEn, ptBrush, x, y); } }