You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

C# WinForms中Graphics.DrawString绘制字体在其他电脑上尺寸缩小问题

C# WinForms 二维码打印程序跨设备文本尺寸异常问题

我正在开发一款用于打印二维码的C# WinForms程序,程序会在空白图片(logo1.bmp)上绘制文本,核心代码如下:

Graphics g = Graphics.FromImage(logo1);
StringFormat stringformat_Model = new StringFormat();
stringformat_Model.Alignment = StringAlignment.Far;
stringformat_Model.LineAlignment = StringAlignment.Far;
g.DrawString(Stringformat_Model, new Font("Bahnschrift Condensed", 16, FontStyle.Regular), new SolidBrush(Color.Black), new Point(467, 265), SomeString);

在我的笔记本电脑上运行时,文本的对齐方式和字体大小均符合预期,但将程序部署到其他电脑后,字体种类未变,但文本尺寸明显缩小。

  • 其他电脑显示效果:文本尺寸缩小,与预期大小不符
  • 我的笔记本显示效果:文本大小、对齐均正常

内容的提问来源于stack exchange,提问作者karthik shanmugam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 12:18:07